Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/branches/presentation/scripts/hangar.lua @ 4091

Last change on this file since 4091 was 4080, checked in by bensch, 18 years ago

orxonox/data/trunk: merged the single_player_map back.
merged with command:
svn merge https://svn.orxonox.net/data/branches/single_player_map . -r624:HEAD
no conflicts, that mattered (all merged to the favour of the branche)

File size: 6.3 KB
Line 
1-- Get objects from orxonox
2thisscript:addObject("Claw", "spaceshipclaw")
3thisscript:addObject("RepairStation", "repair")
4thisscript:addObject("FPSPlayer", "Player")
5thisscript:addObject("SpaceShip", "spaceship")
6thisscript:addObject("GenericNPC", "mechanic")
7
8-- Global Variables
9playerEnteredSpaceShip = false
10playerReachedTrigger = false
11spaceshipOnPad = false
12spaceshipLaunchReady = false
13
14
15-- Returns the distance between (x1,x2,x3) and (y1,y2,y3)
16function dist( x1,x2,x3, y1,y2,y3 )
17
18return math.sqrt( (x1-y1)^2 + (x2-y2)^2 + (x3-y3)^2 )
19
20end
21
22
23
24function observePlayer()
25
26--playerEnteredSpaceShip = spaceship:hasPlayer()
27
28playerX = Player:getAbsCoorX()
29playerY = Player:getAbsCoorY()
30playerZ = Player:getAbsCoorZ()
31
32if dist( playerX,playerY,playerZ,678.946838, -11.959779, -920.512634 ) < 200 then
33playerReachedTrigger = true
34end
35
36end
37
38
39
40
41
42programRoute = true
43mheight = 5
44function mechanicMove(timestep)
45if programRoute then
46
47mechanic:walkTo( 991.192261, mheight, -1878.394287)
48mechanic:walkTo( 976.976685, mheight, -1879.182129)
49mechanic:walkTo( 963.752625, mheight, -1880.202881)
50mechanic:walkTo( 948.094543, mheight, -1880.980713)
51mechanic:walkTo( 931.008606, mheight, -1880.974854)
52mechanic:walkTo( 917.888428, mheight, -1880.832764)
53mechanic:walkTo( 901.552368, mheight, -1880.655762)
54mechanic:walkTo( 886.475220, mheight, -1880.522949)
55mechanic:walkTo( 872.041504, mheight, -1880.545410)
56mechanic:walkTo( 851.380249, mheight, -1880.577637)
57mechanic:walkTo( 840.637512, mheight, -1880.594238)
58mechanic:walkTo( 828.564941, mheight, -1880.489868)
59mechanic:walkTo( 811.580322, mheight, -1880.085205)
60mechanic:walkTo( 801.953003, mheight, -1880.036377)
61mechanic:walkTo( 784.801086, mheight, -1880.280762)
62mechanic:walkTo( 774.514343, mheight, -1880.380005)
63mechanic:walkTo( 762.351746, mheight, -1880.248779)
64mechanic:walkTo( 750.737549, mheight, -1880.123413)
65mechanic:walkTo( 739.186890, mheight, -1879.999023)
66mechanic:walkTo( 728.210022, mheight, -1879.880371)
67mechanic:walkTo( 717.243835, mheight, -1879.761719)
68mechanic:walkTo( 708.253235, mheight, -1879.649048)
69mechanic:walkTo( 695.825867, mheight, -1877.611938)
70mechanic:walkTo( 687.077820, mheight, -1869.800659)
71mechanic:walkTo( 683.886963, mheight, -1859.888062)
72mechanic:walkTo( 685.589905, mheight, -1844.102051)
73mechanic:walkTo( 686.333069, mheight, -1837.212524)
74mechanic:walkTo( 687.256042, mheight, -1828.656860)
75mechanic:walkTo( 688.759583, mheight, -1820.024048)
76mechanic:walkTo( 690.621216, mheight, -1809.834595)
77mechanic:walkTo( 692.045593, mheight, -1803.566772)
78mechanic:walkTo( 695.021851, mheight, -1795.320923)
79mechanic:walkTo( 703.956360, mheight, -1789.028931)
80mechanic:walkTo( 711.400574, mheight, -1785.378418)
81mechanic:walkTo( 720.236267, mheight, -1782.750977)
82mechanic:walkTo( 741.346130, mheight, -1786.131836)
83mechanic:walkTo( 744.505798, mheight, -1788.214111)
84mechanic:walkTo( 753.788513, mheight, -1796.320557)
85mechanic:walkTo( 760.480408, mheight, -1804.107788)
86mechanic:walkTo( 765.918274, mheight, -1811.952393)
87mechanic:walkTo( 772.114990, mheight, -1823.565674)
88mechanic:walkTo( 776.130737, mheight, -1830.713989)
89mechanic:walkTo( 781.833313, mheight, -1836.770996)
90mechanic:walkTo( 796.051880, mheight, -1843.499512)
91mechanic:walkTo( 805.178101, mheight, -1844.844116)
92mechanic:walkTo( 816.733154, mheight, -1846.198608)
93mechanic:walkTo( 830.296326, mheight, -1844.374146)
94mechanic:walkTo( 841.234680, mheight, -1841.184814)
95mechanic:walkTo( 853.356201, mheight, -1837.650391)
96mechanic:walkTo( 866.242981, mheight, -1833.892944)
97mechanic:walkTo( 877.006836, mheight, -1830.820923)
98mechanic:walkTo( 889.236816, mheight, -1828.092773)
99mechanic:walkTo( 897.856689, mheight, -1826.204346)
100mechanic:walkTo( 909.685486, mheight, -1823.613037)
101mechanic:walkTo( 922.058777, mheight, -1819.907227)
102mechanic:walkTo( 933.861328, mheight, -1814.044800)
103mechanic:walkTo( 943.290588, mheight, -1809.960205)
104mechanic:walkTo( 952.188293, mheight, -1806.317261)
105mechanic:walkTo( 985.450745, mheight, -1800.297729)
106mechanic:walkTo( 1000.339722, mheight, -1800.916626)
107mechanic:walkTo( 1013.447937, mheight, -1802.642090)
108mechanic:walkTo( 1022.703430, mheight, -1808.694946)
109mechanic:walkTo( 1030.242554, mheight, -1821.859253)
110mechanic:walkTo( 1030.063354, mheight, -1839.935547)
111mechanic:walkTo( 1025.804932, mheight, -1864.135986)
112mechanic:walkTo( 1019.079651, mheight, -1878.196777)
113
114programRoute = false
115end
116
117if mechanic:finalGoalReached() then
118programRoute = true
119end
120
121end
122
123
124
125
126
127
128
129
130
131positionReached = false
132spaceShipReleased = false
133function moveToLaunchSite(timestep)
134
135if not positionReached then
136dx = 10 * timestep
137dy = 0 * timestep
138dz = 0* timestep
139end
140
141if not spaceShipReleased and positionReached then 
142dx = 0 * timestep
143dy = 10 * timestep
144dz = 0 * timestep
145end
146
147if positionReached and spaceShipReleased then
148dx = 0 * timestep
149dy = 1 * timestep
150dz = 0 * timestep
151end
152
153
154if spaceshipOnPad then
155
156if not spaceShipReleased then
157--spaceshipclaw:playAnimation(1,1)
158io.write("release spaceship\n")
159spaceShipReleased = true
160playerEnteredSpaceShip = true
161end
162
163--if clawY > 100 then
164spaceshipLaunchReady = true
165--end
166
167end
168
169
170-- set new coordinates
171--clawX = claw:getAbsCoorX()
172--clawY = claw:getAbsCoorY()
173--clawZ = claw:getAbsCoorZ()
174
175--claw:setAbsCoor(clawX + dx, clawY + dy, clawZ + dz)
176spaceshipX = spaceship:getAbsCoorX()
177spaceshipY = spaceship:getAbsCoorY()
178spaceshipZ = spaceship:getAbsCoorZ()
179
180spaceship:setAbsCoor(spaceshipX + dx, spaceshipY + dy, spaceshipZ + dz)
181
182
183
184--if dist( clawX,clawY,clawZ,1020.025024, -11.959781, -1721.614380 ) < 60 then
185if dist( spaceshipX,spaceshipY,spaceshipZ,1020.025024, -11.959781, -1721.614380 ) < 60 then
186positionReached = true
187end
188
189
190--if dist( clawX,clawY,clawZ,167.361526,29,483.163818 ) < 60 then
191if  spaceshipY > 10 then
192spaceshipOnPad = true
193end
194
195
196end
197
198hoverPosReached = false
199function launchSpaceShip(timestep)
200
201if not hoverPosReached then
202dx = 0 * timestep
203dy = 1 * timestep
204dz = 0 * timestep
205else
206dx = 200 * timestep
207dy = 0 * timestep
208dz = 0 * timestep
209end
210
211spaceshipX = spaceship:getAbsCoorX()
212spaceshipY = spaceship:getAbsCoorY()
213spaceshipZ = spaceship:getAbsCoorZ()
214
215spaceship:setAbsCoor(spaceshipX + dx, spaceshipY + dy, spaceshipZ + dz)
216
217if spaceshipY > 15 then
218hoverPosReached = true
219end
220
221end
222
223
224function tick(timestep)
225
226observePlayer()
227mechanicMove(timestep)
228
229if playerReachedTrigger and not spaceshipLaunchReady then
230moveToLaunchSite(timestep)
231end
232
233if spaceshipLaunchReady then
234launchSpaceShip(timestep)
235end
236
237
238return false
239end
Note: See TracBrowser for help on using the repository browser.