Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/trunk/scripts/hangar.lua @ 4218

Last change on this file since 4218 was 4202, checked in by bensch, 18 years ago

merged the data back from scripting

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