Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 4864 was 4850, checked in by vkaenemi, 18 years ago

Moonstation level inc intro

File size: 3.2 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)
15triggerGetEnergyQuest:setDebugDraw(true)
16
17--activate energy - finish energyQuest
18triggerFinishEnergyQuest = SpaceTrigger()
19triggerFinishEnergyQuest:setScript("quest.lua")
20triggerFinishEnergyQuest:setFunction("finishEnergyQuest")
21triggerFinishEnergyQuest:setAbsCoor(346.239166, 482.885010, -160.825775)
22triggerFinishEnergyQuest:setTarget("Player")
23triggerFinishEnergyQuest:setRadius(30)
24triggerFinishEnergyQuest:setDebugDraw(true)
25
26--HINT Broken station -> find another way
27triggerFinishEnergyQuest = SpaceTrigger()
28triggerFinishEnergyQuest:setScript("quest.lua")
29triggerFinishEnergyQuest:setFunction("hintBrokenStation")
30triggerFinishEnergyQuest:setAbsCoor(192.274033, 221.190002, 63.674793)
31triggerFinishEnergyQuest:setTarget("Player")
32triggerFinishEnergyQuest:setRadius(85)
33triggerFinishEnergyQuest:setDebugDraw(true)
34
35--HINT find action button
36
37--Tick: HINT need to open the door and stop the player
38trigger = TickTrigger()
39trigger:setScript("quest.lua")
40trigger:setFunction("tick")
41--trigger:setActiveOnCreation(true)
42
43
44--gloabals---------------------------------------------------------------------
45questEnergyDone = false
46lastPlayerZ = 0
47lastDoorY = 0
48doorSequenceTime = 7 --duration time sec
49
50function getEnergyQuest(timestep)
51        energyQuest:startGUI()
52        return true
53end
54
55function hintBrokenStation(timestep)
56        gameWorld:showText("The station seems broken... you    need to find another way.")
57        return true
58end
59
60function 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
68end
69
70function 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
93end
Note: See TracBrowser for help on using the repository browser.