Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/trunk/scripts/moonstation/quest.lua @ 4889

Last change on this file since 4889 was 4889, checked in by vkaenemi, 17 years ago

2 turrets

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