Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/branches/single_player_map/scripts/prisoner.lua @ 4068

Last change on this file since 4068 was 4068, checked in by snellen, 19 years ago

continued

File size: 9.9 KB
Line 
1-- Get objects from orxonox
2thisscript:addObject("GenericNPC", "prisoner")
3thisscript:addObject("FPSPlayer", "Player")
4thisscript:addObject("GenericNPC", "secondguard")
5thisscript:addObject("GenericNPC","guard")
6
7
8cellDoorOpened = false
9walkinCellFinished = false
10cellExitReached = false
11exitReached = false
12hangarReached = false
13spaceShipReached = false
14spaceShipEntered = false
15playerInLock = false
16guardStopped = false
17
18randTime = 0
19height = 29
20
21
22function dist( x1,x2,x3, y1,y2,y3 )
23
24return math.sqrt( (x1-y1)^2 + (x2-y2)^2 + (x3-y3)^2 )
25
26end
27
28function observeGuard()
29guardX = secondguard:getAbsCoorX()
30guardY = secondguard:getAbsCoorY()
31guardZ = secondguard:getAbsCoorZ()
32
33if dist( guardX,guardY,guardZ, 43.406876, 29, 179.517303) < 60 then
34cellDoorOpened = true
35end
36
37end
38
39function observePlayer()
40playerX = Player:getAbsCoorX()
41playerY = Player:getAbsCoorY()
42playerZ = Player:getAbsCoorZ()
43
44
45guardX = guard:getAbsCoorX()
46guardY = guard:getAbsCoorY()
47guardZ = guard:getAbsCoorZ()
48
49
50if dist( playerX,playerY,playerZ,161.76,49,358.87 ) < 60 then
51playerInLock = true
52end
53
54
55if dist( guardX,guardY,guardZ,playerX, playerY, playerZ) > 150 and hangarProgrammed then
56 prisoner:stop()
57 guardStopped = true
58end
59
60if dist( guardX,guardY,guardZ,playerX, playerY, playerZ) < 150 and hangarProgrammed and guardStopped then
61 prisoner:resume()
62 guardStopped = false
63end
64
65end
66
67walkProgrammed = false
68exitProgrammed = false
69function walkInCell(timestep)
70
71
72if not walkProgrammed then
73prisoner:walkTo( -66.454849, height, 62.363449)
74prisoner:walkTo( -66.454849, height, 62.363449)
75prisoner:walkTo( -63.214821, height, 62.429710)
76prisoner:walkTo( -56.661182, height, 62.563740)
77prisoner:walkTo( -46.779755, height, 62.765827)
78prisoner:walkTo( -41.634224, height, 71.319214)
79prisoner:walkTo( -38.168526, height, 79.655807)
80prisoner:walkTo( -40.782196, height, 101.285233)
81prisoner:walkTo( -47.722874, height, 114.314980)
82prisoner:walkTo( -54.593349, height, 118.605423)
83prisoner:walkTo( -62.802982, height, 117.947144)
84prisoner:walkTo( -73.180130, height, 116.720863)
85prisoner:walkTo( -85.028603, height, 114.952316)
86prisoner:walkTo( -113.125824, height, 96.362946)
87prisoner:walkTo( -118.218887, height, 87.702599)
88prisoner:walkTo( -120.596275, height, 80.304184)
89prisoner:walkTo( -114.928169, height, 68.971840)
90prisoner:walkTo( -108.606766, height, 62.085098)
91prisoner:walkTo( -90.078171, height, 59.558804)
92prisoner:walkTo( -83.558510, height, 60.516567)
93prisoner:walkTo( -71.352402, height, 63.920750)
94walkProgrammed = true
95end
96
97
98if prisoner:finalGoalReached() and not cellDoorOpened then
99 walkProgrammed = false
100end
101
102
103if cellDoorOpened then
104
105  if not exitProgrammed then
106prisoner:walkTo( -61.875267, height, 158.254517)
107prisoner:walkTo( -62.335995, height, 170.318756)
108prisoner:walkTo( -62.358681, height, 179.232559)
109prisoner:walkTo( -55.998741, height, 189.289749)
110prisoner:walkTo( -49.237957, height, 195.076263)
111prisoner:walkTo( -39.007496, height, 195.889221)
112prisoner:walkTo( -24.234095, height, 195.547043)
113prisoner:walkTo( -11.409116, height, 196.236069)
114prisoner:walkTo( 2.545602, height, 196.805954)
115prisoner:walkTo( 13.875313, height, 196.377563)
116prisoner:walkTo( 28.379402, height, 195.829132)
117prisoner:walkTo( 41.672989, height, 195.326477)
118prisoner:walkTo( 57.125935, height, 194.742126)
119prisoner:walkTo( 70.114609, height, 194.251007)
120prisoner:walkTo( 81.857407, height, 193.806961)
121prisoner:walkTo( 97.840607, height, 193.974030)
122prisoner:walkTo( 107.569641, height, 196.299652)
123prisoner:walkTo( 120.975266, height, 202.754532)
124prisoner:walkTo( 129.063812, height, 207.099640)
125prisoner:walkTo( 140.468765, height, 214.389191)
126prisoner:walkTo( 145.902267, height, 224.194229)
127prisoner:walkTo( 148.106079, height, 233.095215)
128prisoner:walkTo( 150.907532, height, 244.410049)
129prisoner:walkTo( 153.191757, height, 253.635788)
130prisoner:walkTo( 153.191757, height, 253.635788)
131   exitProgrammed = true
132  end
133
134  if prisoner:finalGoalReached() then
135   return true
136  end
137
138end 
139
140return false
141
142end
143
144
145hangarRouteProgrammed = false
146function goToHangar(timestep)
147
148if not hangarRouteProgrammed and playerInLock then
149prisoner:walkTo( 153.801224, height, 253.259750)
150prisoner:walkTo( 156.047333, height, 263.016998)
151prisoner:walkTo( 158.592575, height, 275.126709)
152prisoner:walkTo( 160.208252, height, 284.592896)
153prisoner:walkTo( 161.436462, height, 293.934601)
154prisoner:walkTo( 162.154053, height, 299.829407)
155prisoner:walkTo( 162.288696, height, 307.149750)
156prisoner:walkTo( 161.846405, height, 314.288727)
157prisoner:walkTo( 161.481949, height, 320.171295)
158prisoner:walkTo( 161.149612, height, 331.675751)
159prisoner:walkTo( 160.959152, height, 344.682129)
160prisoner:walkTo( 161.191635, height, 359.230835)
161prisoner:walkTo( 161.436386, height, 364.404175)
162prisoner:walkTo( 161.829483, height, 372.712799)
163prisoner:walkTo( 162.251343, height, 382.889465)
164prisoner:walkTo( 162.375793, height, 391.746979)
165prisoner:walkTo( 162.433640, height, 399.580994)
166prisoner:walkTo( 162.492249, height, 407.515991)
167prisoner:walkTo( 162.624390, height, 425.402435)
168prisoner:walkTo( 162.666931, height, 431.160980)
169prisoner:walkTo( 162.708481, height, 436.786591)
170prisoner:walkTo( 162.789124, height, 447.704620)
171prisoner:walkTo( 162.863098, height, 457.719055)
172prisoner:walkTo( 162.916428, height, 464.939545)
173prisoner:walkTo( 162.975830, height, 472.982452)
174prisoner:walkTo( 163.028259, height, 480.078857)
175prisoner:walkTo( 164.319611, height, 491.340607)
176prisoner:walkTo( 168.597382, height, 497.577728)
177prisoner:walkTo( 186.090088, height, 506.772766)
178prisoner:walkTo( 205.179825, height, 510.814911)
179prisoner:walkTo( 210.280609, height, 511.704041)
180prisoner:walkTo( 216.508865, height, 512.518982)
181prisoner:walkTo( 224.820663, height, 513.199585)
182prisoner:walkTo( 233.553589, height, 513.803711)
183prisoner:walkTo( 275.363922, height, 514.931763)
184prisoner:walkTo( 325.490265, height, 515.918945)
185prisoner:walkTo( 365.214355, height, 516.691833)
186prisoner:walkTo( 403.109619, height, 515.911804)
187prisoner:walkTo( 464.696991, height, 514.644348)
188prisoner:walkTo( 524.817627, height, 513.407104)
189prisoner:walkTo( 565.836670, height, 512.870239)
190prisoner:walkTo( 608.300232, height, 512.717957)
191prisoner:walkTo( 634.151794, height, 512.625183)
192prisoner:walkTo( 656.115234, height, 512.546570)
193prisoner:walkTo( 679.420166, height, 512.462708)
194prisoner:walkTo( 696.694702, height, 512.400635)
195prisoner:walkTo( 712.425781, height, 512.344299)
196prisoner:walkTo( 720.998474, height, 512.273193)
197prisoner:walkTo( 733.098389, height, 512.028137)
198prisoner:walkTo( 755.905273, height, 493.950714)
199prisoner:walkTo( 758.626648, height, 472.345520)
200prisoner:walkTo( 758.944458, height, 464.883545)
201prisoner:walkTo( 760.426208, height, 404.809967)
202prisoner:walkTo( 761.147827, height, 370.829987)
203prisoner:walkTo( 761.848511, height, 337.836395)
204prisoner:walkTo( 762.567932, height, 303.964020)
205prisoner:walkTo( 763.293335, height, 269.808380)
206prisoner:walkTo( 764.076294, height, 232.951477)
207prisoner:walkTo( 765.114441, height, 184.070221)
208prisoner:walkTo( 765.890076, height, 147.545258)
209prisoner:walkTo( 766.753296, height, 106.902954)
210prisoner:walkTo( 767.115967, height, 76.410255)
211prisoner:walkTo( 766.648621, height, 39.034630)
212prisoner:walkTo( 766.501282, height, 3.641552)
213prisoner:walkTo( 766.630615, height, -25.998037)
214prisoner:walkTo( 766.773560, height, -58.753052)
215prisoner:walkTo( 766.897766, height, -87.277809)
216prisoner:walkTo( 766.534546, height, -107.109718)
217prisoner:walkTo( 764.282104, height, -135.666809)
218prisoner:walkTo( 761.187439, height, -155.214981)
219prisoner:walkTo( 756.769043, height, -180.015106)
220prisoner:walkTo( 748.603821, height, -224.832336)
221prisoner:walkTo( 741.901978, height, -259.153870)
222prisoner:walkTo( 735.091492, height, -293.963196)
223prisoner:walkTo( 726.579651, height, -329.477051)
224prisoner:walkTo( 716.802002, height, -367.452911)
225prisoner:walkTo( 706.963806, height, -402.515228)
226prisoner:walkTo( 697.003357, height, -438.013824)
227prisoner:walkTo( 688.261230, height, -471.035400)
228prisoner:walkTo( 683.497986, height, -504.091461)
229prisoner:walkTo( 681.250732, height, -528.006287)
230prisoner:walkTo( 679.264771, height, -554.841125)
231prisoner:walkTo( 678.647949, height, -582.533508)
232prisoner:walkTo( 678.731018, height, -612.342407)
233prisoner:walkTo( 678.873230, height, -663.699585)
234prisoner:walkTo( 683.213135, height, -824.669922)
235prisoner:walkTo( 691.796326, height, -993.215332)
236prisoner:walkTo( 696.237244, height, -1045.909302)
237prisoner:walkTo( 702.897461, height, -1072.645020)
238prisoner:walkTo( 710.501160, height, -1095.735107)
239prisoner:walkTo( 715.637573, height, -1111.740845)
240prisoner:walkTo( 725.408020, height, -1144.843506)
241prisoner:walkTo( 747.384888, height, -1223.670410)
242prisoner:walkTo( 751.330872, height, -1238.939941)
243prisoner:walkTo( 757.179504, height, -1262.104980)
244prisoner:walkTo( 761.473145, height, -1287.161133)
245prisoner:walkTo( 764.180298, height, -1311.035767)
246prisoner:walkTo( 765.995178, height, -1339.139648)
247prisoner:walkTo( 767.811340, height, -1381.138428)
248prisoner:walkTo( 769.017273, height, -1409.277344)
249prisoner:walkTo( 769.463684, height, -1430.375244)
250prisoner:walkTo( 769.351685, height, -1451.503418)
251hangarRouteProgrammed = true
252end
253
254thisX = prisoner:getAbsCoorX()
255thisY = prisoner:getAbsCoorY()
256thisZ = prisoner:getAbsCoorZ()
257
258if dist( thisX,thisY,thisZ, 3.175952, 29, -1610.220093) < 60 then
259return true
260end
261
262
263return false
264
265end
266
267spaceshipRouteProgrammed = false
268function goToSpaceship(timestep)
269
270if not spaceshipRouteProgrammed then
271
272
273spaceshipRouteProgrammed = true
274end
275
276if prisoner:finalGoalReached() then
277   return true
278end
279
280return false
281
282end
283
284
285function enterSpaceship(timestep)
286
287return false
288end
289
290
291
292function tick(timestep)
293
294 observeGuard()
295 observePlayer()
296
297
298if not walkinCellFinished then
299walkinCellFinished = walkInCell(timestep)
300end
301
302
303if walkinCellFinished and not hangarReached then
304hangarReached = goToHangar(timestep)
305end
306
307if hangarReached and not spaceShipReached then 
308spaceShipReached = goToSpaceship(timestep)
309end
310
311if spaceShipReached and not spaceShipEntered then
312spaceShipEntered = enterSpaceship(timestep)
313end
314
315if spaceShipEntered then
316return true
317end
318
319return false
320end
Note: See TracBrowser for help on using the repository browser.