home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2006 March / Gamestar_82_2006-03_dvd.iso / Dema / ankh_demo_en.exe / media / lua / AnkhQuest_Global.lua < prev    next >
Encoding:
Text File  |  2005-11-24  |  62.6 KB  |  1,558 lines

  1. -----------------------------------------------------------------------
  2. -- the table where all the functions/methods go to
  3. -----------------------------------------------------------------------
  4. Global = {
  5.    quest,
  6.    name,
  7.    locations,
  8.    iactors,
  9.    inventory,
  10.    triggers,
  11.    conversations,
  12.    cutscenes,
  13.    checklist
  14. }
  15. -----------------------------------------------------------------------
  16.  
  17. -----------------------------------------------------------------------
  18. -- init function
  19. -----------------------------------------------------------------------
  20. function Global:init()
  21.    local questName = "Global"
  22.    -- the quest object stores the C++ object pointer (Quest object)
  23.    self.quest = QuestMgr:createQuest(questName)
  24.    self.name  = questName
  25.    
  26.    -- the locations associated with this quest
  27.    self.locations = {
  28.       "bazar",
  29.       "giza",
  30.       "palace_garden",
  31.       "sphinx_inside",
  32.       "sphinx_outside",
  33.       "palace_gate",
  34.       "oasis",
  35.  
  36.       "desert_plain",
  37.       "desert_rock",
  38.       "desert_crossing"
  39.    }
  40.    -- the interactor objects associated with this quest
  41.    self.iactors = {
  42.       "char_jackal",
  43.       "char_bigcop",
  44.       "char_bulbul",
  45.       "char_burgerman",
  46.       "char_blackeye",
  47.       "char_dinar",
  48. --      "char_egyptian",
  49.       "char_father",
  50.       "char_girlie",
  51.       "char_granny",
  52.       "char_nubian",
  53.       "char_prisoner",
  54.       "char_raseltin",
  55.       "char_far_el_matu",
  56.       "char_mut_el_tebtyns",
  57.       "char_slavedriver",
  58.       "char_slave",
  59.       "char_seeker",
  60.       "char_smallcop",
  61.       "char_pharao",
  62.       "char_tailor",
  63.       "char_tarok",
  64.       "char_thara",
  65.       "char_assil",
  66.       "char_bakshish",
  67.       "char_volcano",
  68.       "char_wineman",
  69.       "char_gordon",
  70.       "char_osiris",
  71.       "char_badawi",
  72.       "char_scarabking",
  73.       "char_schmuel",
  74.       "char_ephraim",
  75.       "char_shalom",
  76.       "char_caravanleader",
  77.       "char_genie",
  78.       
  79.       "char_egyptian_1",
  80.       "char_egyptian_2",
  81.  
  82.       "item_silver_coin",
  83.  
  84.       "animobj_iactor_key",
  85.       "item_flute",
  86.  
  87.       "item_treasure_map",
  88.       "item_cloak_dirty",
  89.       "iactor_home_hanging_basket",
  90.       "item_cloak_noble",
  91.       "item_brush_broken",
  92.       "item_treasure_dirty",
  93.       "item_camel_hair",
  94.       "item_skull",
  95.       "item_croc_purse",
  96.       "item_croc_teeth",
  97.       "item_skull",
  98.       "item_stone_arm",
  99.       "char_crocodile",
  100.       "item_shirt_hawai",
  101.       "item_pirate_flag",
  102.       "item_hanger",
  103.       "iactor_palace_prison_cell_to_palace_prison_tunnel",
  104.       "iactor_palace_gate_entrance_to_palace_courtyard",
  105.       "animobj_bazar_water_plane",
  106.       "iactor_giza_camel_o_wash",
  107.  
  108.       "iactor_palace_gate_street_to_palace_gate_entrance",
  109.  
  110.       "animobj_palace_garden_water_plane",
  111.       "animobj_palace_garden_crank"
  112.    }
  113.  
  114.    -- the conversations associated with this quest
  115.    self.conversations = {
  116.       "Standard_dinar_noble_shop",
  117.       "SunOfCairo_bakshish_quest",
  118.       "Standard_slave",
  119.       "Standard_slavedriver",
  120.       "Final_pharaoh",
  121.       "Final_bakshish"
  122.    }
  123.    
  124.    -- the cutscenes associated with this quest
  125.    self.cutscenes = {
  126.    }
  127.  
  128.    -- the checklist of little tasks associated with this quest
  129.    self.checklist = {
  130.       "SpokenToDinarOnce",
  131.       "SeekerProblemDiscussed",
  132.       "SlaveToldStory",
  133.  
  134.       "GlobalRaseltinLoopRunning",
  135.       "GlobalRaseltinLoopBlocked",
  136.       "GardenGordonLoopRunning",
  137.       "GardenGordonLoopBlocked",
  138.  
  139.       -- TL
  140.       "Egyptian1WalkActive",
  141.       "Egyptian1WalkToGirliePending",
  142.       "Egyptian1WalkOffPending",
  143.       "Egyptian2WalkActive",
  144.       "Egyptian2WalkToTailorPending",
  145.       "Egyptian2WalkOffPending",
  146.       "GrannyWalkActive",
  147.       "PalaceGateIntroduced",
  148.  
  149.       -- and ultimately
  150.       "QuestSolved"
  151.    }
  152.  
  153.    ------------------------- Global Assil/Thara close trigger -------------------
  154.  
  155.    local trig_args = ProximityTriggerArgs("myArgs")
  156.    trig_args.entity1  = "char_assil"
  157.    trig_args.entity2  = "char_thara"
  158.    trig_args.distance = 75
  159.    trig_args.lua_func = "Global:onAssilCloseToThara"
  160.    trig_args.single_shot = false
  161.    EventTriggerMgr:createProximityEventTrigger("trig_assil_thara", trig_args)
  162.    --EventTriggerMgr:subscribeEventTriggerEvent("trig_assil_thara", "EventProximityAreaEntered",
  163.     --                      "Global:onAssi
  164.  
  165.    -- create a proximity trigger for the slavedriver/slave conversation
  166.    local trig_args = ProximityTriggerArgs("myArgs")
  167.    trig_args.entity1 = "char_assil"
  168.    trig_args.entity2 = "char_slave"
  169.    trig_args.distance = 1000
  170.    trig_args.lua_func = "Global:startSlaveConversationLoop"
  171.    trig_args.single_shot = false
  172.    EventTriggerMgr:createProximityEventTrigger("trig_bazar_slave_loop", trig_args)
  173.    EventTriggerMgr:subscribeEventTriggerEvent("trig_bazar_slave_loop", "EventProximityAreaLeft", 
  174.                           "Global:stopSlaveConversationLoop", false)
  175.    self.quest:addTrigger("trig_bazar_slave_loop", "bazar")
  176.  
  177.    -- create a proximity trigger for gordon
  178.    local trig_args = ProximityTriggerArgs("myArgs")
  179.    trig_args.entity1 = "char_assil"
  180.    trig_args.entity2 = "char_gordon"
  181.    trig_args.distance = 1000
  182.    trig_args.lua_func = "Global:startGordonConversationLoop"
  183.    trig_args.single_shot = false
  184.    EventTriggerMgr:createProximityEventTrigger("trig_palace_garden_gordon_loop", trig_args)
  185.    EventTriggerMgr:subscribeEventTriggerEvent("trig_palace_garden_gordon_loop", "EventProximityAreaLeft", 
  186.                           "Global:stopGordonConversationLoop", false)
  187.    self.quest:addTrigger("trig_palace_garden_gordon_loop", "palace_garden")
  188.    EventTriggerMgr:setEventTriggerMuted("trig_palace_garden_gordon_loop",true)
  189.  
  190.    ----------------------- Egyptian Walk -----------------------
  191.    
  192.    local trig_args = ProximityTriggerArgs("char_assil")
  193.    trig_args.entity1 = "char_assil"
  194.    trig_args.entity2 = "char_egyptian_1"
  195.    trig_args.distance = 550
  196.    trig_args.lua_func = "Global:onAssilGetsCloseToEgyptian1"
  197.    trig_args.single_shot = false
  198.    EventTriggerMgr:createProximityEventTrigger("trig_bazar_peasant_a_prox", trig_args)
  199.    --EventTriggerMgr:subscribeEventTriggerEvent("trig_bazar_peasant_a_prox", "EventProximityAreaLeft", 
  200.     --                      "Global:startEgyptian1WalkLoop", false)
  201.    self.quest:addTrigger("trig_bazar_peasant_a_prox", "bazar")
  202.  
  203.    local trig_args = ProximityTriggerArgs("char_assil")
  204.    trig_args.entity1 = "char_assil"
  205.    trig_args.entity2 = "char_egyptian_2"
  206.    trig_args.distance = 600
  207.    trig_args.lua_func = "Global:onAssilGetsCloseToEgyptian2"
  208.    trig_args.single_shot = false
  209.    EventTriggerMgr:createProximityEventTrigger("trig_bazar_peasant_b_prox", trig_args)
  210.    EventTriggerMgr:subscribeEventTriggerEvent("trig_bazar_peasant_b_prox", "EventProximityAreaLeft", 
  211.                           "Global:startEgyptian2WalkLoop", false)
  212.    self.quest:addTrigger("trig_bazar_peasant_b_prox", "bazar")
  213.  
  214.    ----------------------- /Egyptian Walk -----------------------
  215.  
  216.    -- associate the locations with the quest
  217.    for key, value in ipairs(self.locations) do
  218.       self.quest:addLocation(value)
  219.    end
  220.    -- associate the interactors with the quest
  221.    for key, value in ipairs(self.iactors) do
  222.       self.quest:addInteractor(value)
  223.    end
  224.    -- associate the conversations with the quest
  225.    for key, value in ipairs(self.conversations) do
  226.       self.quest:addConversation(value)
  227.    end
  228.    -- associate the cutscenes with the quest
  229.    for key, value in ipairs(self.cutscenes) do
  230.       self.quest:addCutscene(value)
  231.    end
  232.    -- associate the list items with the quest
  233.    for key, value in ipairs(self.checklist) do
  234.       self.quest:addTaskToCheckList(value)
  235.    end
  236.  
  237.    -- subscribe the lua functions to call
  238.    self.quest:subscribeLocationEntered(self.name .. ":onLocationEntered")
  239.    self.quest:subscribeLocationLeft(self.name .. ":onLocationLeft")
  240.    self.quest:subscribeInteractorEvent(self.name .. ":onInteractorEvent")
  241.    self.quest:subscribeInteractorEntered(self.name .. ":onMouseEnteredInteractor")
  242.    self.quest:subscribeInteractorLeft(self.name .. ":onMouseLeftInteractor")
  243.    self.quest:subscribeLocationFadingInFinished(self.name .. ":onLocationFadingInFinished")
  244.    self.quest:subscribeConversationEvent(self.name .. ":onConversationEvent")
  245.    self.quest:subscribeConversationFinished(self.name .. ":onConversationFinished")
  246.    self.quest:subscribeCutsceneFinished(self.name .. ":onCutsceneFinished")
  247.    self.quest:subscribeTriggerEvent(self.name .. ":onTriggerEvent")   
  248.    self.quest:subscribeTriggerFaceEvent(self.name .. ":onTriggerFaceEvent")   
  249.    self.quest:subscribeCheckListChanged(self.name .. ":updateFromCheckList")   
  250.  
  251.    -- set the initial quest state
  252.    self.quest:setState("Initialized")
  253.  
  254.    -- TL
  255.    --CameraMgr:subscribeEvent("EventCameraActivated","Global:onCameraChanged",false)
  256. end
  257. -----------------------------------------------------------------------
  258.  
  259. --------------------------------------------------------------------------
  260. -- sets the quest active and updates the iactor configurations
  261. --------------------------------------------------------------------------
  262. function Global:activate()
  263.    _LogInfo(self.name .. ":activate", self.name)
  264.  
  265.    self:initConfigurations()
  266.    self.quest:setActive(true)
  267.  
  268. end
  269. -----------------------------------------------------------------------
  270.  
  271. -----------------------------------------------------------------------
  272. -- sets the quest inactive and resets the iactor configurations
  273. -----------------------------------------------------------------------
  274. function Global:deactivate()
  275.    _LogInfo("Global:deactivate", "called")
  276.    self.quest:setActive(false)
  277.  
  278.    -- reset the configurations for the interactor objects to default
  279.    for key, value in ipairs(self.iactors) do
  280.       local iactor = GameEntityMgr:getInteractor(value)
  281.       iactor:initFromDefaultConfiguration()
  282.    end
  283. end
  284. -----------------------------------------------------------------------
  285.  
  286. -----------------------------------------------------------------------
  287. -- lua slot called when an action was performed on an interactor
  288. -- associated with this quest
  289. -----------------------------------------------------------------------
  290. function Global:onInteractorEvent(p_Interactor, p_ActionID, p_InteractedInteractor)
  291.    _LogInfo("Global:onInteractorEvent", p_Interactor)
  292.  
  293.    local questState = self.quest:getState()
  294.    local iactor     = GameEntityMgr:getInteractor(p_Interactor)
  295.    local location
  296.  
  297.    if p_Interactor == "animobj_palace_garden_crank" and p_ActionID == Interactor.LookAt then
  298.       if GameEntityMgr:getMainCharacter() == "char_thara" then
  299.      player("CFG_ANIMOBJ_PALACE_GARDEN_CRANK_LOOKAT_THARA")
  300.       else
  301.      player("CFG_ANIMOBJ_PALACE_GARDEN_CRANK_LOOKAT")
  302.       end
  303.    end
  304.  
  305.    if p_Interactor == "animobj_palace_garden_water_plane" and p_ActionID == Interactor.LookAt then
  306.       --player:say("CFG_ANIMOBJ_PALACE_GARDEN_WATER_PLANE_LOOKAT")
  307.       if GameEntityMgr:getMainCharacter() == "char_thara" then
  308.      player:say("CFG_ANIMOBJ_PALACE_GARDEN_WATER_PLANE_LOOKAT_THARA")
  309.       else
  310.      player:say("CFG_ANIMOBJ_PALACE_GARDEN_WATER_PLANE_LOOKAT")
  311.       end
  312.    end
  313.  
  314.    if p_Interactor == "item_flute" and p_ActionID == Interactor.LookAt then
  315.       if GameEntityMgr:getMainCharacter() == "char_thara" then
  316.      player:say("CFG_ITEM_FLUTE_LOOKAT_THARA")
  317.       else
  318.      player:say("CFG_ITEM_FLUTE_LOOKAT")
  319.       end
  320.    end
  321.  
  322.    if p_Interactor == "iactor_palace_gate_street_to_palace_gate_entrance" and 
  323.       p_ActionID == Interactor.Leave then
  324.       if not self.quest:isDone("PalaceGateIntroduced") then
  325.      api:cutscene("palace_gate_intro")
  326.      self.quest:setDone("PalaceGateIntroduced")
  327.       end
  328.    end
  329.  
  330.    if (p_Interactor == "char_assil" or p_Interactor == "char_thara") and 
  331.       p_ActionID == Interactor.Use then
  332.       if Ankh:isCharSwitchVisible() then
  333.      Ankh:toggleMainChar()
  334.       end
  335.    end
  336.  
  337.    if p_Interactor == "char_assil" then
  338.       if string.len(p_InteractedInteractor) > 0 then
  339.      -- check if char switch is visible
  340.      if Ankh:isCharSwitchVisible() then
  341.         -- give item to other char
  342.         g_InteractionHandled = true
  343.         char_thara:removeItemSafely(p_InteractedInteractor)
  344.         char_assil:addItemSafely(p_InteractedInteractor)
  345.         char_assil:say("ID_SWAP_ITEM_ASSIL")
  346.      end
  347.       end
  348.    end
  349.  
  350.    if p_Interactor == "char_thara" then
  351.       if string.len(p_InteractedInteractor) > 0 then
  352.      if Ankh:isCharSwitchVisible() then
  353.         -- give item to other char
  354.         g_InteractionHandled = true
  355.         char_assil:removeItemSafely(p_InteractedInteractor)
  356.         char_thara:addItemSafely(p_InteractedInteractor)
  357.         char_thara:say("ID_SWAP_ITEM_THARA")
  358.      end
  359.       end
  360.    end
  361.  
  362.    if p_Interactor == "item_treasure_map" and p_ActionID == Interactor.LookAt then
  363.       QuestHelper:showTreasureMap()
  364.    end
  365.  
  366.    if p_Interactor == "char_volcano" and p_ActionID == Interactor.TalkTo then
  367.       if Sphinx.quest:isActive() then
  368.          api:conversation("Sphinx_volcano_hint")
  369.       elseif SunOfCairo.quest:isActive() then
  370.          api:conversation("SunOfCairo_volcano_hint")
  371.       elseif Embassy.quest:isActive() or Bulbul.quest:isActive() then
  372.          api:conversation("Embassy_volcano_hint")
  373.       elseif EnterPalace.quest:isActive() then
  374.          api:conversation("EnterPalace_volcano_welcome")
  375.       end
  376.    end
  377.  
  378.    if p_Interactor == "char_dinar" and p_ActionID == Interactor.TalkTo then
  379.       if not Embassy.quest:isActive() and not SunOfCairo.quest:isActive() then
  380.          if TriggerControl.quest:isDone("DinarInShadyShop") then
  381.             if not self.quest:isDone("SpokenToDinarOnce") then
  382.                self.quest:setDone("SpokenToDinarOnce")
  383.                api:conversation("Standard_dinar_shady_shop")
  384.             else
  385.                api:conversation("Standard_dinar_shady_shop_followup")
  386.             end
  387.          else
  388.             api:conversation("Standard_dinar_noble_shop")
  389.          end
  390.       end
  391.    end
  392.  
  393.    if p_Interactor == "char_seeker" and p_ActionID == Interactor.TalkTo then
  394.       if Sphinx.quest:isActive() then
  395.          api:conversation("SunOfCairo_seeker_send_out_hint")
  396.       elseif not SunOfCairo.quest:isActive() then
  397.          if not self.quest:isDone("SeekerProblemDiscussed") then
  398.             self.quest:setDone("SeekerProblemDiscussed")
  399.             api:conversation("Standard_seeker")
  400.          else
  401.             api:conversation("Standard_seeker_hint")
  402.          end
  403.       end
  404.    end
  405.  
  406.    if ((p_Interactor == "char_bigcop" or p_Interactor == "char_smallcop") and
  407.        p_ActionID == Interactor.TalkTo) or
  408.       (p_Interactor == "iactor_palace_gate_entrance_to_palace_courtyard" and
  409.        p_ActionID == Interactor.Leave) then
  410.       if EnterPalace.quest:isDone("QuestSolved") and not SunOfCairo.quest:isActive() and
  411.          not Sphinx.quest:isActive() then
  412.          api:conversation("SunOfCairo_guards_deny")
  413.       elseif (SunOfCairo.quest:isActive() and SunOfCairo.quest:isDone("KeyReceived")) or
  414.               Sphinx.quest:isActive() then
  415.          api:conversation("Sphinx_guards_deny")
  416.       end
  417.    end
  418.  
  419.    if p_Interactor == "char_wineman" and p_ActionID == Interactor.TalkTo then
  420.       if not SunOfCairo.quest:isActive() then
  421.          api:conversation("SunOfCairo_wineman_quest")
  422.       end      
  423.    end
  424.  
  425.    if p_Interactor == "char_bakshish" and p_ActionID == Interactor.TalkTo then
  426.       if not SunOfCairo.quest:isActive() and not Sphinx.quest:isActive() then
  427.          api:conversation("SunOfCairo_bakshish_quest")
  428.       end      
  429.    end
  430.  
  431.    if p_Interactor == "char_slave" and p_ActionID == Interactor.TalkTo then
  432.       if Sphinx.quest:isActive() then
  433.          api:conversation("SunOfCairo_slave_oasis_done")
  434.       elseif not SunOfCairo.quest:isActive() then
  435.          api:conversation("Standard_slave")
  436.       end      
  437.    end
  438.  
  439.    if p_Interactor == "char_slavedriver" and p_ActionID == Interactor.TalkTo then
  440.       if not SunOfCairo.quest:isActive() then
  441.          api:conversation("Standard_slavedriver")
  442.       end      
  443.    end
  444.  
  445.    if p_Interactor == "char_girlie" and p_ActionID == Interactor.TalkTo then
  446.       if not QuestMgr:isQuestActive("Oasis") then
  447.          api:conversation("Oasis_girlie_standard")
  448.       end
  449.    end
  450.  
  451.    if (p_Interactor == "char_raseltin" or
  452.        p_Interactor == "char_far_el_matu" or
  453.        p_Interactor == "char_mut_el_tebtyns") and p_ActionID == Interactor.TalkTo then
  454.       if not QuestMgr:isQuestActive("Oasis") then
  455.          api:conversation("Oasis_raseltin_done")
  456.       end
  457.    end
  458.  
  459.    if p_Interactor == "char_schmuel" or
  460.       p_Interactor == "char_ephraim" or
  461.       p_Interactor == "char_shalom" then
  462.       if not QuestMgr:isQuestActive("Oasis") and not QuestMgr:isQuestActive("SunOfCairo") then
  463.          api:conversation("Oasis_schmuel_done")
  464.       end
  465.    end
  466.  
  467.    if p_Interactor == "animobj_iactor_key" and p_ActionID == Interactor.Pickup then
  468.       if not SunOfCairo.quest:isActive() then
  469.            char_assil:say("ID_SUNOFCAIRO_CANNOT_TAKE_BUNCH_OF_KEYS")
  470.       end
  471.    end
  472.  
  473.    if p_InteractedInteractor == "item_silver_coin" then
  474.       if string.find(p_Interactor, "char_") then 
  475.      if p_Interactor == "char_thara" then
  476.         -- nothing to do
  477.          elseif not (p_Interactor == "char_nubian" or p_Interactor == "char_bulbul" or
  478.             (p_Interactor == "char_girlie" and Oasis.quest:isDone("TreasureMapHint") and not Oasis.quest:isDone("TreasureMapTaken")) or
  479.             (p_Interactor == "char_wineman" and SunOfCairo.quest:isActive())) then
  480.             g_InteractionHandled = true
  481.             api:conversation("Standard_assil_keep_coin")
  482.          end
  483.       end
  484.    end
  485.  
  486.    if (p_Interactor == "char_wineman" and p_InteractedInteractor == "item_bottle_empty") then
  487.       if not SunOfCairo.quest:isDone("BananaGiven") then
  488.          g_InteractionHandled = true
  489.          Inventory:removeItemSafely("item_bottle_empty")
  490.          Inventory:addItemSafely("item_silver_coin")
  491.          api:conversation("SunOfCairo_wineman_give_refund")
  492.       end
  493.    end
  494.  
  495.    -- hints for not allowed combinations of items
  496.    if (p_Interactor == "iactor_home_hanging_basket" and p_InteractedInteractor == "item_cloak_dirty") then
  497.       CharacterControllerMgr:say("char_assil", "ID_FEEDBACK_CLOTH_TOO_SHORT")
  498.       g_InteractionHandled = true
  499.  
  500.    elseif (p_Interactor == "iactor_home_hanging_basket" and p_InteractedInteractor == "item_cloak_noble") then
  501.       CharacterControllerMgr:say("char_assil", "ID_FEEDBACK_CLOTH_TOO_SHORT")
  502.       g_InteractionHandled = true
  503.       
  504.    elseif (p_Interactor == "item_brush_broken" and p_InteractedInteractor == "item_treasure_dirty") or
  505.           (p_Interactor == "item_treasure_dirty" and p_InteractedInteractor == "item_brush_broken") then
  506.       CharacterControllerMgr:say("char_assil", "ID_FEEDBACK_BRUSH_NEEDS_HAIR")
  507.       g_InteractionHandled = true
  508.       
  509.    elseif (p_Interactor == "item_camel_hair" and p_InteractedInteractor == "item_treasure_dirty") or
  510.           (p_Interactor == "item_treasure_dirty" and p_InteractedInteractor == "item_camel_hair") then
  511.       CharacterControllerMgr:say("char_assil", "ID_FEEDBACK_HAIR_NEEDS_BRUSH")
  512.       g_InteractionHandled = true
  513.  
  514.    elseif (p_Interactor == "item_croc_purse" and p_InteractedInteractor == "item_skull") or
  515.           (p_Interactor == "item_skull" and p_InteractedInteractor == "item_croc_purse") then
  516.       CharacterControllerMgr:say("char_assil", "ID_COMBINE_MASK")
  517.       g_InteractionHandled = true
  518.  
  519.    elseif (p_Interactor == "item_croc_purse" and p_InteractedInteractor == "item_croc_teeth") or
  520.           (p_Interactor == "item_croc_teeth" and p_InteractedInteractor == "item_croc_purse") then
  521.       CharacterControllerMgr:say("char_assil", "ID_COMBINE_MASK")
  522.       g_InteractionHandled = true
  523.  
  524.    elseif (p_Interactor == "item_skull" and p_InteractedInteractor == "item_croc_teeth") or
  525.           (p_Interactor == "item_croc_teeth" and p_InteractedInteractor == "item_skull") then
  526.       CharacterControllerMgr:say("char_assil", "ID_COMBINE_MASK")
  527.       g_InteractionHandled = true
  528.    --elseif (p_Interactor == "item_stone_arm" and p_InteractedInteractor == "char_crocodile") or
  529.    --       (p_Interactor == "char_crocodile" and p_InteractedInteractor == "item_stone_arm") then
  530.    --   CharacterControllerMgr:say("char_assil", "ID_FEEDBACK_ARM_HAS_NO_DISGUISE")
  531.  
  532.    elseif (p_Interactor == "item_shirt_hawai" and p_InteractedInteractor == "char_crocodile") or
  533.           (p_Interactor == "char_crocodile" and p_InteractedInteractor == "item_shirt_hawai") then
  534.       CharacterControllerMgr:say("char_assil", "ID_FEEDBACK_SHIRT_ALONE_NOT_EATEN")
  535.       g_InteractionHandled = true
  536.  
  537.    elseif (p_Interactor == "item_stone_arm" and p_InteractedInteractor == "item_pirate_flag") or
  538.           (p_Interactor == "item_pirate_flag" and p_InteractedInteractor == "item_stone_arm") then
  539.       CharacterControllerMgr:say("char_assil", "ID_FEEDBACK_ARM_NEEDS_BETTER_DISGUISE")
  540.       g_InteractionHandled = true
  541.  
  542.    elseif p_Interactor == "iactor_palace_prison_cell_to_palace_prison_tunnel" and p_InteractedInteractor == "item_hanger" then
  543.       CharacterControllerMgr:say("char_assil", "ID_FEEDBACK_HANGER_MUST_BE_MODIFIED")
  544.       g_InteractionHandled = true
  545.  
  546.    elseif p_Interactor == "animobj_bazar_water_plane" and p_InteractedInteractor == "item_treasure_dirty" then
  547.       CharacterControllerMgr:say("char_assil", "ID_FEEDBACK_WATER_DOES_NOT_HELP")
  548.       g_InteractionHandled = true
  549.  
  550.    elseif p_Interactor == "iactor_giza_camel_o_wash" and p_InteractedInteractor == "item_treasure_dirty" then
  551.       CharacterControllerMgr:say("char_assil", "ID_FEEDBACK_THIS_IS_NO_CAMEL")
  552.       g_InteractionHandled = true
  553.  
  554.    elseif (p_Interactor == "char_smallcop" or p_Interactor == "char_bigcop") and
  555.            p_InteractedInteractor == "item_croc_teeth" then
  556.       CharacterControllerMgr:say("char_assil", "ID_FEEDBACK_NOT_SHOCKING_ENOUGH")
  557.       g_InteractionHandled = true
  558.  
  559.    elseif (p_Interactor == "char_smallcop" or p_Interactor == "char_bigcop") and
  560.            p_InteractedInteractor == "item_skull" then
  561.       CharacterControllerMgr:say("char_assil", "ID_FEEDBACK_NOT_SHOCKING_ENOUGH")
  562.       g_InteractionHandled = true
  563.  
  564.    elseif (p_Interactor == "char_smallcop" or p_Interactor == "char_bigcop") and
  565.            p_InteractedInteractor == "item_croc_purse" then
  566.       CharacterControllerMgr:say("char_assil", "ID_FEEDBACK_NOT_SHOCKING_ENOUGH")
  567.       g_InteractionHandled = true
  568.    end
  569.  
  570. end
  571. -----------------------------------------------------------------------
  572.  
  573. -----------------------------------------------------------------------
  574. -- lua slot called when the mouse entered an iactor associated 
  575. -- with this quest
  576. -----------------------------------------------------------------------
  577. function Global:onMouseEnteredInteractor(p_Interactor)
  578.    _LogInfo("Global:onMouseEnteredInteractor", p_Interactor)
  579. end
  580. -----------------------------------------------------------------------
  581.  
  582. -----------------------------------------------------------------------
  583. -- lua slot called when the mouse left an iactor associated 
  584. -- with this quest
  585. -----------------------------------------------------------------------
  586. function Global:onMouseLeftInteractor(p_Interactor)
  587.    _LogInfo("Global:onMouseLeftInteractor", p_Interactor)
  588. end
  589. -----------------------------------------------------------------------
  590.  
  591. -----------------------------------------------------------------------
  592. -- lua slot called when the player entered a location that is associated
  593. -- with this quest
  594. -----------------------------------------------------------------------
  595. function Global:onLocationEntered(p_Location)
  596.    _LogInfo("Global:onLocationEntered", p_Location)
  597.  
  598.    local SkinCtrl
  599.  
  600.    if p_Location == "bazar" then
  601.       SkinCtrl = ControllerMgr:getSkinController("animobj_bazar_cat_beige/SkinController")
  602.       SkinCtrl:blendTo("cat_idle", 0.1, 0, false, true)
  603.  
  604.       SkinCtrl = ControllerMgr:getSkinController("animobj_bazar_cat_black/SkinController")
  605.       SkinCtrl:setSpeed("cat_idle_greedy", 0.8, 0.0)
  606.       SkinCtrl:blendTo("cat_idle_greedy", 0.1, 0, false, true)
  607.  
  608.       SkinCtrl = ControllerMgr:getSkinController("animobj_bazar_cat_orange/SkinController")
  609.       SkinCtrl:setSpeed("cat_idle_greedy", 1.2, 0.0)
  610.       SkinCtrl:blendTo("cat_idle_greedy", 0.1, 0, false, true)
  611.  
  612.       if not CrocMask.quest:isDone("CrocPurseTaken") then
  613.          api:attachToBoneSafely("char_granny","item_croc_purse","RigProp")
  614.       end
  615.  
  616.       if not SunOfCairo.quest:isDone("BunchOfKeysTaken") then
  617.          api:attachToBoneSafely("char_slavedriver","animobj_iactor_key","RigPelvis")
  618.       end
  619.  
  620.       Global:startBazarWalkLoops()
  621.       char_egyptian_2:setMaterial("egyptian2")
  622.    end
  623.  
  624.    if p_Location == "giza" then
  625.       if not SunOfCairo.quest:isDone("CaravanLeaderWokenUp") then
  626.          SkinCtrl = ControllerMgr:getSkinController("animobj_giza_camel_a1/SkinController")
  627.          SkinCtrl:setSpeed("camel_idle", 0.7, 0.0)
  628.          SkinCtrl:blendTo("camel_idle", 0.1, 0, false, true)
  629.  
  630.          SkinCtrl = ControllerMgr:getSkinController("animobj_giza_camel_a2/SkinController")
  631.          SkinCtrl:setSpeed("camel_idle", 0.8, 0.0)
  632.          SkinCtrl:blendTo("camel_idle", 0.1, 0, false, true)
  633.  
  634.          local controller=ControllerMgr:getController("animobj_giza_sign/sign_idle")
  635.          controller:setCycleType(AnimationController.Loop)
  636.          local obj=GameEntityMgr:getGameEntity("animobj_giza_sign")
  637.          if not obj:isControllerAttached("animobj_giza_sign/sign_idle") then
  638.             obj:attachController("animobj_giza_sign/sign_idle")
  639.             ControllerMgr:resumeController("animobj_giza_sign/sign_idle")
  640.          end
  641.       end
  642.    end
  643.  
  644.    if p_Location == "palace_garden" then
  645.       if not Garden.quest:isDone("BannerAcquired") and not Garden.quest:isDone("WaterLevelLowered") then
  646.          local controller=ControllerMgr:getController("animobj_palace_garden_water_screw/turn_slow")
  647.          controller:setCycleType(AnimationController.Loop)
  648.          local obj=GameEntityMgr:getGameEntity("animobj_palace_garden_water_screw")
  649.          if not obj:isControllerAttached("animobj_palace_garden_water_screw/turn_slow") then
  650.             obj:attachController("animobj_palace_garden_water_screw/turn_slow")
  651.             ControllerMgr:resumeController("animobj_palace_garden_water_screw/turn_slow")
  652.          end
  653.       end
  654.    end
  655.  
  656.    if p_Location == "sphinx_inside" then
  657.       local controller=ControllerMgr:getController("animobj_sphinx_inside_warp_effect_a/teleporter_idle")
  658.       controller:setCycleType(AnimationController.Loop)
  659.       local obj=GameEntityMgr:getGameEntity("animobj_sphinx_inside_warp_effect_a")
  660.       if not obj:isControllerAttached("animobj_sphinx_inside_warp_effect_a/teleporter_idle") then
  661.          obj:attachController("animobj_sphinx_inside_warp_effect_a/teleporter_idle")
  662.          ControllerMgr:resumeController("animobj_sphinx_inside_warp_effect_a/teleporter_idle")
  663.       end
  664.    end
  665.  
  666.    if p_Location == "sphinx_inside" then
  667.           local SkinCtrl = ControllerMgr:getSkinController("animobj_sphinx_inside_electric_eel/SkinController")
  668.          SkinCtrl:setSpeed("eel1_swim", 0.9, 0.0)
  669.          SkinCtrl:blendTo("eel1_swim", 0.1, 0, false, true)
  670.  
  671.       if not Sphinx.quest:isDone("WaterFlushed") then
  672.          SkinCtrl = ControllerMgr:getSkinController("animobj_sphinx_inside_electric_eel1/SkinController")
  673.          SkinCtrl:setSpeed("eel1_swim", 0.9, 0.0)
  674.          SkinCtrl:blendTo("eel1_swim", 0.1, 0, false, true)
  675.          local controller=ControllerMgr:getController("eel1_swim")
  676.          controller:setCycleType(AnimationController.Loop)
  677.          local obj=GameEntityMgr:getGameEntity("animobj_sphinx_inside_electric_eel1")
  678.          if not obj:isControllerAttached("eel1_swim") then
  679.             obj:attachController("eel1_swim")
  680.             ControllerMgr:resumeController("eel1_swim")
  681.          end
  682.  
  683.          SkinCtrl = ControllerMgr:getSkinController("animobj_sphinx_inside_electric_eel2/SkinController")
  684.          SkinCtrl:setSpeed("eel2_swim", 1.1, 0.0)
  685.          SkinCtrl:blendTo("eel2_swim", 0.1, 0, false, true)
  686.          local controller=ControllerMgr:getController("eel2_swim")
  687.          controller:setCycleType(AnimationController.Loop)
  688.          local obj=GameEntityMgr:getGameEntity("animobj_sphinx_inside_electric_eel2")
  689.          if not obj:isControllerAttached("eel2_swim") then
  690.             obj:attachController("eel2_swim")
  691.             ControllerMgr:resumeController("eel2_swim")
  692.          end
  693.  
  694.          SkinCtrl = ControllerMgr:getSkinController("animobj_sphinx_inside_electric_eel3/SkinController")
  695.          SkinCtrl:setSpeed("eel3_swim", 0.8, 0.0)
  696.          SkinCtrl:blendTo("eel3_swim", 0.1, 0, false, true)
  697.          local controller=ControllerMgr:getController("eel3_swim")
  698.          controller:setCycleType(AnimationController.Loop)
  699.          local obj=GameEntityMgr:getGameEntity("animobj_sphinx_inside_electric_eel3")
  700.          if not obj:isControllerAttached("eel3_swim") then
  701.             obj:attachController("eel3_swim")
  702.             ControllerMgr:resumeController("eel3_swim")
  703.          end
  704.  
  705.          SkinCtrl = ControllerMgr:getSkinController("animobj_sphinx_inside_electric_eel4/SkinController")
  706.          SkinCtrl:setSpeed("eel4_swim", 1.0, 0.0)
  707.          SkinCtrl:blendTo("eel4_swim", 0.1, 0, false, true)
  708.          local controller=ControllerMgr:getController("eel4_swim")
  709.          controller:setCycleType(AnimationController.Loop)
  710.          local obj=GameEntityMgr:getGameEntity("animobj_sphinx_inside_electric_eel4")
  711.          if not obj:isControllerAttached("eel4_swim") then
  712.             obj:attachController("eel4_swim")
  713.             ControllerMgr:resumeController("eel4_swim")
  714.          end
  715.  
  716.          SkinCtrl = ControllerMgr:getSkinController("animobj_sphinx_inside_electric_eel5/SkinController")
  717.          SkinCtrl:setSpeed("eel5_swim", 1.05, 0.0)
  718.          SkinCtrl:blendTo("eel5_swim", 0.1, 0, false, true)
  719.          local controller=ControllerMgr:getController("eel5_swim")
  720.          controller:setCycleType(AnimationController.Loop)
  721.          local obj=GameEntityMgr:getGameEntity("animobj_sphinx_inside_electric_eel5")
  722.          if not obj:isControllerAttached("eel5_swim") then
  723.             obj:attachController("eel5_swim")
  724.             ControllerMgr:resumeController("eel5_swim")
  725.          end
  726.       end
  727.    end
  728.  
  729. end
  730. -----------------------------------------------------------------------
  731.  
  732. -----------------------------------------------------------------------
  733. -- lua slot called when the player left a location that is associated
  734. -- with this quest
  735. -----------------------------------------------------------------------
  736. function Global:onLocationLeft(p_Location)
  737.    _LogInfo("Global:onLocationLeft", p_Location)
  738.  
  739.    if p_Location == "desert_rock" or p_Location == "desert_plain" or 
  740.       p_Location == "desert_crossing" then
  741.       Ankh:hideFerrySwitch()
  742.    end
  743.  
  744.    if p_Location == "bazar" then
  745.       if not CrocMask.quest:isDone("CrocPurseTaken") then
  746.          api:detachFromBoneSafely("char_granny","item_croc_purse")
  747.       end
  748.  
  749.       if not SunOfCairo.quest:isDone("BunchOfKeysTaken") then
  750.          api:detachFromBoneSafely("char_slavedriver","animobj_iactor_key")
  751.       end
  752.  
  753.       Global:stopBazarWalkLoops()
  754.    end
  755.  
  756.    if p_Location == "giza" then
  757.       Global:stopRaseltinConversationLoop()
  758.       Global:stopBakshishGizaConversationLoop()
  759.    end
  760.  
  761.    if p_Location == "oasis" then
  762.       Global:stopGenieConversationLoop()
  763.    end
  764.  
  765.    if p_Location == "sphinx_outside" then
  766.       Global:stopBakshishConversationLoop()
  767.    end
  768.  
  769. end
  770. -----------------------------------------------------------------------
  771.  
  772. -----------------------------------------------------------------------
  773. -- lua slot called whenever a location associated with this quest
  774. -- has finished fading in
  775. -----------------------------------------------------------------------
  776. function Global:onLocationFadingInFinished(p_Location)
  777.    _LogInfo("Global:onLocationFadingInFinished", p_Location)
  778.  
  779.    if p_Location == "desert_rock" or p_Location == "desert_plain" or 
  780.       p_Location == "desert_crossing" then
  781.       Ankh:showFerrySwitch()
  782.    end
  783.  
  784.    if p_Location == "bazar" then
  785.       if not self.quest:isDone("SpokenToDinarOnce") and CameraMgr:getActiveCameraName() == "cam_bazar_burger" then
  786.          self.quest:setDone("SpokenToDinarOnce")
  787.          api:cutscene_("Standard_dinar_intercepts",0)
  788.       end
  789.    end
  790.    
  791.    if p_Location == "giza" then
  792.       if not SunOfCairo.quest:isDone("CaravanLeaderWokenUp") then
  793.          Global:startRaseltinConversationLoop()
  794.       elseif not Sphinx.quest:isActive() then
  795.          Global:startBakshishGizaConversationLoop()
  796.       end
  797.    end
  798.  
  799.    if p_Location == "sphinx_outside" and not SunOfCairo.quest:isDone("CaravanLeaderWokenUp") then
  800.       if CameraMgr:getActiveCameraName() == "cam_sphinx_outside_sphinx" then
  801.          Global:startBakshishConversationLoop()
  802.       else
  803.          Global:stopBakshishConversationLoop()
  804.       end
  805.    end
  806.  
  807.    if p_Location == "oasis" then
  808.       if not SunOfCairo.quest:isDone("SlaveDive") and SunOfCairo.quest:isActive() then
  809.          if LocationMgr:getLocationActivePathNodes("oasis") == "oasis_stairs_a_pathnodes" then
  810.             Global:startGenieConversationLoop()
  811.          else
  812.             Global:stopGenieConversationLoop()
  813.          end
  814.       end
  815.    end
  816.  
  817. end
  818. -----------------------------------------------------------------------
  819.  
  820. -----------------------------------------------------------------------
  821. -- lua slot called when a cutscene associated with this quest was
  822. -- finished
  823. -----------------------------------------------------------------------
  824. function Global:onCutsceneFinished(p_Cutscene)
  825.    _LogInfo("Global:onCutsceneFinished", p_Cutscene)
  826. end
  827. -----------------------------------------------------------------------
  828.  
  829. -----------------------------------------------------------------------
  830. -- lua slot called when a conversation associated with this quest
  831. -- was finished
  832. -----------------------------------------------------------------------
  833. function Global:onConversationFinished(p_Conversation)
  834.    _LogInfo("Global:onConversationFinished", p_Conversation)
  835. end
  836. ----------------------------------------------------------------------
  837.  
  838. -----------------------------------------------------------------------
  839. -- lua slot called when a conversation associated with this quest
  840. -- has fired a special event
  841. -----------------------------------------------------------------------
  842. function Global:onConversationEvent(p_Conversation, p_Event)
  843.    _LogInfo("Global:onConversationEvent", p_Conversation .. ":" .. p_Event)
  844.  
  845.    if p_Conversation == "Final_bakshish" and p_Event == "activate_final_animated_camera" then
  846.      CameraMgr:activateCamera("cam_underworld_bakshish_thara_shoe")
  847.    end
  848.  
  849.    if p_Conversation == "Final_pharaoh" then
  850.       if p_Event == "comedian_try_dance" then
  851.      -- let him try to dance and fail miserably
  852.      local skinCtrl = ControllerMgr:getSkinController("char_comedian_3/SkinController")
  853.      skinCtrl:setCycleType("comedian_3_fall",AnimationController.Clamp)
  854.      skinCtrl:blendTo("comedian_3_fall",0,0.35,false,true)
  855.      api:callDelayed("sound(\"punch\")",4.0)
  856.       elseif p_Event == "gordon_pull_lever" then
  857.      -- let him pull the lever to fulfil the comedian's destiny
  858.      local skinCtrl = ControllerMgr:getSkinController("char_gordon/SkinController")
  859.      skinCtrl:setCycleType("all_pull_lever",AnimationController.Clamp)
  860.      skinCtrl:blendTo("all_pull_lever",0,0.35,false,true)
  861.      animobj_lever_guard_pull:playAnimation("lever_pull")
  862.      api:callDelayed("Global:letComedianFall()",1.5)
  863.      sound("huge_lever_pull")
  864.       end
  865.    end
  866. end
  867. -----------------------------------------------------------------------
  868.  
  869. function Global:letComedianFall()
  870.    animobj_palace_throneroom_trapdoor_a:playAnimation("open")
  871.    animobj_palace_throneroom_trapdoor_b:playAnimation("open")
  872.    sound("trapdoor_open")
  873.    api:callDelayed("char_comedian_3:playAnimation(\"comedian_3_fall_into_hole\")",0.25)
  874. end
  875.  
  876. -----------------------------------------------------------------------
  877. -- lua slot called when a trigger associated with this quest
  878. -- has fired its event
  879. -----------------------------------------------------------------------
  880. function Global:onTriggerEvent(p_Trigger)
  881.    _LogInfo("Global:onTriggerEvent", p_Trigger)
  882. end
  883. -----------------------------------------------------------------------
  884.  
  885. -----------------------------------------------------------------------
  886. -- lua slot called when a trigger associated with this quest
  887. -- has fired its event enhanced with the face the trigger was entered
  888. -----------------------------------------------------------------------
  889. function Global:onTriggerFaceEvent(p_Trigger,p_FrontFace)
  890.    _LogInfo("Global:onTriggerFaceEvent", p_Trigger)
  891. end
  892. -----------------------------------------------------------------------
  893.  
  894. -----------------------------------------------------------------------
  895. -- sets the interactor configurations for the iactors associated with
  896. -- this quest according to the quest's current state
  897. -----------------------------------------------------------------------
  898. function Global:initConfigurations()
  899.    local questState = self.quest:getState()
  900.    -- default case, quest just initialized
  901.    if questState == "Initialized" then
  902.       for key, value in ipairs(self.iactors) do
  903.          local configName = self.name .. "_" .. value
  904.          _LogInfo("setting config: '" .. value .. "' to '" .. configName .. "'","")
  905.          if InteractorConfigurationMgr:isConfigurationPresent(configName) then
  906.             local iactor = GameEntityMgr:getInteractor(value)
  907.             iactor:setConfiguration(configName)
  908.          else
  909.              _LogWarning("lua", "No such config: " .. configName)
  910.           end
  911.       end
  912.    end
  913. end
  914. -----------------------------------------------------------------------
  915.  
  916. -----------------------------------------------------------------------
  917. -- check function
  918. -----------------------------------------------------------------------
  919. function Global:updateFromCheckList(p_Task, p_Done)
  920.    --_LogInfo("Global:updateFromCheckList", "")
  921.  
  922.    if p_Task == "PalaceGateIntroduced" then
  923.       if p_Done then
  924.      iactor_palace_gate_street_to_palace_gate_entrance:setConfiguration("cfg_iactor_palace_gate_street_to_palace_gate_entrance")
  925.       else
  926.      iactor_palace_gate_street_to_palace_gate_entrance:setConfiguration("PalaceGateIntro_iactor_palace_gate_street_to_palace_gate_entrance")
  927.       end
  928.    end
  929.  
  930.    if p_Task == "GlobalRaseltinLoopBlocked" then
  931.       if p_Done then
  932.          Global:stopRaseltinConversationLoop()
  933.       else
  934.          Global:startRaseltinConversationLoop()
  935.       end
  936.    end
  937.  
  938.    if p_Task == "GardenGordonLoopBlocked" then
  939.       if p_Done then
  940.          Global:stopGordonConversationLoop()
  941.       else
  942.          Global:startGordonConversationLoop()
  943.       end
  944.    end
  945.  
  946. end
  947. -----------------------------------------------------------------------
  948.  
  949. -----------------------------------------------------------------------
  950. -- start the conversation loop
  951. -----------------------------------------------------------------------
  952. function Global:startSlaveConversationLoop()
  953.    _LogInfo("Global:startSlaveConversationLoop", "")
  954.  
  955.    if not QuestMgr:isQuestActive("SunOfCairo") then
  956.       ConversationMgr:setConversationInteractive("Standard_slave_slavedriver_loop", false)
  957.       -- text position 0 is 'overhead'
  958.       ConversationMgr:setTextPosition("Standard_slave_slavedriver_loop", 0)
  959.       api:conversation("Standard_slave_slavedriver_loop")
  960.    elseif not SunOfCairo.quest:isDone("SlavedriverPassedOut") then
  961.       ConversationMgr:setConversationInteractive("SunOfCairo_slave_slavedriver_loop", false)
  962.       -- text position 0 is 'overhead'
  963.       ConversationMgr:setTextPosition("SunOfCairo_slave_slavedriver_loop", 0)
  964.       api:conversation("SunOfCairo_slave_slavedriver_loop")
  965.    end
  966.  
  967. end
  968. -----------------------------------------------------------------------
  969.  
  970. -----------------------------------------------------------------------
  971. -- stop the conversation loop
  972. -----------------------------------------------------------------------
  973. function Global:stopSlaveConversationLoop()
  974.    _LogInfo("Global:stopSlaveConversationLoop", "")
  975.  
  976.    if not QuestMgr:isQuestActive("SunOfCairo") then
  977.       ConversationMgr:cancelConversation("Standard_slave_slavedriver_loop")
  978.    else
  979.       ConversationMgr:cancelConversation("SunOfCairo_slave_slavedriver_loop")
  980.    end
  981.  
  982. end
  983. -----------------------------------------------------------------------
  984.  
  985. -----------------------------------------------------------------------
  986. -- start the conversation loop
  987. -----------------------------------------------------------------------
  988. function Global:startBakshishConversationLoop()
  989.    _LogInfo("Global:startBakshishConversationLoop", "")
  990.  
  991.    -- TL added Osiris check
  992.    if not Osiris.quest:isActive() then
  993.       ConversationMgr:setConversationInteractive("SunOfCairo_bakshish_loop", false)
  994.       -- text position 0 is 'overhead'
  995.       ConversationMgr:setTextPosition("SunOfCairo_bakshish_loop", 0)
  996.       api:conversation("SunOfCairo_bakshish_loop")
  997.    end
  998.  
  999. end
  1000. -----------------------------------------------------------------------
  1001.  
  1002. -----------------------------------------------------------------------
  1003. -- stop the conversation loop
  1004. -----------------------------------------------------------------------
  1005. function Global:stopBakshishConversationLoop()
  1006.    _LogInfo("Global:stopBakshishConversationLoop", "")
  1007.  
  1008.    ConversationMgr:cancelConversation("SunOfCairo_bakshish_loop")
  1009.  
  1010. end
  1011. -----------------------------------------------------------------------
  1012.  
  1013. -----------------------------------------------------------------------
  1014. -- start the conversation loop
  1015. -----------------------------------------------------------------------
  1016. function Global:startRaseltinConversationLoop()
  1017.    _LogInfo("Global:startRaseltinConversationLoop", "")
  1018.  
  1019.    if not self.quest:isDone("GlobalRaseltinLoopRunning") and
  1020.       not self.quest:isDone("GlobalRaseltinLoopBlocked") then
  1021.       ConversationMgr:setConversationInteractive("Oasis_raseltin_loop", false)
  1022.       -- text position 0 is 'overhead'
  1023.       ConversationMgr:setTextPosition("Oasis_raseltin_loop", 0)
  1024.       api:conversation("Oasis_raseltin_loop")
  1025.       self.quest:setDone("GlobalRaseltinLoopRunning")
  1026.    end
  1027.  
  1028. end
  1029. -----------------------------------------------------------------------
  1030.  
  1031. -----------------------------------------------------------------------
  1032. -- stop the conversation loop
  1033. -----------------------------------------------------------------------
  1034. function Global:stopRaseltinConversationLoop()
  1035.    _LogInfo("Global:stopRaseltinConversationLoop", "")
  1036.  
  1037.    if self.quest:isDone("GlobalRaseltinLoopRunning") then
  1038.       ConversationMgr:cancelConversation("Oasis_raseltin_loop")
  1039.       self.quest:setUndone("GlobalRaseltinLoopRunning")
  1040.    end
  1041.  
  1042. end
  1043. -----------------------------------------------------------------------
  1044.  
  1045. -----------------------------------------------------------------------
  1046. -- start the conversation loop
  1047. -----------------------------------------------------------------------
  1048. function Global:startBakshishGizaConversationLoop()
  1049.    _LogInfo("Global:startBakshishGizaConversationLoop", "")
  1050.  
  1051.    ConversationMgr:setConversationInteractive("SunOfCairo_bakshish_giza_loop", false)
  1052.    -- text position 0 is 'overhead'
  1053.    ConversationMgr:setTextPosition("SunOfCairo_bakshish_giza_loop", 0)
  1054.    api:conversation("SunOfCairo_bakshish_giza_loop")
  1055.  
  1056. end
  1057. -----------------------------------------------------------------------
  1058.  
  1059. -----------------------------------------------------------------------
  1060. -- stop the conversation loop
  1061. -----------------------------------------------------------------------
  1062. function Global:stopBakshishGizaConversationLoop()
  1063.    _LogInfo("Global:stopBakshishGizaConversationLoop", "")
  1064.  
  1065.    ConversationMgr:cancelConversation("SunOfCairo_bakshish_giza_loop")
  1066.  
  1067. end
  1068. -----------------------------------------------------------------------
  1069.  
  1070. -----------------------------------------------------------------------
  1071. -- start the conversation loop
  1072. -----------------------------------------------------------------------
  1073. function Global:startGordonConversationLoop()
  1074.    _LogInfo("Global:startGordonConversationLoop", "")
  1075.  
  1076.    if not self.quest:isDone("GardenGordonLoopRunning") and
  1077.       not self.quest:isDone("GardenGordonLoopBlocked") then
  1078.       ConversationMgr:setConversationInteractive("Garden_gordon_loop", false)
  1079.       -- text position 0 is 'overhead'
  1080.       ConversationMgr:setTextPosition("Garden_gordon_loop", 0)
  1081.       api:conversation("Garden_gordon_loop")
  1082.       self.quest:setDone("GardenGordonLoopRunning")
  1083.    end
  1084.  
  1085. end
  1086. -----------------------------------------------------------------------
  1087.  
  1088. -----------------------------------------------------------------------
  1089. -- stop the conversation loop
  1090. -----------------------------------------------------------------------
  1091. function Global:stopGordonConversationLoop()
  1092.    _LogInfo("Global:stopGordonConversationLoop", "")
  1093.  
  1094.    if self.quest:isDone("GardenGordonLoopRunning") then
  1095.       ConversationMgr:cancelConversation("Garden_gordon_loop")
  1096.       self.quest:setUndone("GardenGordonLoopRunning")
  1097.    end
  1098.  
  1099. end
  1100. -----------------------------------------------------------------------
  1101.  
  1102. -----------------------------------------------------------------------
  1103. -- start the conversation loop
  1104. -----------------------------------------------------------------------
  1105. function Global:startGenieConversationLoop()
  1106.    _LogInfo("Global:startGenieConversationLoop", "")
  1107.  
  1108.    ConversationMgr:setConversationInteractive("SunOfCairo_genie_loop", false)
  1109.    -- text position 0 is 'overhead'
  1110.    ConversationMgr:setTextPosition("SunOfCairo_genie_loop", 0)
  1111.    api:conversation("SunOfCairo_genie_loop")
  1112.  
  1113. end
  1114. -----------------------------------------------------------------------
  1115.  
  1116. -----------------------------------------------------------------------
  1117. -- stop the conversation loop
  1118. -----------------------------------------------------------------------
  1119. function Global:stopGenieConversationLoop()
  1120.    _LogInfo("Global:stopGenieConversationLoop", "")
  1121.  
  1122.    ConversationMgr:cancelConversation("SunOfCairo_genie_loop")
  1123.  
  1124. end
  1125. -----------------------------------------------------------------------
  1126.  
  1127. -----------------------------------------------------------------------
  1128. -- The default interaction handler, should handle interactions
  1129. -- that have not been handled by any active quest
  1130. -- For this to work, all quests have to flag the global variable
  1131. -- 'g_InteractionHandled' to true whenever a combination of objects
  1132. -- worked out.
  1133. -----------------------------------------------------------------------
  1134. DefaultInteractionHandler = {}
  1135. -----------------------------------------------------------------------
  1136. function DefaultInteractionHandler:onInteractorsCombined(p_Interactor,
  1137.                              p_InteractedInteractor)
  1138.    if not g_InteractionHandled then
  1139.       -- no quest handled the interaction, the action did not make sense
  1140.       -- it's possible to handle the interaction depending on the two objects
  1141.       -- combined allowing for more elaborate behaviour than just
  1142.       -- "That doesn't make sense"...
  1143.  
  1144.       local i = math.random(2)
  1145.  
  1146.       if i == 0 then
  1147.           player:say("ID_THATS_SILLY")
  1148.       elseif i == 1 then
  1149.           player:say("ID_WONT_WORK_OUT")
  1150.       elseif i == 2 then
  1151.           player:say("ID_DOESNT_WORK")
  1152.       else -- won't be included TL
  1153.           player:say("ID_THATS_SILLY")
  1154.       end
  1155.  
  1156.       --[[if iaction(p_Interactor,p_InteractedInteractor,
  1157.       "char_tarok","item_brush_broken") then
  1158.       player:say("Hitting him on the head, that might actually be fun...")
  1159.       else
  1160.       player:say("I don't think that'll work out")
  1161.       end]]
  1162.  
  1163.    end
  1164.  
  1165.    -- flag the next interaction to come as "not yet handled"
  1166.    g_InteractionHandled = false
  1167. end
  1168. -----------------------------------------------------------------------
  1169.  
  1170. -----------------------------------------------------------------------
  1171. -- functions handling walking of bazar characters
  1172. -----------------------------------------------------------------------
  1173. function Global:startBazarWalkLoops()
  1174.    if not self.quest:isDone("GrannyWalkActive") then
  1175.       char_granny:setPosition(-27.5, 0, -534)
  1176.       self:startGrannyWalkLoop()
  1177.    end
  1178.    --self.quest:setDone("Egyptian1WalkActive")
  1179.    --self.quest:setDone("Egyptian2WalkActive")
  1180.  
  1181.    if not self.quest:isDone("Egyptian1WalkActive") then
  1182.       char_egyptian_1:setPosition(473,119,-811)
  1183.       _LogInfo("Global:startBazarWalkLoops", "")
  1184.       char_egyptian_1:setPathnodeGraph("peasant_a")
  1185.       self:startEgyptian1WalkLoop()
  1186.    end
  1187.    --self:walkToGirlieEgyptian1()
  1188.  
  1189.    if not self.quest:isDone("Egyptian2WalkActive") then
  1190.       char_egyptian_2:setPosition(680, 286, -2024)
  1191.       char_egyptian_2:setPathnodeGraph("peasant_b")
  1192.       --self:walkToTailorEgyptian2()
  1193.       api:callDelayed("Global:startEgyptian2WalkLoop()", 1)
  1194.    end
  1195.  
  1196. end
  1197. -----------------------------------------------------------------------
  1198. function Global:startEgyptian1WalkLoop()
  1199.    if not self.quest:isDone("Egyptian1WalkActive") then
  1200.       self.quest:setDone("Egyptian1WalkActive")
  1201.       if not self.quest:isDone("Egyptian1WalkToGirliePending") then
  1202.          self:walkToGirlieEgyptian1()
  1203.       end
  1204.    end
  1205. end
  1206. -----------------------------------------------------------------------
  1207. function Global:stopEgyptian1WalkLoop()
  1208.    CharacterControllerMgr:stop("char_egyptian_1")
  1209.    self.quest:setUndone("Egyptian1WalkActive")
  1210. end
  1211. -----------------------------------------------------------------------
  1212. function Global:startEgyptian2WalkLoop()
  1213.    if not self.quest:isDone("Egyptian2WalkActive") then
  1214.       self.quest:setDone("Egyptian2WalkActive")
  1215.       if not self.quest:isDone("Egyptian2WalkOffPending") then
  1216.          Global:walkToTailorEgyptian2()
  1217.       end
  1218.    end
  1219. end
  1220. -----------------------------------------------------------------------
  1221. function Global:stopEgyptian2WalkLoop()
  1222.    CharacterControllerMgr:stop("char_egyptian_2")
  1223.    self.quest:setUndone("Egyptian2WalkActive")
  1224. end
  1225. -----------------------------------------------------------------------
  1226. function Global:stopEgyptian1WalkLoop()
  1227.    CharacterControllerMgr:stop("char_egyptian_1")
  1228.    self.quest:setUndone("Egyptian1WalkActive")
  1229. end
  1230. -----------------------------------------------------------------------
  1231. function Global:startGrannyWalkLoop()
  1232.    self.quest:setDone("GrannyWalkActive")
  1233.    CharacterControllerMgr:setWalkSpeed("char_granny",30)
  1234.    self:walkToUpperPointGranny()
  1235. end
  1236. -----------------------------------------------------------------------
  1237. function Global:continueGrannyWalkLoop()
  1238.    self.quest:setDone("GrannyWalkActive")
  1239.    self:walkToLowerPointGrannyStartingFromAttachPoint()
  1240.    --CharacterControllerMgr:setWalkSpeed("char_granny",30)
  1241. end
  1242. -----------------------------------------------------------------------
  1243. function Global:stopGrannyWalkLoop()
  1244.    CharacterControllerMgr:stop("char_granny")
  1245.    self.quest:setUndone("GrannyWalkActive")
  1246. end
  1247. -----------------------------------------------------------------------
  1248. function Global:stopBazarWalkLoops()
  1249.    CharacterControllerMgr:stop("char_egyptian_1")
  1250.    CharacterControllerMgr:stop("char_egyptian_2")
  1251.    CharacterControllerMgr:stop("char_granny")
  1252.  
  1253.    self.quest:setUndone("Egyptian1WalkActive")
  1254.    self.quest:setUndone("Egyptian2WalkActive")
  1255.    self.quest:setUndone("GrannyWalkActive")
  1256.  
  1257.    self.quest:setUndone("GrannyWalkActive")
  1258.  
  1259.    --[[if char_granny:isControllerAttached("char_granny/RotationController_Begin") then
  1260.       char_granny:detachController("char_granny/RotationController_Begin")
  1261.    end
  1262.  
  1263.    if char_egyptian_1:isControllerAttached("char_egyptian_1/RotationController_Begin") then
  1264.       char_egyptian_1:detachController("char_egyptian_1/RotationController_Begin")
  1265.    end
  1266.  
  1267.    if char_egyptian_2:isControllerAttached("char_egyptian_2/RotationController_Begin") then
  1268.       char_egyptian_2:detachController("char_egyptian_2/RotationController_Begin")
  1269.    end
  1270.  
  1271.    if char_granny:isControllerAttached("char_granny/RotationController_End") then
  1272.       char_granny:detachController("char_granny/RotationController_End")
  1273.    end
  1274.  
  1275.    if char_egyptian_1:isControllerAttached("char_egyptian_1/RotationController_End") then
  1276.       char_egyptian_1:detachController("char_egyptian_1/RotationController_End")
  1277.    end
  1278.  
  1279.    if char_egyptian_2:isControllerAttached("char_egyptian_2/RotationController_End") then
  1280.       char_egyptian_2:detachController("char_egyptian_2/RotationController_End")
  1281.    end]]
  1282. end
  1283. -----------------------------------------------------------------------
  1284. function Global:walkToLowerPointGrannyStartingFromAttachPoint()
  1285.    if self.quest:isDone("GrannyWalkActive") then
  1286.       if LocationMgr:getCurrentLocation() == "bazar" then
  1287.          CharacterControllerMgr:walk("char_granny",
  1288.                      PinaVector3(-27.5,0,-534),
  1289.                      Degree(0))
  1290.          api:callDelayed("Global:walkToUpperPointGranny()",25)
  1291.       else
  1292.          self.quest:setUndone("GrannyWalkActive")
  1293.       end   
  1294.    end
  1295. end
  1296. -----------------------------------------------------------------------
  1297. function Global:walkToLowerPointGranny()
  1298.    if self.quest:isDone("GrannyWalkActive") then
  1299.       if LocationMgr:getCurrentLocation() == "bazar" then
  1300.          CharacterControllerMgr:walk("char_granny",
  1301.                      PinaVector3(-27.5,0,-534),
  1302.                      Degree(0))
  1303.          api:callDelayed("Global:walkToUpperPointGranny()",45)
  1304.       else
  1305.          self.quest:setUndone("GrannyWalkActive")
  1306.       end   
  1307.    end
  1308. end
  1309. -----------------------------------------------------------------------
  1310. function Global:walkToUpperPointGranny()
  1311.    if self.quest:isDone("GrannyWalkActive") then
  1312.       if LocationMgr:getCurrentLocation() == "bazar" then
  1313.          CharacterControllerMgr:walk("char_granny",
  1314.                      --PinaVector3(66,0,-1891),
  1315.                  PinaVector3(73, 266, -1697),
  1316.                    Degree(270))
  1317.          api:callDelayed("Global:walkToLowerPointGranny()",45)
  1318.       else
  1319.          self.quest:setUndone("GrannyWalkActive")
  1320.       end
  1321.    end
  1322. end
  1323. -----------------------------------------------------------------------
  1324. function Global:walkOffEgyptian1()
  1325.    _LogInfo("walkOffEgyptian1","called")
  1326.  
  1327.    if LocationMgr:getCurrentLocation() == "bazar" then
  1328.       CharacterControllerMgr:walk("char_egyptian_1",
  1329.                   --PinaVector3(12,-32,675),
  1330.               PinaVector3(473, 119, -811),
  1331.                   Degree(270))
  1332.  
  1333.       if self.quest:isDone("Egyptian1WalkActive") then
  1334.           local delay = 10 + math.random(5)  
  1335.          if not self.quest:setDone("Egyptian1WalkToGirliePending") then
  1336.              api:callDelayed("Global:walkToGirlieEgyptian1",delay)
  1337.             self.quest:setDone("Egyptian1WalkToGirliePending")
  1338.          end
  1339.       end
  1340.    else
  1341.       self.quest:setUndone("Egyptian1WalkActive")
  1342.    end
  1343. end
  1344. -----------------------------------------------------------------------
  1345.  
  1346. -----------------------------------------------------------------------
  1347. function Global:walkOffEgyptian2()
  1348.    if LocationMgr:getCurrentLocation() == "bazar" then
  1349.       CharacterControllerMgr:walk("char_egyptian_2",
  1350.                   PinaVector3(680, 286, -2024),
  1351.                   Degree(270))
  1352.       if self.quest:isDone("Egyptian2WalkActive") then      
  1353.          if not self.quest:setDone("Egyptian2WalkToTailorPending") then
  1354.           local delay = 10 + math.random(5)
  1355.           api:callDelayed("Global:walkToTailorEgyptian2",delay)
  1356.          self.quest:setDone("Egyptian2WalkToTailorPending")
  1357.          end
  1358.       end
  1359.    else
  1360.       self.quest:setUndone("Egyptian2WalkActive")
  1361.    end
  1362. end
  1363. -----------------------------------------------------------------------
  1364. function Global:walkToGirlieEgyptian1()
  1365.    _LogInfo("walkToGirlieEgyptian1","called")
  1366.  
  1367.    if self.quest:isDone("Egyptian1WalkActive") then      
  1368.       if LocationMgr:getCurrentLocation() == "bazar" then
  1369.          if (api:getDistanceSqr(char_assil:getPosition(),char_egyptian_1:getPosition())>360000) then
  1370.             self.quest:setUndone("Egyptian1WalkToGirliePending")
  1371.             CharacterControllerMgr:walk("char_egyptian_1",
  1372.                    --PinaVector3(-49.346577,8.073211,-266.370728),
  1373.                PinaVector3(0, 5, -282),
  1374.                    Degree(270))
  1375.             local delay = 10 + math.random(5)
  1376.             api:callDelayed("Global:walkOffEgyptian1()",delay)
  1377.          else
  1378.             if not self.quest:isDone("Egyptian1WalkToGirliePending") then
  1379.                api:callDelayed("Global:walkToGirlieEgyptian1()", 5)
  1380.                self.quest:setDone("Egyptian1WalkToGirliePending")
  1381.             end
  1382.          end   
  1383.       else
  1384.          self.quest:setUndone("Egyptian1WalkActive")
  1385.       end   
  1386.    end
  1387. end
  1388. -----------------------------------------------------------------------
  1389. function Global:walkToTailorEgyptian2()
  1390.    if self.quest:isDone("Egyptian2WalkActive") then      
  1391.       if LocationMgr:getCurrentLocation() == "bazar" then
  1392.          if (api:getDistanceSqr(char_assil:getPosition(),char_egyptian_2:getPosition())>360000) then
  1393.             self.quest:setUndone("Egyptian2WalkToTailorPending")
  1394.             CharacterControllerMgr:walk("char_egyptian_2",
  1395.                    PinaVector3(112, 273, -1770),
  1396.                    Degree(280))
  1397.             local delay = 10 + math.random(5)
  1398.             api:callDelayed("Global:walkOffEgyptian2()",delay)
  1399.          else
  1400.             if not self.quest:isDone("Egyptian2WalkToTailorPending") then
  1401.                api:callDelayed("Global:walkToTailorEgyptian2()", 5)
  1402.                self.quest:setDone("Egyptian2WalkToTailorPending")
  1403.             end
  1404.          end   
  1405.       else
  1406.          self.quest:setUndone("Egyptian2WalkActive")
  1407.       end   
  1408.    end
  1409. end
  1410. -----------------------------------------------------------------------
  1411. function Global:onAssilGetsCloseToEgyptian1()
  1412.    _LogInfo("onAssilGetsCloseToEgyptian1","setting Egyptian1WalkActive undone")
  1413.    --self.quest:setUndone("Egyptian1WalkActive")
  1414.    self:egyptian1FleeAssil()
  1415. end
  1416. -----------------------------------------------------------------------
  1417. function Global:egyptian1FleeAssil()
  1418.    --self.quest:setUndone("Egyptian1WalkActive")
  1419.    self:walkOffEgyptian1()
  1420.    --self.quest:setDone("Egyptian1WalkActive")
  1421. end
  1422. -----------------------------------------------------------------------
  1423. function Global:onAssilGetsCloseToEgyptian2()
  1424.    _LogInfo("onAssilGetsCloseToEgyptian1","setting Egyptian2WalkActive undone")
  1425.    --self.quest:setUndone("Egyptian2WalkActive")
  1426.    --self:walkOffEgyptian2()
  1427.    self:egyptian2FleeAssil()
  1428. end
  1429. -----------------------------------------------------------------------
  1430. function Global:egyptian2FleeAssil()
  1431.    self.quest:setUndone("Egyptian2WalkActive")
  1432.    self:walkOffEgyptian2()
  1433.    --self.quest:setDone("Egyptian2WalkActive")
  1434. end
  1435. -----------------------------------------------------------------------
  1436. function Global:onCameraChanged()
  1437.  
  1438.    local cam = CameraMgr:getActiveCameraName()
  1439.    if cam == "cam_bazar_entrance" then
  1440.       char_egyptian_1:setVisible(false)
  1441.       char_egyptian_2:setVisible(true)
  1442.  
  1443.    elseif cam == "cam_bazar_cloth" then
  1444.       char_egyptian_1:setVisible(true)
  1445.       char_egyptian_2:setVisible(false)
  1446.  
  1447.    elseif cam == "cam_bazar_plaza" then
  1448.       char_egyptian_1:setVisible(false)
  1449.       char_egyptian_2:setVisible(true)
  1450.  
  1451.    elseif cam == "cam_bazar_a" then
  1452.       char_egyptian_1:setVisible(true)
  1453.       char_egyptian_2:setVisible(true)
  1454.  
  1455.    end
  1456. end
  1457. -----------------------------------------------------------------------
  1458.  
  1459. -----------------------------------------------------------------------
  1460. -----------------------------------------------------------------------
  1461. function Global:fadeInChapter2()
  1462.    local overlay = GUIWindowMgr:getOverlay2D("ankh_chapter_overlay")
  1463.    overlay:setTextureName("ankh_chapter_overlay/ImagePanel","chapter_2_german.tga")
  1464.    overlay:setVisible(true)
  1465.    overlay:setAlpha(0.0)
  1466.    overlay:animateAlpha(0.0,1.0,1.0)
  1467. end
  1468. -----------------------------------------------------------------------
  1469.  
  1470. -----------------------------------------------------------------------
  1471. -----------------------------------------------------------------------
  1472. function Global:fadeOutChapter2()
  1473.    local overlay = GUIWindowMgr:getOverlay2D("ankh_chapter_overlay")
  1474.    overlay:setVisible(true)
  1475.    overlay:setAlpha(1.0)
  1476.    overlay:animateAlpha(1.0,0.0,1.0)
  1477. end
  1478. -----------------------------------------------------------------------
  1479.  
  1480. -----------------------------------------------------------------------
  1481. -----------------------------------------------------------------------
  1482. function Global:showTreasureMap()   
  1483.    local overlay = GUIWindowMgr:getOverlay2D("ankh_treasure_map")
  1484.    overlay:setVisible(true)
  1485.    --overlay:setAlpha(0.0)
  1486.    --overlay:animateAlpha(1.0,0.0,1.0)
  1487. end
  1488. -----------------------------------------------------------------------
  1489.  
  1490. -----------------------------------------------------------------------
  1491. -----------------------------------------------------------------------
  1492. function Global:hideTreasureMap()
  1493.    local overlay = GUIWindowMgr:getOverlay2D("ankh_treasure_map")
  1494.    overlay:setVisible(false)
  1495.    --overlay:setVisible(true)
  1496.    --overlay:setAlpha(1.0)
  1497.    --overlay:animateAlpha(0.0,1.0,1.0)
  1498. end
  1499. -----------------------------------------------------------------------
  1500.  
  1501. -----------------------------------------------------------------------
  1502. -----------------------------------------------------------------------
  1503. function Global:toggleTreasureMap()
  1504.    local overlay = GUIWindowMgr:getOverlay2D("ankh_treasure_map")
  1505.    if overlay:isVisible() then
  1506.       Global:hideTreasureMap()
  1507.    else
  1508.       Global:showTreasureMap()
  1509.    end
  1510. end
  1511. -----------------------------------------------------------------------
  1512.  
  1513. -----------------------------------------------------------------------
  1514. --
  1515. -----------------------------------------------------------------------
  1516. function Global:onAssilCloseToThara()
  1517.  
  1518.    if not Ankh:isCharSwitchVisible() then
  1519.       return 
  1520.    end
  1521.  
  1522.    MouseIface:blockInput(1.0)
  1523.  
  1524.    if GameEntityMgr:getMainCharacter() == "char_assil" then
  1525.       -- get rotation, rotate by 180 degree, give go
  1526.       local yawBefore = char_assil:getRotate():getYaw()
  1527.       _LogInfo("","s" .. yawBefore:getDegrees())
  1528.       local yawAfter  = Degree(180 + yawBefore:getDegrees())
  1529.       if yawAfter:getDegrees() > 360 then
  1530.      yawAfter = yawAfter - Degree(360)
  1531.       end
  1532.       char_assil:setYaw(yawAfter)
  1533.       char_assil:move(0,0,50)
  1534.       targetPos = char_assil:getPosition()
  1535.       char_assil:move(0,0,-50)
  1536.       char_assil:setYaw(yawBefore)
  1537.       CharacterControllerMgr:walk("char_assil",targetPos,yawAfter)
  1538.    end
  1539.  
  1540.    if GameEntityMgr:getMainCharacter() == "char_thara" then
  1541.       -- get rotation, rotate by 180 degree, give go
  1542.       local yawBefore = char_thara:getRotate():getYaw()
  1543.       _LogInfo("","s" .. yawBefore:getDegrees())
  1544.       local yawAfter  = Degree(180 + yawBefore:getDegrees())
  1545.       if yawAfter:getDegrees() > 360 then
  1546.      yawAfter = yawAfter - Degree(360)
  1547.       end
  1548.       char_thara:setYaw(yawAfter)
  1549.       char_thara:move(0,0,50)
  1550.       targetPos = char_thara:getPosition()
  1551.       char_thara:move(0,0,-50)
  1552.       char_thara:setYaw(yawBefore)
  1553.       CharacterControllerMgr:walk("char_thara",targetPos,yawAfter)
  1554.    end
  1555.  
  1556. end
  1557. -----------------------------------------------------------------------
  1558.