Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 4100 was 4100, checked in by snellen, 18 years ago

continued working

File size: 9.4 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")
7thisscript:addObject("GenericNPC", "mechanic2")
8
9-- Global Variables
10playerEnteredSpaceShip = false
11playerReachedTrigger = false
12spaceshipOnPad = false
13spaceshipLaunchReady = false
14
15
16-- Returns the distance between (x1,x2,x3) and (y1,y2,y3)
17function dist( x1,x2,x3, y1,y2,y3 )
18
19return math.sqrt( (x1-y1)^2 + (x2-y2)^2 + (x3-y3)^2 )
20
21end
22
23
24
25function observePlayer()
26
27--playerEnteredSpaceShip = spaceship:hasPlayer()
28
29playerX = Player:getAbsCoorX()
30playerY = Player:getAbsCoorY()
31playerZ = Player:getAbsCoorZ()
32
33if dist( playerX,playerY,playerZ,678.946838, -11.959779, -920.512634 ) < 200 then
34playerReachedTrigger = true
35end
36
37end
38
39
40
41
42
43mprogramRoute = true
44mheight = 5
45function mechanicMove(timestep)
46if mprogramRoute then
47
48mechanic:walkTo( 991.192261, mheight, -1878.394287)
49mechanic:walkTo( 976.976685, mheight, -1879.182129)
50mechanic:walkTo( 963.752625, mheight, -1880.202881)
51mechanic:walkTo( 948.094543, mheight, -1880.980713)
52mechanic:walkTo( 931.008606, mheight, -1880.974854)
53mechanic:walkTo( 917.888428, mheight, -1880.832764)
54mechanic:walkTo( 901.552368, mheight, -1880.655762)
55mechanic:walkTo( 886.475220, mheight, -1880.522949)
56mechanic:walkTo( 872.041504, mheight, -1880.545410)
57mechanic:walkTo( 851.380249, mheight, -1880.577637)
58mechanic:walkTo( 840.637512, mheight, -1880.594238)
59mechanic:walkTo( 828.564941, mheight, -1880.489868)
60mechanic:walkTo( 811.580322, mheight, -1880.085205)
61mechanic:walkTo( 801.953003, mheight, -1880.036377)
62mechanic:walkTo( 784.801086, mheight, -1880.280762)
63mechanic:walkTo( 774.514343, mheight, -1880.380005)
64mechanic:walkTo( 762.351746, mheight, -1880.248779)
65mechanic:walkTo( 750.737549, mheight, -1880.123413)
66mechanic:walkTo( 739.186890, mheight, -1879.999023)
67mechanic:walkTo( 728.210022, mheight, -1879.880371)
68mechanic:walkTo( 717.243835, mheight, -1879.761719)
69mechanic:walkTo( 708.253235, mheight, -1879.649048)
70mechanic:walkTo( 695.825867, mheight, -1877.611938)
71mechanic:walkTo( 687.077820, mheight, -1869.800659)
72mechanic:walkTo( 683.886963, mheight, -1859.888062)
73mechanic:walkTo( 685.589905, mheight, -1844.102051)
74mechanic:walkTo( 686.333069, mheight, -1837.212524)
75mechanic:walkTo( 687.256042, mheight, -1828.656860)
76mechanic:walkTo( 688.759583, mheight, -1820.024048)
77mechanic:walkTo( 690.621216, mheight, -1809.834595)
78mechanic:walkTo( 692.045593, mheight, -1803.566772)
79mechanic:walkTo( 695.021851, mheight, -1795.320923)
80mechanic:walkTo( 703.956360, mheight, -1789.028931)
81mechanic:walkTo( 711.400574, mheight, -1785.378418)
82mechanic:walkTo( 720.236267, mheight, -1782.750977)
83mechanic:walkTo( 741.346130, mheight, -1786.131836)
84mechanic:walkTo( 744.505798, mheight, -1788.214111)
85mechanic:walkTo( 753.788513, mheight, -1796.320557)
86mechanic:walkTo( 760.480408, mheight, -1804.107788)
87mechanic:walkTo( 765.918274, mheight, -1811.952393)
88mechanic:walkTo( 772.114990, mheight, -1823.565674)
89mechanic:walkTo( 776.130737, mheight, -1830.713989)
90mechanic:walkTo( 781.833313, mheight, -1836.770996)
91mechanic:walkTo( 796.051880, mheight, -1843.499512)
92mechanic:walkTo( 805.178101, mheight, -1844.844116)
93mechanic:walkTo( 816.733154, mheight, -1846.198608)
94mechanic:walkTo( 830.296326, mheight, -1844.374146)
95mechanic:walkTo( 841.234680, mheight, -1841.184814)
96mechanic:walkTo( 853.356201, mheight, -1837.650391)
97mechanic:walkTo( 866.242981, mheight, -1833.892944)
98mechanic:walkTo( 877.006836, mheight, -1830.820923)
99mechanic:walkTo( 889.236816, mheight, -1828.092773)
100mechanic:walkTo( 897.856689, mheight, -1826.204346)
101mechanic:walkTo( 909.685486, mheight, -1823.613037)
102mechanic:walkTo( 922.058777, mheight, -1819.907227)
103mechanic:walkTo( 933.861328, mheight, -1814.044800)
104mechanic:walkTo( 943.290588, mheight, -1809.960205)
105mechanic:walkTo( 952.188293, mheight, -1806.317261)
106mechanic:walkTo( 985.450745, mheight, -1800.297729)
107mechanic:walkTo( 1000.339722, mheight, -1800.916626)
108mechanic:walkTo( 1013.447937, mheight, -1802.642090)
109mechanic:walkTo( 1022.703430, mheight, -1808.694946)
110mechanic:walkTo( 1030.242554, mheight, -1821.859253)
111mechanic:walkTo( 1030.063354, mheight, -1839.935547)
112mechanic:walkTo( 1025.804932, mheight, -1864.135986)
113mechanic:walkTo( 1019.079651, mheight, -1878.196777)
114
115mprogramRoute = false
116end
117
118if mechanic:finalGoalReached() then
119mprogramRoute = true
120end
121
122end
123
124mtprogramRoute = true
125mtheight = 5
126waittime = 0
127waiting = false
128function mechanictMove(timestep)
129if mtprogramRoute then
130mechanic2:walkTo( 1564.473999, mtheight, -1923.821533)
131mechanic2:walkTo( 1556.049927, mtheight, -1916.359009)
132mechanic2:walkTo( 1550.970581, mtheight, -1913.087524)
133mechanic2:walkTo( 1542.345459, mtheight, -1912.611938)
134mechanic2:walkTo( 1534.643677, mtheight, -1912.361816)
135mechanic2:walkTo( 1524.490845, mtheight, -1912.074097)
136mechanic2:walkTo( 1516.120605, mtheight, -1912.511475)
137mechanic2:walkTo( 1508.607788, mtheight, -1912.904175)
138mechanic2:walkTo( 1498.452759, mtheight, -1913.434814)
139mechanic2:walkTo( 1492.513916, mtheight, -1913.744995)
140mechanic2:walkTo( 1483.056274, mtheight, -1914.239136)
141mechanic2:walkTo( 1471.428711, mtheight, -1916.435303)
142mechanic2:walkTo( 1460.068359, mtheight, -1916.473022)
143mechanic2:walkTo( 1451.006592, mtheight, -1913.691772)
144mechanic2:walkTo( 1444.585938, mtheight, -1911.533691)
145mechanic2:walkTo( 1439.008423, mtheight, -1909.659058)
146mechanic2:walkTo( 1421.636230, mtheight, -1915.466553)
147mechanic2:walkTo( 1420.582275, mtheight, -1926.693970)
148mechanic2:walkTo( 1422.506714, mtheight, -1934.938232)
149mechanic2:walkTo( 1430.749023, mtheight, -1942.431519)
150mechanic2:walkTo( 1440.773315, mtheight, -1948.152832)
151mechanic2:walkTo( 1452.532227, mtheight, -1950.169800)
152mechanic2:walkTo( 1465.584961, mtheight, -1949.407959)
153mechanic2:walkTo( 1475.635254, mtheight, -1948.756226)
154mechanic2:walkTo( 1481.961548, mtheight, -1948.346069)
155mechanic2:walkTo( 1495.564575, mtheight, -1947.588257)
156mechanic2:walkTo( 1505.660156, mtheight, -1947.679077)
157mechanic2:walkTo( 1514.055542, mtheight, -1947.901245)
158mechanic2:walkTo( 1523.532959, mtheight, -1948.351440)
159mechanic2:walkTo( 1537.855347, mtheight, -1949.461914)
160mechanic2:walkTo( 1545.510498, mtheight, -1950.162720)
161mechanic2:walkTo( 1553.132935, mtheight, -1950.860718)
162mechanic2:walkTo( 1556.371460, mtheight, -1951.157104)
163mechanic2:walkTo( 1563.450806, mtheight, -1951.804932)
164mechanic2:walkTo( 1572.594116, mtheight, -1952.320679)
165mechanic2:walkTo( 1582.691772, mtheight, -1950.470459)
166mechanic2:walkTo( 1589.872681, mtheight, -1929.683105)
167mechanic2:walkTo( 1587.794922, mtheight, -1922.749756)
168mechanic2:walkTo( 1582.800171, mtheight, -1917.671021)
169mechanic2:walkTo( 1573.449951, mtheight, -1915.750854)
170mechanic2:walkTo( 1564.055908, mtheight, -1914.986328)
171mtprogramRoute = false
172end
173
174mechanic2X = mechanic2:getAbsCoorX()
175mechanic2Y = mechanic2:getAbsCoorY()
176mechanic2Z = mechanic2:getAbsCoorZ()
177
178if dist(mechanic2X,mechanic2Y,mechanic2Z,1435.444824, mtheight, -1916.463013) < 10 and not waiting then
179mechanic2:stop()
180waittime = 5
181--io.write("mechanic2 stoped \n")
182waiting = true
183end
184
185if waittime >= 0 and waiting then
186waittime = waittime - timestep
187--io.write(waittime,"\n")
188if waittime < 0 then
189--io.write("mechanic2 finished waiting\n")
190mechanic2:resume()
191end
192end
193
194if dist(mechanic2X,mechanic2Y,mechanic2Z,1564.473999, mtheight, -1923.821533) < 10 and waiting then
195waiting = false
196end
197
198
199if mechanic2:finalGoalReached() then
200mtprogramRoute = true
201end
202
203end
204
205
206
207
208
209
210
211
212positionReached = false
213spaceShipReleased = false
214function moveToLaunchSite(timestep)
215
216if not positionReached then
217dx = 10 * timestep
218dy = 0 * timestep
219dz = 0* timestep
220end
221
222if not spaceShipReleased and positionReached then 
223dx = 0 * timestep
224dy = 10 * timestep
225dz = 0 * timestep
226end
227
228if positionReached and spaceShipReleased then
229dx = 0 * timestep
230dy = 1 * timestep
231dz = 0 * timestep
232end
233
234
235if spaceshipOnPad then
236
237if not spaceShipReleased then
238--spaceshipclaw:playAnimation(1,1)
239--io.write("release spaceship\n")
240spaceShipReleased = true
241playerEnteredSpaceShip = true
242end
243
244--if clawY > 100 then
245spaceshipLaunchReady = true
246--end
247
248end
249
250
251-- set new coordinates
252--clawX = claw:getAbsCoorX()
253--clawY = claw:getAbsCoorY()
254--clawZ = claw:getAbsCoorZ()
255
256--claw:setAbsCoor(clawX + dx, clawY + dy, clawZ + dz)
257spaceshipX = spaceship:getAbsCoorX()
258spaceshipY = spaceship:getAbsCoorY()
259spaceshipZ = spaceship:getAbsCoorZ()
260
261spaceship:setAbsCoor(spaceshipX + dx, spaceshipY + dy, spaceshipZ + dz)
262
263
264
265--if dist( clawX,clawY,clawZ,1020.025024, -11.959781, -1721.614380 ) < 60 then
266if dist( spaceshipX,spaceshipY,spaceshipZ,1020.025024, -11.959781, -1721.614380 ) < 60 then
267positionReached = true
268end
269
270
271--if dist( clawX,clawY,clawZ,167.361526,29,483.163818 ) < 60 then
272if  spaceshipY > 10 then
273spaceshipOnPad = true
274end
275
276
277end
278
279hoverPosReached = false
280function launchSpaceShip(timestep)
281
282if not hoverPosReached then
283dx = 0 * timestep
284dy = 1 * timestep
285dz = 0 * timestep
286else
287dx = 200 * timestep
288dy = 0 * timestep
289dz = 0 * timestep
290end
291
292spaceshipX = spaceship:getAbsCoorX()
293spaceshipY = spaceship:getAbsCoorY()
294spaceshipZ = spaceship:getAbsCoorZ()
295
296spaceship:setAbsCoor(spaceshipX + dx, spaceshipY + dy, spaceshipZ + dz)
297
298if spaceshipY > 15 then
299hoverPosReached = true
300end
301
302end
303
304
305function tick(timestep)
306
307observePlayer()
308mechanicMove(timestep)
309mechanictMove(timestep)
310
311if playerReachedTrigger and not spaceshipLaunchReady then
312moveToLaunchSite(timestep)
313end
314
315if spaceshipLaunchReady then
316launchSpaceShip(timestep)
317end
318
319
320return false
321end
Note: See TracBrowser for help on using the repository browser.