departureCinematics = { "Sc02_BalloonTakeoff", -- 01 "Sc45_BalloonTakeoff3", -- 02 "Sc09_BalloonTakeoff2", -- 03 "Sc12_ShipTakeoff", -- 04 "Sc48_ShipTakeoff2", -- 05 "Sc49_ShipTakeoff3", -- 06 "Sc20_BridgeTakeoff", -- 07 "Sc51_BridgeTakeoff2", -- 08 "Sc23_TreeTakeoff", -- 09 "Sc58_TreeTakeoff2", -- 10 "Sc26_CannonTakeoff", -- 11 "Sc59_CannonTakeoff2", -- 12 "Sc60_CannonTakeoff3", -- 13 "Sc31_TunnelTakeoff", -- 14 "Sc61_TunnelTakeoff2", -- 15 "Sc62_TunnelTakeoff3", -- 16 "Sc35_TrainTakeoff", -- 17 "Sc64_TrainTakeoff2", -- 18 "Sc38_ChainTakeoff", -- 19 "Sc65_ChainTakeoff2", -- 20 "Sc42_FinalTakeoff", -- 21 } function introHandlers() local state = RuinsState.get() -- Intro Cutscene Handlers if not sc03played and not sc03Done and state == 1 and isThereAPlayer() then print ("playing sl_sc02") sc03played = true playMovie("sl_sc02") end if trigger.received(1,"sl_sc02Done") then print("playing Sc03_AfterTutorial") object("Sc03_AfterTutorial").trigger.send() end if not sc04played and not sc04Done and state == 2 and isThereAPlayer() then print("playing Sc04_AfterSheep") sc04played = true object("Sc04_AfterSheep").trigger.send() end if not sc07played and not sc07Done and state == 3 and isThereAPlayer() then print("playing Sc07_AfterDocks") sc07played = true object("Sc07_AfterDocks").trigger.send() end --state 4 - air source, lower docks gate if not sc10played and not sc10Done and state == 4 and isThereAPlayer() then sc10played = true print("playing sl_sc04") playMovie("sl_sc04") end if trigger.received(1,"sl_sc04Done") then print("playing Sc10_WaterBeach") object("Sc10_WaterBeach").trigger.send() end --state 5 if not sc13played and not sc13Done and state == 5 and isThereAPlayer() then print("playing Sc13_WaterOilDonkey") sc13played = true object("Sc13_WaterOilDonkey").trigger.send() end if trigger.received(1,"sc13Done") then spawnOilCan() object("Oil_Donkey").trigger.send() end --state 6 if not sc18played and not sc18Done and state == 6 and isThereAPlayer() then print("playing sky_800_moment_02") sc18played = true playMovie("sky_800_moment_02") end if trigger.received(1,"sky_800_moment_02Done") then print("playing Sc18_WaterReady") object("Sc18_WaterReady").trigger.send() end --state 7 if not sc19played and not sc19Done and state == 7 and isThereAPlayer() then sc19played = true print("playing sl_sc06") playMovie("sl_sc06") end if trigger.received(1,"sl_sc06Done") then print("playing Sc19_EarthBeach") object("Sc19_EarthBeach").trigger.send() end --state 8 if not sc21played and not sc21Done and state == 8 and isThereAPlayer() then print("playing sky_800_moment_04") sc21played = true playMovie("sky_800_moment_04") end if trigger.received(1,"sky_800_moment_04Done") then print("playing Sc21_EarthReady") object("Sc21_EarthReady").trigger.send() end --state 9 if trigger.received(1,"switchVine") then print("switchVine") object("VineBridge1").delete() object("vine_RIG").setAlpha(1) object("LeafPlatform").setAlpha(1) end if not sc22played and not sc22Done and state == 9 and isThereAPlayer() then object("vine_RIG").setAlpha(0) object("LeafPlatform").setAlpha(0) object("VineBridge1").setAlpha(0) sc22played = true print("playing sky_800_moment_05") playMovie("sky_800_moment_05") end if trigger.received(1,"sc22vineGrow") then object("VineBridge1").setAlpha(1) end if trigger.received(1,"sky_800_moment_05Done") then print("playing Sc22_LifeAppears") object("Sc22_LifeAppears").trigger.send() object("FlippableRock").setAlpha(0) end --state 10 if not sc24played and not sc24Done and not sc52Played and not sc52Done and state == 10 and isThereAPlayer() then print("playing Sc24_LifePlanting") sc24played = true object("Sc24_LifePlanting").trigger.send() end if trigger.received(1,"AppleGameOver") and not sc52Played and not sc52Done then print("apple game over, playing sc52") --force UI to close DisappearClamUI() -- yes, it works for apple UI too object("Sc52_LifeReady").trigger.send() sc52Played = true NPCsPlaced = false end --state 11 if not sc25played and not sc25Done and state == 11 and isThereAPlayer() then sc25played = true print("playing sky_800_moment_06") playMovie("sky_800_moment_06") end if trigger.received(1,"sky_800_moment_06Done") then print("playing Sc25_TechGeneralRobot") object("Sc25_TechGeneralRobot").trigger.send() end --state 12 if not sc27played and not sc27Done and state == 12 and isThereAPlayer() then sc27played = true print("playing sl_sc12") playMovie("sl_sc12") end if trigger.received(1,"sl_sc12Done") then print("playing Sc27_TechGoo") object("Sc27_TechGoo").trigger.send() end --state 13 if not sc28played and not sc28Done and state == 13 and isThereAPlayer() then sc28played = true print("playing sky_800_moment_08") playMovie("sky_800_moment_08") end if trigger.received(1,"sky_800_moment_08Done") then print("playing Sc28_TechReady") object("Sc28_TechReady").trigger.send() end --state 14 if not sc30played and not sc30Done and state == 14 and isThereAPlayer() then sc30played = true print("playing sl_sc14") playMovie("sl_sc14") end if trigger.received(1,"sl_sc14Done") then print("playing Sc30_UndeadGate") object("Sc30_UndeadGate").trigger.send() end if not sc46wp or not sc46wpPos then sc46wp = object("IGC_741_Meet_T_Bone_waypoint_1") sc46wpPos = { object("IGC_741_Meet_T_Bone_waypoint_1").position() } end if not sc46played and not sc47Done and state == 14 and isThereAPlayer() then local tp, d , d2d = getNearestPlayer( sc46wpPos ) if d <= 16 then object("Sc46_UndeadAppears").trigger.send() sc46played = true end end if trigger.received(1,"sc46Done") then npcPointers.mrbones.trigger.send(1,"startMinigame") end if trigger.received(1,"BonesMinigameComplete") then print("BonesMinigameComplete") object("Sc47_UndeadAssemble").trigger.send() end if trigger.received(1,"sc47Done") then sc47Done = true global_variable_set_bool("Ruins_sc47Done",true) SaveGameProgress() end -- state 15 - historian and mr. bones chat about skull mask and undead source if not sc32played and not sc32Done and state == 15 and isThereAPlayer() then sc32played = true print("playing sky_800_moment_10") playMovie("sky_800_moment_10") end if trigger.received(1,"sky_800_moment_10Done") then print("playing Sc32_UndeadKey") object("Sc32_UndeadKey").trigger.send() end --state 16 if not sc33played and not sc33Done and state == 16 and isThereAPlayer() then sc33played = true print("playing Sc33_UndeadReady") object("Sc33_UndeadReady").trigger.send() end --state 17 if not sc34played and not sc34Done and state == 17 and isThereAPlayer() then sc34played = true print("playing sky_800_moment_11") playMovie("sky_800_moment_11") end if trigger.received(1,"sky_800_moment_11Done") then print("playing Sc34_FireTrain") object("Sc34_FireTrain").trigger.send() end --state 18 if not sc36played and not sc36Done and state == 18 and isThereAPlayer() then sc36played = true print("playing sl_sc18") playMovie("sl_sc18") end if trigger.received(1,"sl_sc18Done") then print("playing Sc36_FireReady") object("Sc36_FireReady").trigger.send() end --state 19 if not sc37played and not sc37Done and state == 19 and isThereAPlayer() then sc37played = true print("playing sky_800_moment_13") playMovie("sky_800_moment_13") end if trigger.received(1,"sky_800_moment_13Done") then print("hiding scripted raft") object("Raft_Controller_01").trigger.send(1,"hide") print("playing Sc37_MagicStatue") object("Sc37_MagicStatue").trigger.send() end --state 20 if not sc40played and not sc40Done and state == 20 and isThereAPlayer() then sc40played = true print("playing sky_800_moment_14") playMovie("sky_800_moment_14") end if trigger.received(1,"sky_800_moment_14Done") then print("playing Sc40_MagicReady") object("Sc40_MagicReady").trigger.send() end --state 21 if not sc41played and not sc41Done and state == 21 and isThereAPlayer() then sc41played = true print("playing sl_sc21") playMovie("sl_sc21") end if trigger.received(1,"sl_sc21Done") then print("playing Sc41_FinalReady") object("Sc41_FinalReady").trigger.send() end --state 22 if not sc43played and not sc43Done and state == 22 and isThereAPlayer() then sc43played = true print("playing Sc43_FinalEnd") object("Sc43_FinalEnd").trigger.send() end end function departHandlers() -- Departure Cutscene Handler if trigger.received(1,"nextlevel") then print("nextlevel") local theDepartureCS = departureCinematics[RuinsState.get()] if theDepartureCS then if theDepartureCS == "Sc26_CannonTakeoff" or theDepartureCS == "Sc59_CannonTakeoff2" or theDepartureCS == "Sc60_CannonTakeoff3" then print("moving npcs for cannon takeoff") moveTo ( npcPointers.generalrobot , object("General_Robot_waypoint_301") ) object("Elevator_Lift").delete() end print("playing " .. theDepartureCS) object(theDepartureCS).trigger.send() else print("no departure cinematic found, sending to next level") sendToNextLevel() end end -- Departure Cutscene Ending Handler if trigger.received(1,"departcsend") then if RuinsState.get() == 10 then print("departure ended, state 10, playing sl_sc10") playMovie("sl_sc10") else print("departure ended, sending to next level") sendToNextLevel() end end -- State 10 Outro Movie Handler if trigger.received(1,"sl_sc10Done") then print("sl_sc10 ended, sending to next level") sendToNextLevel() end end