Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

objects get added from within the script

File size: 10.2 KB
RevLine 
[4051]1-- Get objects from orxonox
2thisscript:addObject("GenericNPC", "prisoner")
3thisscript:addObject("FPSPlayer", "Player")
4thisscript:addObject("GenericNPC", "secondguard")
5
6
[3946]7cellDoorOpened = false
8walkinCellFinished = false
9cellExitReached = false
[3945]10exitReached = false
11hangarReached = false
12spaceShipReached = false
13spaceShipEntered = false
[3954]14playerInLock = false
[3945]15
[3946]16randTime = 0
[3966]17height = 80
[3945]18
[3962]19
20function dist( x1,x2,x3, y1,y2,y3 )
21
22return math.sqrt( (x1-y1)^2 + (x2-y2)^2 + (x3-y3)^2 )
23
24end
25
[3954]26function observeGuard()
[3965]27guardX = secondguard:getAbsCoorX()
28guardY = secondguard:getAbsCoorY()
29guardZ = secondguard:getAbsCoorZ()
[3954]30
[3965]31if dist( guardX,guardY,guardZ, 43.406876, 29, 179.517303) < 60 then
[3945]32cellDoorOpened = true
33end
34
[3954]35end
[3945]36
[3954]37function observePlayer()
38playerX = Player:getAbsCoorX()
39playerY = Player:getAbsCoorY()
40playerZ = Player:getAbsCoorZ()
41
42if dist( playerX,playerY,playerZ,161.76,49,358.87 ) < 60 then
43playerInLock = true
44end
45
[3962]46end
47
[3965]48
49
[3954]50walkProgrammed = false
51exitProgrammed = false
[3945]52function walkInCell(timestep)
53
[3965]54
[3954]55if not walkProgrammed then
[3964]56prisoner:walkTo( -66.454849, height, 62.363449)
57prisoner:walkTo( -66.454849, height, 62.363449)
58prisoner:walkTo( -63.214821, height, 62.429710)
59prisoner:walkTo( -56.661182, height, 62.563740)
60prisoner:walkTo( -46.779755, height, 62.765827)
61prisoner:walkTo( -41.634224, height, 71.319214)
62prisoner:walkTo( -38.168526, height, 79.655807)
63prisoner:walkTo( -40.782196, height, 101.285233)
64prisoner:walkTo( -47.722874, height, 114.314980)
65prisoner:walkTo( -54.593349, height, 118.605423)
66prisoner:walkTo( -62.802982, height, 117.947144)
67prisoner:walkTo( -73.180130, height, 116.720863)
68prisoner:walkTo( -85.028603, height, 114.952316)
69prisoner:walkTo( -113.125824, height, 96.362946)
70prisoner:walkTo( -118.218887, height, 87.702599)
71prisoner:walkTo( -120.596275, height, 80.304184)
72prisoner:walkTo( -114.928169, height, 68.971840)
73prisoner:walkTo( -108.606766, height, 62.085098)
74prisoner:walkTo( -90.078171, height, 59.558804)
75prisoner:walkTo( -83.558510, height, 60.516567)
76prisoner:walkTo( -71.352402, height, 63.920750)
[3954]77walkProgrammed = true
[3945]78end
79
[3964]80
81if prisoner:finalGoalReached() and not cellDoorOpened then
[3965]82 walkProgrammed = false
83end
[3964]84
[3965]85
[3954]86if cellDoorOpened then
[3945]87
[3954]88  if not exitProgrammed then
[3964]89prisoner:walkTo( -61.875267, height, 158.254517)
90prisoner:walkTo( -62.335995, height, 170.318756)
91prisoner:walkTo( -62.358681, height, 179.232559)
92prisoner:walkTo( -55.998741, height, 189.289749)
93prisoner:walkTo( -49.237957, height, 195.076263)
94prisoner:walkTo( -39.007496, height, 195.889221)
95prisoner:walkTo( -24.234095, height, 195.547043)
96prisoner:walkTo( -11.409116, height, 196.236069)
97prisoner:walkTo( 2.545602, height, 196.805954)
98prisoner:walkTo( 13.875313, height, 196.377563)
99prisoner:walkTo( 28.379402, height, 195.829132)
100prisoner:walkTo( 41.672989, height, 195.326477)
101prisoner:walkTo( 57.125935, height, 194.742126)
102prisoner:walkTo( 70.114609, height, 194.251007)
103prisoner:walkTo( 81.857407, height, 193.806961)
104prisoner:walkTo( 97.840607, height, 193.974030)
105prisoner:walkTo( 107.569641, height, 196.299652)
106prisoner:walkTo( 120.975266, height, 202.754532)
107prisoner:walkTo( 129.063812, height, 207.099640)
108prisoner:walkTo( 140.468765, height, 214.389191)
109prisoner:walkTo( 145.902267, height, 224.194229)
110prisoner:walkTo( 148.106079, height, 233.095215)
111prisoner:walkTo( 150.907532, height, 244.410049)
112prisoner:walkTo( 153.191757, height, 253.635788)
113prisoner:walkTo( 153.191757, height, 253.635788)
[3954]114   exitProgrammed = true
115  end
116
[3964]117  if prisoner:finalGoalReached() then
[3954]118   return true
119  end
120
[3965]121end 
[3954]122
123return false
[3964]124
[3946]125end
[3945]126
[3946]127
[3954]128hangarRouteProgrammed = false
[3945]129function goToHangar(timestep)
130
[3965]131if not hangarRouteProgrammed and playerInLock then
132prisoner:walkTo( 149.255554, height, 253.358582)
133prisoner:walkTo( 155.679886, height, 274.126282)
134prisoner:walkTo( 157.556641, height, 285.543640)
135prisoner:walkTo( 159.016068, height, 294.552338)
136prisoner:walkTo( 160.234924, height, 303.494812)
137prisoner:walkTo( 161.399475, height, 313.532013)
138prisoner:walkTo( 162.218994, height, 323.290924)
139prisoner:walkTo( 162.030823, height, 335.226715)
140prisoner:walkTo( 161.351410, height, 378.328094)
141prisoner:walkTo( 161.183487, height, 388.983093)
142prisoner:walkTo( 160.590225, height, 426.615540)
143prisoner:walkTo( 160.313049, height, 444.198425)
144prisoner:walkTo( 160.410721, height, 454.192413)
145prisoner:walkTo( 161.796692, height, 465.085663)
146prisoner:walkTo( 163.096069, height, 474.038086)
147prisoner:walkTo( 165.596329, height, 485.415924)
148prisoner:walkTo( 167.407303, height, 493.229279)
149prisoner:walkTo( 169.595749, height, 499.048309)
150prisoner:walkTo( 173.485214, height, 504.383026)
151prisoner:walkTo( 182.131546, height, 510.774567)
152prisoner:walkTo( 187.788422, height, 512.870789)
153prisoner:walkTo( 196.524994, height, 514.751892)
154prisoner:walkTo( 205.403473, height, 515.840271)
155prisoner:walkTo( 205.403473, height, 515.840271)
156prisoner:walkTo( 220.813049, height, 515.886658)
157prisoner:walkTo( 392.501221, height, 516.405579)
158prisoner:walkTo( 441.405975, height, 516.502502)
159prisoner:walkTo( 513.379517, height, 515.572266)
160prisoner:walkTo( 586.638611, height, 514.625244)
161prisoner:walkTo( 651.319214, height, 513.789246)
162prisoner:walkTo( 680.890869, height, 513.406982)
163prisoner:walkTo( 701.035828, height, 512.568359)
164prisoner:walkTo( 716.025879, height, 510.741150)
165prisoner:walkTo( 723.756042, height, 509.009583)
166prisoner:walkTo( 733.522095, height, 504.761475)
167prisoner:walkTo( 738.782104, height, 501.529327)
168prisoner:walkTo( 744.840637, height, 496.154846)
169prisoner:walkTo( 750.059875, height, 487.892670)
170prisoner:walkTo( 753.419373, height, 477.053894)
171prisoner:walkTo( 754.661743, height, 470.759735)
172prisoner:walkTo( 765.877319, height, 397.575897)
173prisoner:walkTo( 768.522522, height, 360.462250)
174prisoner:walkTo( 769.531250, height, 326.195801)
175prisoner:walkTo( 770.420532, height, 286.531830)
176prisoner:walkTo( 769.840393, height, 238.220535)
177prisoner:walkTo( 771.094543, height, 172.138474)
178prisoner:walkTo( 772.765137, height, 94.427673)
179prisoner:walkTo( 771.779175, height, 62.094421)
180prisoner:walkTo( 771.069336, height, 35.182930)
181prisoner:walkTo( 769.679199, height, 4.657598)
182prisoner:walkTo( 768.049377, height, -23.208313)
183prisoner:walkTo( 766.691711, height, -54.609066)
184prisoner:walkTo( 765.022156, height, -85.732277)
185prisoner:walkTo( 763.538635, height, -110.417847)
186prisoner:walkTo( 761.547485, height, -143.547577)
187prisoner:walkTo( 760.982483, height, -147.543091)
188prisoner:walkTo( 756.619934, height, -163.474457)
189prisoner:walkTo( 751.651611, height, -180.926727)
190prisoner:walkTo( 739.842041, height, -216.826782)
191prisoner:walkTo( 716.715149, height, -294.878693)
192prisoner:walkTo( 698.400146, height, -365.404541)
193prisoner:walkTo( 692.199890, height, -396.395386)
194prisoner:walkTo( 685.157593, height, -437.489929)
195prisoner:walkTo( 678.175537, height, -475.680817)
196prisoner:walkTo( 674.907837, height, -505.428314)
197prisoner:walkTo( 674.588501, height, -531.477478)
198prisoner:walkTo( 674.703308, height, -550.883789)
199prisoner:walkTo( 675.315063, height, -567.361206)
200prisoner:walkTo( 676.178345, height, -583.178772)
201prisoner:walkTo( 678.579407, height, -638.655518)
202prisoner:walkTo( 689.508118, height, -884.296448)
203prisoner:walkTo( 690.749084, height, -917.750366)
204prisoner:walkTo( 691.617676, height, -933.357056)
205prisoner:walkTo( 696.260742, height, -972.685669)
206prisoner:walkTo( 698.526550, height, -990.077209)
207prisoner:walkTo( 705.576599, height, -1033.587646)
208prisoner:walkTo( 719.388611, height, -1111.123657)
209prisoner:walkTo( 724.847229, height, -1137.902832)
210prisoner:walkTo( 729.118652, height, -1159.426514)
211prisoner:walkTo( 733.152161, height, -1179.577393)
212prisoner:walkTo( 737.474365, height, -1200.200684)
213prisoner:walkTo( 740.808777, height, -1216.996216)
214prisoner:walkTo( 748.261108, height, -1252.447021)
215prisoner:walkTo( 748.648682, height, -1254.182983)
216prisoner:walkTo( 752.690430, height, -1272.386719)
217prisoner:walkTo( 755.726562, height, -1286.795532)
218prisoner:walkTo( 758.134705, height, -1302.620117)
219prisoner:walkTo( 759.900879, height, -1317.258911)
220prisoner:walkTo( 760.405212, height, -1357.575195)
221prisoner:walkTo( 760.203979, height, -1396.744385)
222prisoner:walkTo( 759.262085, height, -1433.674316)
223prisoner:walkTo( 758.916016, height, -1447.247437)
224prisoner:walkTo( 757.844910, height, -1474.596558)
225prisoner:walkTo( 756.331238, height, -1484.150269)
226prisoner:walkTo( 754.152283, height, -1491.574585)
227prisoner:walkTo( 750.549561, height, -1497.667236)
228prisoner:walkTo( 741.115356, height, -1509.581177)
229prisoner:walkTo( 733.292236, height, -1516.592407)
230prisoner:walkTo( 724.755798, height, -1522.380615)
231prisoner:walkTo( 712.188721, height, -1528.557495)
232prisoner:walkTo( 707.279907, height, -1530.261841)
233prisoner:walkTo( 698.749390, height, -1532.002563)
234prisoner:walkTo( 681.891785, height, -1532.067871)
235prisoner:walkTo( 625.072388, height, -1531.572266)
236prisoner:walkTo( 501.572601, height, -1533.919922)
237prisoner:walkTo( 237.189667, height, -1538.984985)
238prisoner:walkTo( 146.071304, height, -1540.965820)
239prisoner:walkTo( 88.186996, height, -1549.110962)
240prisoner:walkTo( 85.715096, height, -1549.537842)
241prisoner:walkTo( 66.997787, height, -1552.770264)
242prisoner:walkTo( 52.632504, height, -1555.359009)
243prisoner:walkTo( 38.350941, height, -1560.845459)
244prisoner:walkTo( 26.315248, height, -1568.211060)
245prisoner:walkTo( 15.210221, height, -1580.474121)
246prisoner:walkTo( 6.527347, height, -1594.483398)
247prisoner:walkTo( 3.175952, height, -1610.220093)
[3945]248
[3954]249hangarRouteProgrammed = true
250end
251
[3965]252thisX = prisoner:getAbsCoorX()
253thisY = prisoner:getAbsCoorY()
254thisZ = prisoner:getAbsCoorZ()
255
256if dist( thisX,thisY,thisZ, 3.175952, 29, -1610.220093) < 60 then
257return true
[3954]258end
259
[3965]260
[3945]261return false
262
263end
264
[3954]265spaceshipRouteProgrammed = false
[3945]266function goToSpaceship(timestep)
267
[3954]268if not spaceshipRouteProgrammed then
269
[3964]270
[3954]271spaceshipRouteProgrammed = true
272end
273
274if prisoner:finalGoalReached() then
275   return true
276end
277
[3945]278return false
279
280end
281
282
283function enterSpaceship(timestep)
284
285return false
286end
287
288
289
290function tick(timestep)
291
[3954]292 observeGuard()
293 observePlayer()
294
295
[3965]296if not walkinCellFinished then
[3946]297walkinCellFinished = walkInCell(timestep)
[3945]298end
299
300
[3965]301if walkinCellFinished and not hangarReached then
[3945]302hangarReached = goToHangar(timestep)
303end
304
305if hangarReached and not spaceShipReached then 
306spaceShipReached = goToSpaceship(timestep)
307end
308
309if spaceShipReached and not spaceShipEntered then
310spaceShipEntered = enterSpaceship(timestep)
311end
312
313if spaceShipEntered then
314return true
315end
316
317return false
318end
Note: See TracBrowser for help on using the repository browser.