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 = 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 = ScriptTrigger() |
---|
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 | |
---|
28 | --HINT find action button |
---|
29 | |
---|
30 | --Tick: HINT need to open the door and stop the player |
---|
31 | trigger = ScriptTrigger() |
---|
32 | trigger:setName("doorClosedTick") |
---|
33 | trigger:setScript("quest.lua") |
---|
34 | trigger:setFunction("tick") |
---|
35 | trigger:setActiveOnCreation(true) |
---|
36 | |
---|
37 | |
---|
38 | --gloabals--------------------------------------------------------------------- |
---|
39 | questEnergyDone = false |
---|
40 | lastPlayerZ = 0 |
---|
41 | lastDoorY = 47.2 |
---|
42 | doorSequenceTime = 7 --duration time sec |
---|
43 | |
---|
44 | function getEnergyQuest(timestep) |
---|
45 | energyQuest:startGUI() |
---|
46 | return true |
---|
47 | end |
---|
48 | |
---|
49 | function finishEnergyQuest(timestep) |
---|
50 | gameWorld:showText("Good work: the emergency energy system seems to be up again.") |
---|
51 | cameraManager:setCam("CameraDoor") |
---|
52 | cameraManager:changeCurrTarget("NPC", "triggeredDoor") |
---|
53 | |
---|
54 | energyQuest:stopGUI() |
---|
55 | questEnergyDone = true |
---|
56 | return true |
---|
57 | end |
---|
58 | |
---|
59 | function tick(timestep) |
---|
60 | --io.write("tick called \n") |
---|
61 | if not questEnergyDone then |
---|
62 | if Player:getAbsCoorZ() < -454 then |
---|
63 | --gameWorld:showText("The door can't open without energy."); |
---|
64 | Player:setAbsCoor(Player:getAbsCoorX(),Player:getAbsCoorY(),lastPlayerZ) --set player back |
---|
65 | else |
---|
66 | lastPlayerZ = Player:getAbsCoorZ() --store last position |
---|
67 | end |
---|
68 | else --quest finished |
---|
69 | if doorSequenceTime > 0 then --sequence running |
---|
70 | --triggeredDoor:walkTo(222, 47.2+92.5, -472) |
---|
71 | --lastDoorY = lastDoorY+92.5/7*timestep |
---|
72 | --triggeredDoor:setAbsDir(0,0,1,0) |
---|
73 | --triggeredDoor:setAbsDir(triggeredDoor:getAbsCoorX(), lastDoorY, triggeredDoor:getAbsCoorZ()) --BUG |
---|
74 | triggeredDoor:setVisibility(false) |
---|
75 | io.write("visibility off \n") |
---|
76 | doorSequenceTime = doorSequenceTime - timestep |
---|
77 | else |
---|
78 | cameraManager:setCam("GameWorldCamera") |
---|
79 | gameWorld:showText("You should hurry as long as there is still energy.") |
---|
80 | return true --quest&sequence finished: kill trigger |
---|
81 | end |
---|
82 | end |
---|
83 | return false |
---|
84 | end |
---|