home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2006 March / Gamestar_82_2006-03_dvd.iso / Dema / ankh_demo_en.exe / media / lua / AnkhQuest_CrocMask.lua < prev    next >
Encoding:
Text File  |  2005-12-08  |  38.9 KB  |  977 lines

  1. -----------------------------------------------------------------------
  2. -- the table where all the functions/methods go to
  3. -----------------------------------------------------------------------
  4. CrocMask = {
  5.    quest,
  6.    name,
  7.    locations,
  8.    iactors,
  9.    triggers,
  10.    conversations,
  11.    cutscenes,
  12.    checklist
  13. }
  14. -----------------------------------------------------------------------
  15.  
  16. -----------------------------------------------------------------------
  17. -- init function
  18. -----------------------------------------------------------------------
  19. function CrocMask:init()
  20.    local questName = "CrocMask"
  21.    -- the quest object stores the C++ object pointer (Quest object)
  22.    self.quest = QuestMgr:createQuest(questName)
  23.    self.name  = questName
  24.    
  25.    -- the locations associated with this quest
  26.    self.locations = {
  27.       --"bazar",
  28.       "nile",
  29.       "ship_wreck",
  30.       "desert_beach"
  31.       --"desert_crossing"
  32.    }
  33.  
  34.    -- the interactor objects associated with this quest
  35.    self.iactors = {
  36.       "item_silver_coin",
  37.       "item_key_pirate_chest",
  38.       "item_pirate_flag",
  39.       "item_compass_broken",
  40.       "item_treasure_dirty",
  41.       "item_shirt_hawai",
  42.       "item_stone_arm",
  43.       "item_compass_needle",
  44.       "item_compass_fixed",
  45.       "item_skull",
  46.       "item_croc_purse",
  47.       "item_croc_teeth",
  48.  
  49.       "item_hand_treasurer",
  50.       "animobj_ship_wreck_arm_treasurer",
  51.  
  52.       "iactor_desert_beach_to_desert_crossing",
  53.       --"iactor_ship_wreck_key_pirate_chest",
  54.       "iactor_ship_wreck_pirate_stuff",
  55.       "iactor_ship_wreck_to_desert_beach",
  56.       --"iactor_bazar_nile_stone_wet",
  57.       --"iactor_bazar_arabian_embassy_to_bazar_tharas_room",
  58.  
  59.       "iactor_ship_wreck_treasurer_arm",
  60.       "iactor_ship_wreck_treasurer_hand",
  61.  
  62.       "animobj_ship_wreck_pirate_chest",
  63.       --"animobj_ship_wreck_plank_top",
  64.       "animobj_ship_wreck_plank_bottom",
  65.       --"animobj_bazar_ferry",
  66.  
  67.       --"iactor_ship_wreck_dead_treasurer_arm",
  68.  
  69.       "char_nubian",
  70.       "char_granny",
  71.       "char_crocodile",
  72.       "char_tailor"
  73.    }
  74.  
  75.    -- the conversations associated with this quest
  76.    self.conversations = {
  77.       "CrocMask_granny_start",
  78.       "CrocMask_granny_done",
  79.       "CrocMask_granny_give_purse",
  80.       "CrocMask_nubian_freeride_to_bazar",
  81.       "CrocMask_nubian_freeride_to_desert_beach",
  82.       "CrocMask_nubian_hint",
  83.       "CrocMask_nubian_paid",
  84.       "CrocMask_nubian_quest",
  85.       "CrocMask_nubian_reunion"
  86.    }
  87.    
  88.    -- the cutscenes associated with this quest
  89.    self.cutscenes = {
  90.       "CrocMask_granny_give_purse",
  91.       "CrocMask_nubian_paid",
  92.       "CrocMask_nile_scene",
  93.       "CrocMask_pimp_my_ferry",
  94.       "CrocMask_ferry_to_desert_beach",
  95.       "CrocMask_ferry_to_bazar",
  96.       "CrocMask_open_pirate_chest"
  97.    }
  98.  
  99.    -- create a proximity trigger for the crocodile
  100.    local trig_args = ProximityTriggerArgs("myArgs")
  101.    trig_args.entity1 = "char_assil"
  102.    trig_args.entity2 = "char_crocodile"
  103.    trig_args.distance = 450
  104.    trig_args.lua_func = "CrocMask:CrocSnapsAtAssil"
  105.    trig_args.single_shot = false
  106.    EventTriggerMgr:createProximityEventTrigger("trig_ship_wreck_croc", trig_args)
  107.    self.quest:addTrigger("trig_ship_wreck_croc", "ship_wreck")
  108.    EventTriggerMgr:setEventTriggerMuted("trig_ship_wreck_croc",true)
  109.  
  110.    --self.quest:addTrigger("trig_desert_crossing_no_way", "desert_crossing")
  111.  
  112.    -- the checklist of little tasks associated with this quest
  113.    self.checklist = {
  114.       "CrocPurseTaken",       -- acquired the croc purse from the granny
  115.       "SpokenWithNubian",     -- got word that a silver coin is needed
  116.       "NubianPaid",           -- given silver coin to nubian ferryman
  117.       "PirateChestOpened",
  118.       "TreasurerHandTaken",
  119.       "KeyPirateChestTaken",
  120.       "PirateStuffTaken",
  121.       "StoneArmTaken",
  122.       "StoneArmWrapped",
  123.       "CrocodileDefeated",
  124.       "FerryPimped",
  125.       "ScissorsGiven",
  126.       "ScissorsSharpened",
  127.       "NeedleGiven",
  128.       "CompassFixed",
  129.       "NoCompassMessage",
  130.       "CompassHelpsMessage",
  131.       "SkullTaken",
  132.  
  133.       "FreeRideToDesert",
  134.       "FerryTakenToDesert",
  135.       "FreeRideToBazar",
  136.       "FerryTakenToBazar"
  137.    }
  138.  
  139.    -- associate the locations with the quest
  140.    for key, value in ipairs(self.locations) do
  141.       self.quest:addLocation(value)
  142.    end
  143.    -- associate the interactors with the quest
  144.    for key, value in ipairs(self.iactors) do
  145.       self.quest:addInteractor(value)
  146.    end
  147.    -- associate the conversations with the quest
  148.    for key, value in ipairs(self.conversations) do
  149.       self.quest:addConversation(value)
  150.    end
  151.    -- associate the cutscenes with the quest
  152.    for key, value in ipairs(self.cutscenes) do
  153.       self.quest:addCutscene(value)
  154.    end
  155.    -- associate the list items with the quest
  156.    for key, value in ipairs(self.checklist) do
  157.       self.quest:addTaskToCheckList(value)
  158.    end
  159.  
  160.    -- subscribe the lua functions to call
  161.    self.quest:subscribeLocationEntered(self.name .. ":onLocationEntered")
  162.    self.quest:subscribeLocationLeft(self.name .. ":onLocationLeft")
  163.    self.quest:subscribeInteractorEvent(self.name .. ":onInteractorEvent")
  164.    self.quest:subscribeInteractorEntered(self.name .. ":onMouseEnteredInteractor")
  165.    self.quest:subscribeInteractorLeft(self.name .. ":onMouseLeftInteractor")
  166.    self.quest:subscribeLocationFadingInFinished(self.name .. ":onLocationFadingInFinished")
  167.    self.quest:subscribeConversationEvent(self.name .. ":onConversationEvent")
  168.    self.quest:subscribeConversationFinished(self.name .. ":onConversationFinished")
  169.    self.quest:subscribeCutsceneFinished(self.name .. ":onCutsceneFinished")
  170.    self.quest:subscribeTriggerEvent(self.name .. ":onTriggerEvent")   
  171.    self.quest:subscribeTriggerFaceEvent(self.name .. ":onTriggerFaceEvent")   
  172.    self.quest:subscribeCheckListChanged(self.name .. ":updateFromCheckList")
  173.  
  174.    -- set the initial quest state
  175.    self.quest:setState("Initialized")
  176. end
  177. -----------------------------------------------------------------------
  178.  
  179. --------------------------------------------------------------------------
  180. -- sets the quest active and updates the iactor configurations
  181. --------------------------------------------------------------------------
  182. function CrocMask:activate()
  183.    _LogInfo(self.name .. ":activate", self.name)
  184.    self.quest:setActive(true)
  185.    self:initConfigurations()
  186. --   self:updateFromCheckList()
  187.  
  188.    self.quest:setDone("SpokenWithNubian")
  189.    self.quest:setDone("NubianPaid")
  190.  
  191.    -- used to equip the mask
  192.    item_croc_mask:setDefaultInventoryAction(Interactor.Use)
  193.    give("bar")
  194.  
  195.    animobj_crocodile_teeth_underwater:setIgnored(true)
  196.    iactor_desert_beach_to_desert_crossing:setIgnored(true)
  197.    -- set the secret passage to the palace to 'ignored' as Assil has to find it later
  198.    --iactor_bazar_to_palace_backdoor:setIgnored(true)
  199.  
  200. end
  201. -----------------------------------------------------------------------
  202.  
  203. -----------------------------------------------------------------------
  204. -- sets the quest inactive and resets the iactor configurations
  205. -----------------------------------------------------------------------
  206. function CrocMask:deactivate()
  207.    _LogInfo("CrocMask:deactivate", "called")
  208.    self.quest:setActive(false)
  209. end
  210. -----------------------------------------------------------------------
  211.  
  212.  
  213. -----------------------------------------------------------------------
  214. -- sets the given checklist element to true after the given amount of
  215. -- time (in seconds)
  216. -----------------------------------------------------------------------
  217. function CrocMask:setDoneDelayed(p_Task, p_Time)
  218.    TimedEventMgr:createTimedEvent("CrocMask.quest:setDone(\"" .. p_Task .. "\")", 
  219.                   p_Time)
  220. end
  221. -----------------------------------------------------------------------
  222.  
  223. -----------------------------------------------------------------------
  224. -- Encapsulates picking up an object
  225. -----------------------------------------------------------------------
  226. function CrocMask:pickupItem(p_Animation, p_Sentence,
  227.                    p_BlockTime, p_TaskToSet, p_TimeToSetTask)
  228.    if string.len(p_Sentence) > 0 then
  229.       player:say(p_Sentence)
  230.    end
  231.    player:blendToPlayOnceAndBack(p_Animation)
  232.    MouseIface:blockInput(p_BlockTime)
  233.    self:setDoneDelayed(p_TaskToSet, p_TimeToSetTask)
  234. end
  235. -----------------------------------------------------------------------
  236.  
  237. -----------------------------------------------------------------------
  238. -- lua slot called when an action was performed on an interactor
  239. -- associated with this quest
  240. -----------------------------------------------------------------------
  241. function CrocMask:onInteractorEvent(p_Interactor, p_ActionID, p_InteractedInteractor)
  242.    _LogInfo("CrocMask:onInteractorEvent", p_Interactor)
  243.  
  244.    local questState = self.quest:getState()
  245.    local iactor     = GameEntityMgr:getInteractor(p_Interactor)
  246.  
  247.    if iaction(p_Interactor,p_InteractedInteractor,"item_shirt_hawai","iactor_ship_wreck_dead_treasurer_arm") then
  248.       g_InteractionHandled = true
  249.       player:say("ID_ARM_ROTTEN")
  250.    end
  251.  
  252.    if iaction(p_Interactor,p_InteractedInteractor,"item_croc_teeth","item_croc_purse") or
  253.       iaction(p_Interactor,p_InteractedInteractor,"item_croc_teeth","item_skull") or 
  254.       iaction(p_Interactor,p_InteractedInteractor,"item_skull","item_croc_purse") then
  255.       g_InteractionHandled = true
  256.       player:say("ID_COMBINE_MASK")
  257.    end
  258.  
  259.    if (p_Interactor == "animobj_ship_wreck_arm_treasurer" or
  260.        p_Interactor == "iactor_ship_wreck_treasurer_arm") and p_ActionID == Interactor.Use then
  261.       char_assil:blendToPlayOnceAndBack("all_pickup_low")
  262.       MouseIface:blockInput(2)
  263.       --animobj_ship_wreck_arm_treasurer:setDefaultAction(Interactor.LookAt)
  264.       animobj_ship_wreck_arm_treasurer:setIgnored(true)
  265.       iactor_ship_wreck_treasurer_arm:setIgnored(true)
  266.       iactor_ship_wreck_treasurer_hand:setIgnored(false)
  267.       animobj_ship_wreck_arm_treasurer:playAnimation("pull")
  268.       item_hand_treasurer:playAnimation("pull")
  269.       sound("pirate_arm_throw")
  270.  
  271.       -- Ankh/Ship_wreck/pankh_treasurer_dust
  272.    end
  273.  
  274.    if (p_Interactor == "item_hand_treasurer" or p_Interactor == "iactor_ship_wreck_treasurer_hand") 
  275.       and p_ActionID == Interactor.Pickup then
  276.       self:pickupItem("all_pickup_low", "", 2.0, "TreasurerHandTaken", 0.8)
  277.       item_hand_treasurer:setDefaultInventoryAction(Interactor.Use)
  278.       iactor_ship_wreck_treasurer_hand:setIgnored(true)
  279.    end
  280.  
  281.    if p_Interactor == "item_hand_treasurer" and p_ActionID == Interactor.Use then
  282.       -- et voila: the key
  283.       self.quest:setDone("KeyPirateChestTaken")
  284.    end
  285.  
  286.    if p_Interactor == "animobj_bazar_ferry" and p_ActionID == Interactor.Use then
  287.       if self.quest:isDone("FerryTakenToDesert") then
  288.      self.quest:setUndone("FerryTakenToDesert")
  289.      self.quest:setDone("FerryTakenToBazar")
  290.  
  291.      api:cutscene_("CrocMask_ferry_to_bazar",0)
  292.  
  293.       elseif self.quest:isDone("FerryTakenToBazar") then
  294.      self.quest:setUndone("FerryTakenToBazar")
  295.      self.quest:setDone("FerryTakenToDesert")
  296.  
  297.      api:cutscene_("CrocMask_ferry_to_desert_beach",0)
  298.       end
  299.    end
  300.  
  301.    if p_Interactor == "char_nubian" and p_ActionID == Interactor.TalkTo then
  302.       if not self.quest:isDone("SpokenWithNubian") then
  303.          api:conversation("CrocMask_nubian_quest")
  304.       else
  305.          if not self.quest:isDone("NubianPaid") then
  306.             api:conversation("CrocMask_nubian_hint")
  307.          elseif not self.quest:isDone("FerryPimped") then
  308.             api:conversation("CrocMask_nubian_reunion")
  309.          else
  310.             if not self.quest:isDone("FerryTakenToBazar") then
  311.                -- start the conversation to go to the bazar
  312. --               self.quest:setUndone("FreeRideToBazar")
  313.                api:conversation("CrocMask_nubian_freeride_to_bazar")
  314.            animobj_bazar_ferry:setDefaultAction(Interactor.Use)
  315.             elseif not self.quest:isDone("FerryTakenToDesert") then
  316.                -- start the conversation to go to the desert
  317. --               self.quest:setUndone("FreeRideToDesert")
  318.                api:conversation("CrocMask_nubian_freeride_to_desert_beach")
  319.             end
  320.          end
  321.       end
  322.  
  323.    elseif p_Interactor == "iactor_ship_wreck_key_pirate_chest" and p_ActionID == Interactor.Use then
  324.       --iactor_ship_wreck_key_pirate_chest:setDefaultAction(Interactor.Pickup)
  325.       --iactor_ship_wreck_hand_closed:setVisible(false)
  326.       --iactor_ship_wreck_hand_opened:setVisible(true)
  327.  
  328.    elseif p_Interactor == "iactor_ship_wreck_key_pirate_chest" and p_ActionID == Interactor.Pickup then
  329.       self:pickupItem("all_pickup_low", "", 2.0, "KeyPirateChestTaken", 0.8)
  330.  
  331.    --elseif p_Interactor == "animobj_ship_wreck_plank_top" and p_ActionID == Interactor.Pickup then
  332.    --   animobj_ship_wreck_plank_top:setIgnored(true)
  333.    --   animobj_ship_wreck_plank_bottom:setIgnored(false)
  334.    --   api:animation("animobj_ship_wreck_plank_top", "animobj_ship_wreck_plank_top/planks_move")
  335.  
  336.    --elseif p_Interactor == "animobj_ship_wreck_plank_bottom" and p_ActionID == Interactor.Pickup then
  337.    --   animobj_ship_wreck_plank_bottom:setIgnored(true)
  338.    --   item_stone_arm:setIgnored(false)
  339.    --   api:animation("animobj_ship_wreck_plank_bottom", "animobj_ship_wreck_plank_bottom/planks_move")
  340.       
  341.    elseif p_Interactor == "animobj_ship_wreck_plank_bottom" and p_ActionID == Interactor.Pickup then
  342.       CharacterControllerMgr:say("char_assil", "ID_CANNOT_MOVE_IT")
  343.  
  344.    elseif p_Interactor == "animobj_ship_wreck_plank_bottom" and 
  345.       p_InteractedInteractor == "item_bar" then
  346.  
  347.       g_InteractionHandled = true
  348.  
  349.       sound("plank_remove")
  350.       char_assil:blendToPlayOnceAndBack("all_pull_lever")
  351.       MouseIface:blockInput(3)
  352.       animobj_ship_wreck_plank_bottom:setIgnored(true)
  353.       item_stone_arm:setIgnored(false)
  354.  
  355.       api:callDelayed("api:animation(\"animobj_ship_wreck_plank_bottom\",\"animobj_ship_wreck_plank_bottom/planks_move\")",1.0)
  356.       --api:animation("animobj_ship_wreck_plank_bottom", "animobj_ship_wreck_plank_bottom/planks_move")
  357.       Inventory:removeItemSafely("item_bar")
  358.  
  359.       -- Ankh/Ship_wreck/pankh_planks_dust
  360.  
  361.    elseif p_Interactor == "item_stone_arm" and p_ActionID == Interactor.Pickup then
  362.       self:pickupItem("all_pickup_low", "", 2.0, "StoneArmTaken", 0.8)
  363.       sound("stone_arm_pickup")
  364.    elseif (p_Interactor == "item_stone_arm" and p_InteractedInteractor == "item_shirt_hawai") or
  365.           (p_Interactor == "item_shirt_hawai" and p_InteractedInteractor == "item_stone_arm") then
  366.       g_InteractionHandled = true
  367.       if not self.quest:isDone("StoneArmTaken") then
  368.          self.quest:setDone("StoneArmTaken")
  369.       end
  370.       self.quest:setDone("StoneArmWrapped")
  371.  
  372.    elseif p_Interactor == "char_nubian" and p_InteractedInteractor == "item_silver_coin" then
  373.       g_InteractionHandled = true
  374.       -- already paid?
  375.       if self.quest:isDone("NubianPaid") then
  376.      -- nothing to do
  377.       elseif not self.quest:isDone("SpokenWithNubian") or
  378.          not EnterPalace.quest:isDone("GuardsFearRevealed") then
  379.          api:conversation("CrocMask_assil_keep_coin")
  380.       else
  381.          self.quest:setDone("NubianPaid")
  382.          Inventory:removeItemSafely("item_silver_coin")
  383.          api:conversation("CrocMask_nubian_paid")
  384.       end
  385.  
  386.    elseif iaction(p_Interactor, p_InteractedInteractor, "item_stone_arm", "item_pirate_flag") then
  387.       player:say("ID_FLAG_TOO_PRECIOUS")
  388.       g_InteractionHandled = true
  389.  
  390.    elseif p_Interactor == "animobj_ship_wreck_pirate_chest" and p_InteractedInteractor == "item_key_pirate_chest" then
  391.       g_InteractionHandled = true
  392.       -- cutscene with anims
  393.       api:cutscene("CrocMask_open_pirate_chest")
  394.       self.quest:setDone("PirateChestOpened")
  395.       --CharacterControllerMgr:say("char_assil", "Cool, I opened the chest!")
  396.       --iactor:playAnimation("open")
  397.       -- we do not need it anymore
  398.       Inventory:removeItemSafely("item_key_pirate_chest")
  399.  
  400.    elseif p_Interactor == "char_crocodile" and p_InteractedInteractor == "item_stone_arm" then
  401.       g_InteractionHandled = true
  402.       --EventTriggerMgr:setEventTriggerMuted("trig_ship_wreck_croc",true)
  403.       -- to be defined how to handle this
  404.       player:say("CFG_ITEM_STONE_ARM_LOOKAT")
  405.  
  406.    elseif p_Interactor == "char_crocodile" and p_InteractedInteractor == "item_stone_arm_shirt" then
  407.       g_InteractionHandled = true
  408.       EventTriggerMgr:setEventTriggerMuted("trig_ship_wreck_croc",true)
  409.       api:cutscene("CrocMask_crocodile_fight")
  410.       self.quest:setUndone("StoneArmWrapped")
  411.       Inventory:removeItem("item_stone_arm_shirt")
  412.  
  413.       -- pickup the pirate stuff within the (now opened) pirate chest
  414.    elseif p_Interactor == "iactor_ship_wreck_pirate_stuff" and p_ActionID == Interactor.Pickup then
  415.       self:pickupItem("all_pickup_midlow", "", 2.0, "PirateStuffTaken", 0.8)
  416.       
  417.       sound("pirate_stuff_pickup")
  418.  
  419.       -- pimp my ferry
  420.    elseif p_InteractedInteractor == "item_pirate_flag" then
  421.       if p_Interactor == "char_nubian" or p_Interactor == "iactor_ferry" then
  422.          g_InteractionHandled = true
  423.          -- cutscene: nubian applies flag
  424.          api:cutscene("CrocMask_pimp_my_ferry")
  425.          self.quest:setDone("FerryPimped")
  426.          Inventory:removeItem("item_pirate_flag")
  427.       end
  428.    
  429.    -- desert crossing
  430.    elseif p_Interactor == "item_skull" and p_ActionID == Interactor.Pickup then
  431.       self:pickupItem("all_pickup_low", "", 2.0, "SkullTaken", 0.8)
  432.       sound("skull_pickup")
  433.    -- talk to tailor
  434.    elseif p_Interactor == "char_tailor" and p_ActionID == Interactor.TalkTo then
  435.       if not self.quest:isDone("NeedleGiven") then
  436.          if not self.quest:isDone("ScissorsGiven") then
  437.             api:conversation("CrocMask_tailor_quest")
  438.          else
  439.             api:conversation("CrocMask_tailor_hint")
  440.          end
  441.       else
  442.          api:conversation("CrocMask_tailor_done")
  443.       end
  444.  
  445.    elseif p_Interactor == "iactor_bazar_nile_stone_wet" and p_InteractedInteractor == "item_scissors_blunt" then
  446.       g_InteractionHandled = true
  447.       if not self.quest:isDone("ScissorsSharpened") then
  448.          self:pickupItem("all_combine_low", "ID_CROCMASK_SCISSORS_SHARP", 2.0, "ScissorsSharpened", 1.3)
  449.          sound("scissors_sharpen")
  450.       else
  451.          CharacterControllerMgr:say("char_assil", "ID_CROCMASK_SCISSORS_SHARP")
  452.       end
  453.  
  454.    elseif (p_Interactor == "char_tailor" and p_InteractedInteractor == "item_scissors_sharp") or
  455.           (p_Interactor == "char_tailor" and p_InteractedInteractor == "item_scissors_blunt") then
  456.       g_InteractionHandled = true
  457.       api:conversation("CrocMask_tailor_hint")
  458.  
  459.    -- fix the compass
  460.    elseif (p_Interactor == "item_compass_broken" and p_InteractedInteractor == "item_compass_needle") or
  461.           (p_Interactor == "item_compass_needle" and p_InteractedInteractor == "item_compass_broken") then
  462.       g_InteractionHandled = true
  463.       self.quest:setDone("CompassFixed")
  464.       sound("compass_fix")
  465.       CharacterControllerMgr:say("char_assil", "ID_CROCMASK_COMPASS_FIXED")
  466.   
  467.    -- talk to granny
  468.    elseif p_Interactor == "char_granny" and p_ActionID == Interactor.TalkTo then
  469.       if not self.quest:isDone("CrocPurseTaken") then
  470.          api:conversation("CrocMask_granny_start")
  471.       else
  472.          api:conversation("CrocMask_granny_done")
  473.       end
  474.  
  475.    -- try to steal the purse
  476.    elseif p_Interactor == "item_croc_purse" and p_ActionID == Interactor.Pickup then
  477.       --api:cutscene("CrocMask_granny_give_purse")
  478.       api:conversation("CrocMask_granny_give_purse")
  479.    end
  480.  
  481. end
  482. -----------------------------------------------------------------------
  483. -- cam_bazar_granny
  484. -----------------------------------------------------------------------
  485. -- lua slot called when the mouse entered an iactor associated 
  486. -- with this quest
  487. -----------------------------------------------------------------------
  488. function CrocMask:onMouseEnteredInteractor(p_Interactor)
  489.    _LogInfo("CrocMask:onMouseEnteredInteractor", p_Interactor)
  490. end
  491. -----------------------------------------------------------------------
  492.  
  493. -----------------------------------------------------------------------
  494. -- lua slot called when the mouse left an iactor associated 
  495. -- with this quest
  496. -----------------------------------------------------------------------
  497. function CrocMask:onMouseLeftInteractor(p_Interactor)
  498.    _LogInfo("CrocMask:onMouseLeftInteractor", p_Interactor)
  499. end
  500. -----------------------------------------------------------------------
  501.  
  502. -----------------------------------------------------------------------
  503. -- lua slot called when the player entered a location that is associated
  504. -- with this quest
  505. -----------------------------------------------------------------------
  506. function CrocMask:onLocationEntered(p_Location)
  507.    _LogInfo("CrocMask:onLocationEntered", p_Location)
  508.  
  509.    if p_Location == "nile" then
  510. --      api:cutscene_("CrocMask_nile_scene",0)
  511.    end
  512.  
  513.    if p_Location == "bazar" then
  514. --      animobj_bazar_ferry:setConfiguration("cfg_animobj_bazar_ferry")
  515. --      char_nubian:setConfiguration("CrocMask_char_nubian_bazar")
  516.       if self.quest:isDone("FerryPimped") then
  517.      animobj_bazar_ferry:setDefaultAction(Interactor.Use)
  518.       end
  519.    end
  520.  
  521.    if p_Location == "desert_beach" then
  522.       if self.quest:isDone("FerryPimped") then
  523.      animobj_bazar_ferry:setDefaultAction(Interactor.Use)
  524.       end
  525.    end
  526.  
  527. end
  528. -----------------------------------------------------------------------
  529.  
  530. -----------------------------------------------------------------------
  531. -- lua slot called when the player left a location that is associated
  532. -- with this quest
  533. -----------------------------------------------------------------------
  534. function CrocMask:onLocationLeft(p_Location)
  535.    _LogInfo("CrocMask:onLocationLeft", p_Location)
  536.  
  537.    if p_Location == "desert_crossing" then
  538.       self.quest:setUndone("NoCompassMessage")
  539.    end
  540.  
  541. end
  542. -----------------------------------------------------------------------
  543.  
  544. -----------------------------------------------------------------------
  545. -- lua slot called whenever a location associated with this quest
  546. -- has finished fading in
  547. -----------------------------------------------------------------------
  548. function CrocMask:onLocationFadingInFinished(p_Location)
  549.    _LogInfo("CrocMask:onLocationFadingInFinished", p_Location)
  550. end
  551. -----------------------------------------------------------------------
  552.  
  553. -----------------------------------------------------------------------
  554. -- lua slot called when a cutscene associated with this quest was
  555. -- finished
  556. -----------------------------------------------------------------------
  557. function CrocMask:onCutsceneFinished(p_Cutscene)
  558.    _LogInfo("CrocMask:onCutsceneFinished", p_Cutscene)
  559.  
  560.    if p_Cutscene == "CrocMask_nile_scene" then
  561.       CrocMask:startShipWreckSequence()
  562.       
  563.       -- remove fruits and laxative (we don't need it anymore)
  564.       Inventory:removeItemSafely("item_fruit_a")
  565.       Inventory:removeItemSafely("item_fruit_b")
  566.       Inventory:removeItemSafely("item_fruit_c")
  567.       Inventory:removeItemSafely("item_laxative")
  568.  
  569.       item_fruit_a:setDefaultAction(Interactor.LookAt)
  570.       item_fruit_b:setDefaultAction(Interactor.LookAt)
  571.       item_fruit_c:setDefaultAction(Interactor.LookAt)
  572.       item_laxative:setDefaultAction(Interactor.LookAt)
  573.       --iactor_bazar_banana_hut_plate_lemons:setDefaultAction(Interactor.LookAt)
  574.    end
  575.  
  576.    if p_Cutscene == "CrocMask_granny_give_purse" then
  577.       Global:continueGrannyWalkLoop()
  578.       CameraMgr:activateCamera("cam_bazar_a")
  579.    end
  580.  
  581.    if p_Cutscene == "CrocMask_ferry_to_bazar" then
  582.       if self.quest:isDone("FerryPimped") then
  583.      animobj_bazar_ferry:setDefaultAction(Interactor.Use)
  584.       end
  585.    end
  586.  
  587.    if p_Cutscene == "CrocMask_ferry_to_desert_beach" then
  588.       if self.quest:isDone("FerryPimped") then
  589.      animobj_bazar_ferry:setDefaultAction(Interactor.Use)
  590.       end
  591.    end
  592.  
  593. end
  594. -----------------------------------------------------------------------
  595.  
  596. -----------------------------------------------------------------------
  597. -- lua slot called when a conversation associated with this quest
  598. -- was finished
  599. -----------------------------------------------------------------------
  600. function CrocMask:onConversationFinished(p_Conversation)
  601.    _LogInfo("CrocMask:onConversationFinished", p_Conversation)
  602.  
  603.    if p_Conversation == "CrocMask_nubian_paid" then
  604.       api:cutscene_("CrocMask_nile_scene",0)
  605.       self.quest:setDone("FerryTakenToDesert")
  606.    end
  607.  
  608.    if p_Conversation == "CrocMask_granny_give_purse" then
  609.       Global:continueGrannyWalkLoop()
  610.       CameraMgr:activateCamera("cam_bazar_a")
  611.    end
  612.  
  613.    if p_Conversation == "CrocMask_nubian_freeride_to_desert_beach" then
  614.       if self.quest:isDone("FreeRideToDesert") then
  615.          self.quest:setUndone("FerryTakenToBazar")
  616.  
  617.      --api:cutscene_("CrocMask_ferry_to_desert_beach",0)
  618.      -- thx for playing
  619.      Ankh:showExtroImage()
  620.  
  621.          self.quest:setDone("FerryTakenToDesert")
  622.       end
  623.    end
  624.  
  625.    if p_Conversation == "CrocMask_nubian_freeride_to_bazar" then
  626.       if self.quest:isDone("FreeRideToBazar") then
  627.          self.quest:setDone("FerryTakenToBazar")
  628.  
  629.      --api:cutscene_("CrocMask_ferry_to_bazar",0)
  630.      --api:cutscene_("CrocMask_ferry_to_desert_beach",0)
  631.      -- thx for playing
  632.      Demo:showExtroImage()
  633.  
  634.          self.quest:setUndone("FerryTakenToDesert")
  635.       end
  636.    end
  637.  
  638.    if p_Conversation == "CrocMask_granny_start" or
  639.       p_Conversation == "CrocMask_granny_done" then
  640.       Global:continueGrannyWalkLoop()
  641.       CameraMgr:activateCamera("cam_bazar_a")
  642.    end
  643.  
  644. end
  645. ----------------------------------------------------------------------
  646.  
  647. -----------------------------------------------------------------------
  648. -- lua slot called when a conversation associated with this quest
  649. -- has fired a special event
  650. -----------------------------------------------------------------------
  651. function CrocMask:onConversationEvent(p_Conversation, p_Event)
  652.    _LogInfo("CrocMask:onConversationEvent", p_Conversation .. ":" .. p_Event)
  653.  
  654.    if p_Conversation == "CrocMask_tailor_hint" and
  655.       p_Event == "CrocMask_needle_given" then
  656.       self.quest:setDone("NeedleGiven")
  657.       sound("needle_receive")
  658.       char_tailor:setConfiguration("cfg_char_tailor")
  659.    end
  660.  
  661.    if p_Event == "EventBeamAssilGranny" then
  662.       self:beamAssilGranny()
  663.    end
  664.  
  665. end
  666. -----------------------------------------------------------------------
  667.  
  668. -----------------------------------------------------------------------
  669. --
  670. -----------------------------------------------------------------------
  671. function CrocMask:beamAssilGranny()
  672.    --Global:stopBazarWalkLoops()
  673.    Global:stopGrannyWalkLoop()
  674.    char_assil:setPosition(101.284, 154.704, -1155.67)
  675.    char_assil:setOrientation(Degree(0),Degree(285),Degree(0))
  676.    --char_granny:setPosition(-41.7212, 146.399, -1099.62)
  677.    char_granny:setPosition(-3,145,-1100)
  678.    char_granny:setOrientation(Degree(0),Degree(100),Degree(0))
  679. end
  680. -----------------------------------------------------------------------
  681.  
  682. -----------------------------------------------------------------------
  683. --
  684. -----------------------------------------------------------------------
  685. function CrocMask:startShipWreckSequence()
  686.    -- unmute trigger so Assil runs away from crocodile
  687.    EventTriggerMgr:setEventTriggerMuted("trig_ship_wreck_croc",false)
  688.    CrocMask:setUnderwaterSpeed()
  689. end
  690. -----------------------------------------------------------------------
  691.  
  692. -----------------------------------------------------------------------
  693. --
  694. -----------------------------------------------------------------------
  695. function CrocMask:endShipWreckSequence()
  696.    CharacterControllerMgr:setWalkAnimation("char_assil", "all_walk")
  697.    CharacterControllerMgr:setWalkSpeed("char_assil", 126)
  698.    CharacterControllerMgr:setRunAnimation("char_assil", "all_run")
  699.    CharacterControllerMgr:setRunSpeed("char_assil", 400)
  700.    api:detachFromBoneSafely("char_assil","animobj_nile_crystal_bowl")
  701.    LocationMgr:activateLocation("desert_beach")
  702.    CameraMgr:activateCamera("cam_desert_beach")
  703.    char_assil:setPosition(1300, -110, 1150)
  704.    char_assil:setYaw(Degree(-145))
  705.    self.quest:setDone("CrocodileDefeated")
  706.    Inventory:addItemSafely("item_croc_teeth")
  707.    char_nubian:setConfiguration("CrocMask_char_nubian_desert_beach")
  708.    animobj_bazar_ferry:setConfiguration("cfg_animobj_bazar_ferry_desert_beach")
  709. --   char_tailor:setConfiguration("CrocMask_PirateStuffTaken_char_tailor")
  710. end
  711. -----------------------------------------------------------------------
  712.  
  713. -----------------------------------------------------------------------
  714. -- lua slot called when a trigger associated with this quest
  715. -- has fired its event enhanced with the face the trigger was entered
  716. -----------------------------------------------------------------------
  717. function CrocMask:onTriggerFaceEvent(p_Trigger,p_FrontFace)
  718.    _LogInfo("CrocMask:onTriggerFaceEvent", p_Trigger)
  719.  
  720.    if p_Trigger == "trig_desert_crossing_no_way" then
  721.       if p_FrontFace then
  722.          if not self.quest:isDone("CompassFixed") then
  723.             if not self.quest:isDone("NoCompassMessage") then
  724.                self.quest:setDone("NoCompassMessage")
  725.                CharacterControllerMgr:say("char_assil", "ID_NO_COMPASS")
  726.             end
  727.          else
  728.             if not self.quest:isDone("CompassHelpsMessage") then
  729.                self.quest:setDone("CompassHelpsMessage")
  730.                CharacterControllerMgr:say("char_assil", "ID_COMPASS_HELPS")
  731.             end
  732.          end
  733.       end
  734.    end
  735.  
  736. end
  737. -----------------------------------------------------------------------
  738.  
  739. -----------------------------------------------------------------------
  740. -- lua slot called when a trigger associated with this quest
  741. -- has fired its event
  742. -----------------------------------------------------------------------
  743. function CrocMask:onTriggerEvent(p_Trigger)
  744.    _LogInfo("CrocMask:onTriggerEvent", p_Trigger)
  745. end
  746. -----------------------------------------------------------------------
  747.  
  748. -----------------------------------------------------------------------
  749. -- sets the interactor configurations for the iactors associated with
  750. -- this quest according to the quest's current state
  751. -----------------------------------------------------------------------
  752. function CrocMask:initConfigurations()
  753.    _LogInfo("CrocMask:initConfigurations", "")
  754.    local questState = self.quest:getState()
  755.    -- default case, quest just initialized
  756.    if questState == "Initialized" then
  757.       for key, value in ipairs(self.iactors) do
  758.           local configName = self.name .. "_" .. value
  759.           _LogInfo("setting config: '" .. value .. "' to '" .. configName .. "'","")
  760.           if InteractorConfigurationMgr:isConfigurationPresent(configName) then
  761.              local iactor = GameEntityMgr:getInteractor(value)
  762.              iactor:setConfiguration(configName, true)
  763.           else
  764.              _LogWarning("lua", "No such config: " .. configName)
  765.           end
  766.       end
  767.    else -- any other state
  768.       for key, value in ipairs(self.iactors) do
  769.           local iactor = GameEntityMgr:getInteractor(value)
  770.           -- config name defaults to "QuestName_State_objname"
  771.           local configName = self.name .. "_" .. questState .. "_" .. value
  772.           -- is there a special configuration available for this state?
  773.           --_LogInfo("lua", "checking for config to exist: " .. configName)
  774.           if (InteractorConfigurationMgr:isConfigurationPresent(configName) ~= true) then
  775.              -- no, use the default for this quest
  776.              configName = self.name .. "_" .. value
  777.           end
  778.           if (InteractorConfigurationMgr:isConfigurationPresent(configName)) then
  779.              --_LogInfo("setting config: '" .. value .. "' to '" .. configName .. "'","")
  780.              iactor:setConfiguration(configName, true)
  781.           end
  782.       end
  783.    end
  784. end
  785. -----------------------------------------------------------------------
  786.  
  787. -----------------------------------------------------------------------
  788. -- updates the configs for the associated interactors based
  789. -- on the little tasks already completed within this quest
  790. -----------------------------------------------------------------------
  791. function CrocMask:updateFromCheckList(p_Task, p_Done)
  792.    _LogInfo("CrocMask:updateFromCheckList", "")
  793.  
  794.    if p_Task == "FerryTakenToDesert" then
  795.       if p_Done then
  796.          --LocationMgr:changeCameraAndOrLocation("desert_beach","cam_desert_beach",PinaVector3(677,15, 1457),
  797.          --                                      Rotate(Degree(0),Degree(180),Degree(0)),"default")
  798.          --animobj_bazar_ferry:setConfiguration("cfg_animobj_bazar_ferry_desert_beach")
  799.          --char_nubian:setConfiguration("CrocMask_char_nubian_desert_beach")
  800.      --api:cutscene_("CrocMask_ferry_to_desert_beach",0)
  801.       end
  802.    end
  803.  
  804.    if p_Task == "FerryTakenToBazar" then
  805.       if p_Done then
  806.          --LocationMgr:changeCameraAndOrLocation("bazar","cam_bazar_nile",PinaVector3(13726, -1719, 592),
  807.          --             Rotate(Degree(0),Degree(0),Degree(0)),"nile")
  808.          --animobj_bazar_ferry:setConfiguration("cfg_animobj_bazar_ferry")
  809.          --char_nubian:setConfiguration("CrocMask_char_nubian_bazar")
  810.      --api:cutscene_("CrocMask_ferry_to_bazar",0)
  811.       end
  812.    end
  813.  
  814.    if p_Task == "TreasurerHandTaken" then
  815.       if p_Done then
  816.      Inventory:addItemSafely("item_hand_treasurer")
  817.      --iactor_ship_wreck_dead_treasurer_arm:setIgnored(true)
  818.      iactor_ship_wreck_dead_treasurer:setIgnored(true)
  819.      animobj_ship_wreck_arm_treasurer:setIgnored(true)
  820.       else
  821.      Inventory:removeItemSafely("item_hand_treasurer")
  822.      --iactor_ship_wreck_dead_treasurer_arm:setIgnored(false)
  823.      iactor_ship_wreck_dead_treasurer:setIgnored(false)
  824.      animobj_ship_wreck_arm_treasurer:setIgnored(false)
  825.       end
  826.    end
  827.  
  828.    if p_Task == "KeyPirateChestTaken" then
  829.       if p_Done then
  830.          Inventory:addItemSafely("item_key_pirate_chest")
  831.          --iactor_ship_wreck_key_pirate_chest:setIgnored(true)
  832.           Inventory:removeItemSafely("item_hand_treasurer")
  833.           --sound("pirate_hand_open")
  834.           sound("key_pickup")
  835.       else
  836.          Inventory:removeItemSafely("item_key_pirate_chest")
  837.          --iactor_ship_wreck_key_pirate_chest:setIgnored(false)
  838.       end
  839.    end
  840.  
  841.    if p_Task == "StoneArmTaken" then
  842.       if p_Done then
  843.          Inventory:addItemSafely("item_stone_arm")
  844.       else
  845.          Inventory:removeItemSafely("item_stone_arm")
  846.       end
  847.    end
  848.  
  849.    if p_Task == "PirateChestOpened" then
  850.       if p_Done then
  851.          iactor_ship_wreck_pirate_stuff:setIgnored(false)
  852.          Inventory:removeItemSafely("item_key_pirate_chest")
  853.       else
  854.          iactor_ship_wreck_pirate_stuff:setIgnored(true)
  855.          Inventory:addItemSafely("item_key_pirate_chest")
  856.       end
  857.    end
  858.  
  859.    if p_Task == "PirateStuffTaken" then
  860.       if p_Done then
  861.          Inventory:addItemSafely("item_pirate_flag")
  862.          Inventory:addItemSafely("item_compass_broken")
  863.          Inventory:addItemSafely("item_treasure_dirty")
  864.          Inventory:addItemSafely("item_shirt_hawai")
  865.          iactor_ship_wreck_pirate_stuff:setIgnored(true)
  866.       end
  867.    end
  868.  
  869.    if p_Task == "StoneArmWrapped" then
  870.       if p_Done then
  871.          Inventory:removeItemSafely("item_shirt_hawai")
  872.          Inventory:removeItemSafely("item_stone_arm")
  873.          Inventory:addItemSafely("item_stone_arm_shirt")
  874.       end
  875.    end
  876.  
  877.    if p_Task == "SkullTaken" then
  878.       if p_Done then
  879.          Inventory:addItemSafely("item_skull")
  880.       else
  881.          Inventory:removeItemSafely("item_skull")
  882.       end
  883.    end
  884.  
  885.    if p_Task == "ScissorsGiven" then
  886.       if p_Done then
  887.          Inventory:addItemSafely("item_scissors_blunt")
  888.          -- ToDo: sharpen scissors
  889.          Ankh:addToDoEntry("ID_TODO_04")
  890.       else
  891.          Inventory:removeItemSafely("item_scissors_blunt")
  892.       end
  893.    end
  894.  
  895.    if p_Task == "ScissorsSharpened" then
  896.       if p_Done then
  897.          Inventory:removeItemSafely("item_scissors_blunt")
  898.          Inventory:addItemSafely("item_scissors_sharp")
  899.       else
  900.          Inventory:removeItemSafely("item_scissors_sharp")
  901.          Inventory:addItemSafely("item_scissors_blunt")
  902.       end
  903.    end
  904.  
  905.    if p_Task == "NeedleGiven" then
  906.       if p_Done then
  907.          Inventory:removeItemSafely("item_scissors_sharp")
  908.          Inventory:addItemSafely("item_compass_needle")
  909.          -- ToDo remove: sharpen scissors
  910.          Ankh:removeToDoEntry("ID_TODO_04")
  911.       else
  912.          Inventory:removeItemSafely("item_compass_needle")
  913.          Inventory:addItemSafely("item_scissors_sharp")
  914.       end
  915.    end
  916.  
  917.    if p_Task == "CompassFixed" then
  918.       if p_Done then
  919.          Inventory:addItemSafely("item_compass_fixed")
  920.          Inventory:removeItemSafely("item_compass_broken")
  921.          Inventory:removeItemSafely("item_compass_needle")
  922.          iactor_desert_beach_to_desert_crossing:setConfiguration("CrocMask_CompassFixed_iactor_desert_beach_to_desert_crossing")
  923.          iactor_desert_crossing_to_desert_rock:setIgnored(false)
  924.          iactor_desert_crossing_to_desert_plain:setIgnored(false)
  925.       else
  926.          Inventory:removeItemSafely("item_compass_fixed")
  927.          Inventory:addItemSafely("item_compass_broken")
  928.          Inventory:addItemSafely("item_compass_needle")
  929.          iactor_desert_beach_to_desert_crossing:setConfiguration("cfg_iactor_desert_beach_to_desert_crossing")
  930.          iactor_desert_crossing_to_desert_rock:setIgnored(true)
  931.          iactor_desert_crossing_to_desert_plain:setIgnored(true)
  932.       end
  933.    end
  934.  
  935.    if p_Task == "CrocPurseTaken" then
  936.       if p_Done then
  937.          api:detachFromBoneSafely("char_granny","item_croc_purse")
  938.          Inventory:addItemSafely("item_croc_purse")
  939.       else
  940.          Inventory:removeItemSafely("item_croc_purse")
  941.          item_croc_purse:setConfiguration("cfg_item_croc_purse")
  942.          api:attachToBoneSafely("char_granny","item_croc_purse","RigLArmPalm")
  943.       end
  944.    end
  945.  
  946. end
  947. -----------------------------------------------------------------------
  948.  
  949. -----------------------------------------------------------------------
  950. -- sets the speed when assil is under water
  951. -----------------------------------------------------------------------
  952. function CrocMask:setUnderwaterSpeed()
  953.  
  954.    CharacterControllerMgr:setWalkAnimation("char_assil", "assil_walk_underwater")
  955.    CharacterControllerMgr:setWalkSpeed("char_assil", 60)
  956.    CharacterControllerMgr:setRunAnimation("char_assil", "assil_walk_underwater")
  957.    CharacterControllerMgr:setRunSpeed("char_assil", 60)
  958.  
  959. end
  960. -----------------------------------------------------------------------
  961.  
  962. -----------------------------------------------------------------------
  963. -- if Assil comes to close to the croc he runs away
  964. -----------------------------------------------------------------------
  965. function CrocMask:CrocSnapsAtAssil()
  966.  
  967.    char_crocodile:blendToPlayOnceAndBack("crocodile_snap")
  968.    char_assil:setYaw(Degree(0))
  969.    --CharacterControllerMgr:setRunSpeed("char_assil", 3300)
  970.    CharacterControllerMgr:run("char_assil", PinaVector3(0,294,424))
  971.    --TimedEventMgr:createTimedEvent("CrocMask:setUnderwaterSpeed()", 1.5)
  972.    MouseIface:blockInput(2.5)
  973.    sound("croc_roar")
  974. end
  975. -----------------------------------------------------------------------
  976.  
  977.