[4850] | 1 | -- Get objects from orxonox |
---|
| 2 | thisscript:addObject("FPSPlayer", "Player") |
---|
| 3 | thisscript:addObject("CameraMan", "cameraManager") |
---|
| 4 | thisscript:addObject("QuestGUI", "energyQuest") |
---|
| 5 | thisscript:addObject("NPC", "triggeredDoor") |
---|
| 6 | thisscript:addObjectAsName("GameWorld", "Moon Station", "gameWorld") -- =gameTitle |
---|
| 7 | |
---|
| 8 | --get first Quest |
---|
| 9 | triggerGetEnergyQuest = SpaceTrigger() --ScriptTrigger() |
---|
| 10 | triggerGetEnergyQuest:setScript("quest.lua") |
---|
| 11 | triggerGetEnergyQuest:setFunction("getEnergyQuest") |
---|
| 12 | triggerGetEnergyQuest:setAbsCoor(229.492569, 38.417606, -363.788483) |
---|
| 13 | triggerGetEnergyQuest:setTarget("Player") |
---|
| 14 | triggerGetEnergyQuest:setRadius(160) |
---|
| 15 | triggerGetEnergyQuest:setDebugDraw(true) |
---|
| 16 | |
---|
| 17 | --activate energy - finish energyQuest |
---|
| 18 | triggerFinishEnergyQuest = SpaceTrigger() |
---|
| 19 | triggerFinishEnergyQuest:setScript("quest.lua") |
---|
| 20 | triggerFinishEnergyQuest:setFunction("finishEnergyQuest") |
---|
| 21 | triggerFinishEnergyQuest:setAbsCoor(346.239166, 482.885010, -160.825775) |
---|
| 22 | triggerFinishEnergyQuest:setTarget("Player") |
---|
| 23 | triggerFinishEnergyQuest:setRadius(30) |
---|
| 24 | triggerFinishEnergyQuest:setDebugDraw(true) |
---|
| 25 | |
---|
| 26 | --HINT Broken station -> find another way |
---|
| 27 | triggerFinishEnergyQuest = SpaceTrigger() |
---|
| 28 | triggerFinishEnergyQuest:setScript("quest.lua") |
---|
| 29 | triggerFinishEnergyQuest:setFunction("hintBrokenStation") |
---|
| 30 | triggerFinishEnergyQuest:setAbsCoor(192.274033, 221.190002, 63.674793) |
---|
| 31 | triggerFinishEnergyQuest:setTarget("Player") |
---|
| 32 | triggerFinishEnergyQuest:setRadius(85) |
---|
| 33 | triggerFinishEnergyQuest:setDebugDraw(true) |
---|
| 34 | |
---|
| 35 | --HINT find action button |
---|
| 36 | |
---|
| 37 | --Tick: HINT need to open the door and stop the player |
---|
| 38 | trigger = TickTrigger() |
---|
| 39 | trigger:setScript("quest.lua") |
---|
| 40 | trigger:setFunction("tick") |
---|
| 41 | --trigger:setActiveOnCreation(true) |
---|
| 42 | |
---|
| 43 | |
---|
| 44 | --gloabals--------------------------------------------------------------------- |
---|
| 45 | questEnergyDone = false |
---|
| 46 | lastPlayerZ = 0 |
---|
| 47 | lastDoorY = 0 |
---|
| 48 | doorSequenceTime = 7 --duration time sec |
---|
| 49 | |
---|
| 50 | function getEnergyQuest(timestep) |
---|
| 51 | energyQuest:startGUI() |
---|
| 52 | return true |
---|
| 53 | end |
---|
| 54 | |
---|
| 55 | function hintBrokenStation(timestep) |
---|
| 56 | gameWorld:showText("The station seems broken... you need to find another way.") |
---|
| 57 | return true |
---|
| 58 | end |
---|
| 59 | |
---|
| 60 | function finishEnergyQuest(timestep) |
---|
| 61 | gameWorld:showText("Good work: the emergency energy system seems to be up again.") |
---|
| 62 | cameraManager:setCam("CameraDoor") |
---|
| 63 | cameraManager:changeCurrTarget("NPC", "triggeredDoor") |
---|
| 64 | |
---|
| 65 | energyQuest:stopGUI() |
---|
| 66 | questEnergyDone = true |
---|
| 67 | return true |
---|
| 68 | end |
---|
| 69 | |
---|
| 70 | function tick(timestep) |
---|
| 71 | --io.write("tick called \n") |
---|
| 72 | if not questEnergyDone then |
---|
| 73 | if Player:getAbsCoorZ() < -454 then |
---|
| 74 | --gameWorld:showText("The door can't open without energy."); |
---|
| 75 | Player:setAbsCoor(Player:getAbsCoorX(),Player:getAbsCoorY(),lastPlayerZ) --set player back |
---|
| 76 | else |
---|
| 77 | lastPlayerZ = Player:getAbsCoorZ() --store last position |
---|
| 78 | end |
---|
| 79 | else --quest finished |
---|
| 80 | if doorSequenceTime > 0 then --sequence running |
---|
| 81 | --triggeredDoor:walkTo(222, 92.5, -472) |
---|
| 82 | lastDoorY = lastDoorY+92.5/8*timestep |
---|
| 83 | triggeredDoor:setAbsCoor(triggeredDoor:getAbsCoorX(), lastDoorY, triggeredDoor:getAbsCoorZ()) |
---|
| 84 | doorSequenceTime = doorSequenceTime - timestep |
---|
| 85 | else |
---|
| 86 | --triggeredDoor:setVisibility(false) |
---|
| 87 | cameraManager:setCam("GameWorldCamera") |
---|
| 88 | gameWorld:showText("You should hurry as long as there is still energy.") |
---|
| 89 | return true --quest&sequence finished: kill trigger |
---|
| 90 | end |
---|
| 91 | end |
---|
| 92 | return false |
---|
| 93 | end |
---|