Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/trunk/scripts/moonstation/intro.lua @ 4896

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

litle lua stuff

File size: 4.0 KB
Line 
1-- Get objects from orxonox
2thisscript:addObject("FPSPlayer", "Player")
3thisscript:addObject("CameraMan", "cameraManager")
4thisscript:addObject("NPC", "IntroSpaceship")
5thisscript:addObjectAsName("GameWorld", "Moon Station", "gameWorld") -- =gameTitle
6
7thisscript:registerClass("Explosion")
8explosion = Explosion()
9
10-- Initialisation
11triggerInit =  TickTrigger() --ScriptTrigger()
12triggerInit:setScript("intro.lua")
13triggerInit:setFunction("startIntro")
14--triggerInit:setActiveOnCreation(true)
15
16-- Camera2MoonstationCenter
17triggerMoonstation = SpaceTrigger()
18triggerMoonstation:setScript("intro.lua")
19triggerMoonstation:setFunction("showMoonstation")
20triggerMoonstation:setAbsCoor(-1253.895386, 727.938721, -268.726807)
21triggerMoonstation:setTarget("CameraIntro")
22triggerMoonstation:setRadius(150)
23--triggerMoonstation:setDebugDraw(true)
24
25-- Camera2Spaceship
26triggerShowCrash = SpaceTrigger()
27triggerShowCrash:setScript("intro.lua")
28triggerShowCrash:setFunction("showCrashingSpaceship")
29triggerShowCrash:setAbsCoor(-158.458618, 543.123169, 541.286926)
30triggerShowCrash:setTarget("CameraIntro")
31triggerShowCrash:setRadius(200)
32--triggerShowCrash:setDebugDraw(true)
33
34-- Explode
35triggerShowCrash = SpaceTrigger()
36triggerShowCrash:setScript("intro.lua")
37triggerShowCrash:setFunction("explodeSpaceship")
38triggerShowCrash:setAbsCoor(840.948486, 175.905289, -175.412460)
39triggerShowCrash:setTarget("IntroSpaceship")
40triggerShowCrash:setRadius(250)
41--triggerShowCrash:setDebugDraw(true)
42
43--hide crashing ship
44triggerShowCrash = SpaceTrigger()
45triggerShowCrash:setScript("intro.lua")
46triggerShowCrash:setFunction("hideCrashingSpaceship")
47triggerShowCrash:setAbsCoor(-100, -400, -110)
48triggerShowCrash:setTarget("IntroSpaceship")
49triggerShowCrash:setRadius(60)
50--triggerShowCrash:setDebugDraw(true)
51
52-- End of Intro
53triggerEndIntro = SpaceTrigger()
54triggerEndIntro:setScript("intro.lua")
55triggerEndIntro:setFunction("stopIntro")
56triggerEndIntro:setAbsCoor(719.431091, 79.719810, -149.023880)
57triggerEndIntro:setTarget("CameraIntro")
58triggerEndIntro:setRadius(110)
59--triggerEndIntro:setDebugDraw(true)
60
61
62-- Functions --------------------------------------------------
63-- globals
64introRunning = false
65spaceshipCrashDelay = 2
66boomSize = 100
67pauseBurn = 0
68exploded = false
69
70-- init function
71function startIntro(timestep)
72        gameWorld:showText("Moon Surface 2102");
73        cameraManager:setCam("CameraIntro")
74        cameraManager:jumpCurrCam(-1295.883301, 621.807922, -969.386780)
75        cameraManager:changeCurrTarget("Planet", "Earth")
76        cameraManager:initFadeBlack()
77        cameraManager:toggleFade()
78       
79        IntroSpaceship:pause(true)
80        --Player:pause(true)
81        introRunning = true
82       
83        return true --just once
84end
85
86function showMoonstation(timestep)
87        cameraManager:changeCurrTarget("Building", "MoonstationCenterHack")
88        return true
89end
90
91function showCrashingSpaceship(timestep)
92        cameraManager:changeCurrTarget("NPC", "IntroSpaceship")
93        spaceshipCrashDelay = spaceshipCrashDelay - timestep
94        if spaceshipCrashDelay<0 then --BUG this is a little hack cause if the target is mooving the camera switch would be imediate
95                IntroSpaceship:pause(false)
96                if pauseBurn==0 then
97                        pauseBurn = 5
98                        explosion:setAbsCoor(IntroSpaceship:getAbsCoorX(),IntroSpaceship:getAbsCoorY(),IntroSpaceship:getAbsCoorZ())
99                        explosion:explode(math.random()*50+50, math.random()*50+50, math.random()*50+50)
100                        if exploded then
101                                cameraManager:changeCurrTarget("ModelEntity", "destroyed fighter")
102                                return true
103                        end
104                else
105                        pauseBurn = pauseBurn - 1
106                end
107                return false
108        end
109        return false
110end
111
112function explodeSpaceship(timestep)
113        --gameWorld:showText("BOOOOOOOOOOOOOOOOM");
114        explosion:setAbsCoor(1003, 226, -102)
115        explosion:explode(boomSize,boomSize,boomSize)
116        boomSize = boomSize + 10
117        if boomSize == 600 then
118                return true
119        end
120        exploded = true
121        return false
122end
123
124function hideCrashingSpaceship(timestep)
125        IntroSpaceship:pause(true)
126        IntroSpaceship:setVisibility(false)
127        return true
128end 
129
130function stopIntro(timestep)
131        cameraManager:setCam("GameWorldCamera")
132        --Player:pause(false)
133        introRunning = false
134        return true
135end
136
Note: See TracBrowser for help on using the repository browser.