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 = ActionTrigger() |
---|
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(35) |
---|
24 | --triggerFinishEnergyQuest:setDebugDraw(true) |
---|
25 | |
---|
26 | --finish quest Info |
---|
27 | triggerFinishEnergyQuest = SpaceTrigger() |
---|
28 | triggerFinishEnergyQuest:setScript("quest.lua") |
---|
29 | triggerFinishEnergyQuest:setFunction("finishEnergyQuestInfo") |
---|
30 | triggerFinishEnergyQuest:setAbsCoor(346.239166, 482.885010, -160.825775) |
---|
31 | triggerFinishEnergyQuest:setTarget("Player") |
---|
32 | triggerFinishEnergyQuest:setRadius(35) |
---|
33 | --triggerFinishEnergyQuest:setDebugDraw(true) |
---|
34 | |
---|
35 | --HINT Broken station -> find another way |
---|
36 | triggerFinishEnergyQuest = SpaceTrigger() |
---|
37 | triggerFinishEnergyQuest:setScript("quest.lua") |
---|
38 | triggerFinishEnergyQuest:setFunction("hintBrokenStation") |
---|
39 | triggerFinishEnergyQuest:setAbsCoor(192.274033, 221.190002, 63.674793) |
---|
40 | triggerFinishEnergyQuest:setTarget("Player") |
---|
41 | triggerFinishEnergyQuest:setRadius(85) |
---|
42 | --triggerFinishEnergyQuest:setDebugDraw(true) |
---|
43 | |
---|
44 | --HINT find action button |
---|
45 | |
---|
46 | --Tick: HINT need to open the door and stop the player |
---|
47 | trigger = TickTrigger() |
---|
48 | trigger:setScript("quest.lua") |
---|
49 | trigger:setFunction("tick") |
---|
50 | --trigger:setActiveOnCreation(true) |
---|
51 | |
---|
52 | |
---|
53 | --gloabals--------------------------------------------------------------------- |
---|
54 | questEnergyDone = false |
---|
55 | lastPlayerZ = 0 |
---|
56 | lastDoorY = 0 |
---|
57 | doorSequenceTime = 7 --duration time sec |
---|
58 | |
---|
59 | function getEnergyQuest(timestep) |
---|
60 | energyQuest:startGUI() |
---|
61 | return true |
---|
62 | end |
---|
63 | |
---|
64 | function hintBrokenStation(timestep) |
---|
65 | gameWorld:showText("The station seems broken... you need to find another way.") |
---|
66 | return true |
---|
67 | end |
---|
68 | |
---|
69 | function finishEnergyQuest(timestep) |
---|
70 | gameWorld:showText("Good work: the emergency energy system seems to be up again.") |
---|
71 | cameraManager:setCam("CameraDoor") |
---|
72 | cameraManager:changeCurrTarget("NPC", "triggeredDoor") |
---|
73 | |
---|
74 | energyQuest:stopGUI() |
---|
75 | questEnergyDone = true |
---|
76 | return true |
---|
77 | end |
---|
78 | |
---|
79 | function finishEnergyQuestInfo(timestep) |
---|
80 | gameWorld:showText("Hint: you can use the Energyswitch by Pressing U") |
---|
81 | return true |
---|
82 | end |
---|
83 | |
---|
84 | function tick(timestep) |
---|
85 | --io.write("tick called \n") |
---|
86 | if not questEnergyDone then |
---|
87 | if Player:getAbsCoorZ() < -454 then |
---|
88 | --gameWorld:showText("The door can't open without energy."); |
---|
89 | Player:setAbsCoor(Player:getAbsCoorX(),Player:getAbsCoorY(),lastPlayerZ) --set player back |
---|
90 | else |
---|
91 | lastPlayerZ = Player:getAbsCoorZ() --store last position |
---|
92 | end |
---|
93 | else --quest finished |
---|
94 | if doorSequenceTime > 0 then --sequence running |
---|
95 | --triggeredDoor:walkTo(222, 92.5, -472) |
---|
96 | lastDoorY = lastDoorY+92.5/8*timestep |
---|
97 | triggeredDoor:setAbsCoor(triggeredDoor:getAbsCoorX(), lastDoorY, triggeredDoor:getAbsCoorZ()) |
---|
98 | doorSequenceTime = doorSequenceTime - timestep |
---|
99 | else |
---|
100 | --triggeredDoor:setVisibility(false) |
---|
101 | cameraManager:setCam("GameWorldCamera") |
---|
102 | gameWorld:showText("You should hurry as long as there is still energy.") |
---|
103 | return true --quest&sequence finished: kill trigger |
---|
104 | end |
---|
105 | end |
---|
106 | return false |
---|
107 | end |
---|