Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

added subground level, intro script explosion, questfix, vis, levelswitch

File size: 3.7 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 find action button
45
46--Tick: HINT need to open the door and stop the player
47trigger = TickTrigger()
48trigger:setScript("quest.lua")
49trigger:setFunction("tick")
50--trigger:setActiveOnCreation(true)
51
52
53--gloabals---------------------------------------------------------------------
54questEnergyDone = false
55lastPlayerZ = 0
56lastDoorY = 0
57doorSequenceTime = 7 --duration time sec
58
59function getEnergyQuest(timestep)
60        energyQuest:startGUI()
61        return true
62end
63
64function hintBrokenStation(timestep)
65        gameWorld:showText("The station seems broken... you    need to find another way.")
66        return true
67end
68
69function 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
77end
78
79function finishEnergyQuestInfo(timestep)
80        gameWorld:showText("Hint: you can use the Energyswitch by Pressing U")
81        return true
82end
83
84function 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
107end
Note: See TracBrowser for help on using the repository browser.