1 | -- Create the trigger |
---|
2 | trigger = ScriptTrigger() |
---|
3 | trigger:setName("prisonertrigger") |
---|
4 | trigger:setScript("prisoner.lua") |
---|
5 | trigger:setFunction("tick") |
---|
6 | trigger:setActiveOnCreation(true) |
---|
7 | |
---|
8 | |
---|
9 | -- Get objects from orxonox |
---|
10 | thisscript:addObject("GenericNPC", "prisoner") |
---|
11 | thisscript:addObject("FPSPlayer", "Player") |
---|
12 | thisscript:addObject("GenericNPC", "secondguard") |
---|
13 | thisscript:addObject("GenericNPC","guard") |
---|
14 | |
---|
15 | |
---|
16 | cellDoorOpened = false |
---|
17 | walkinCellFinished = false |
---|
18 | cellExitReached = false |
---|
19 | exitReached = false |
---|
20 | hangarReached = false |
---|
21 | spaceShipReached = false |
---|
22 | spaceShipEntered = false |
---|
23 | playerInLock = false |
---|
24 | guardStopped = false |
---|
25 | gotoSpaceship = false |
---|
26 | |
---|
27 | randTime = 0 |
---|
28 | height = 36 |
---|
29 | |
---|
30 | |
---|
31 | function dist( x1,x2,x3, y1,y2,y3 ) |
---|
32 | |
---|
33 | return math.sqrt( (x1-y1)^2 + (x2-y2)^2 + (x3-y3)^2 ) |
---|
34 | |
---|
35 | end |
---|
36 | |
---|
37 | function observeGuard() |
---|
38 | guardX = secondguard:getAbsCoorX() |
---|
39 | guardY = secondguard:getAbsCoorY() |
---|
40 | guardZ = secondguard:getAbsCoorZ() |
---|
41 | |
---|
42 | if dist( guardX,guardY,guardZ, -85.456375, height, 171.823486) < 60 then |
---|
43 | cellDoorOpened = true |
---|
44 | end |
---|
45 | |
---|
46 | end |
---|
47 | |
---|
48 | function observePlayer() |
---|
49 | playerX = Player:getAbsCoorX() |
---|
50 | playerY = Player:getAbsCoorY() |
---|
51 | playerZ = Player:getAbsCoorZ() |
---|
52 | |
---|
53 | |
---|
54 | guardX = guard:getAbsCoorX() |
---|
55 | guardY = guard:getAbsCoorY() |
---|
56 | guardZ = guard:getAbsCoorZ() |
---|
57 | |
---|
58 | distance = dist( guardX,guardY,guardZ,playerX, playerY, playerZ) |
---|
59 | |
---|
60 | if dist( playerX,playerY,playerZ,161.76,49,408.87 ) < 50 then |
---|
61 | playerInLock = true |
---|
62 | end |
---|
63 | |
---|
64 | |
---|
65 | if distance > 250 and hangarRouteProgrammed and not guardStopped and not gotoSpaceship then |
---|
66 | prisoner:stop() |
---|
67 | guardStopped = true |
---|
68 | end |
---|
69 | |
---|
70 | if distance < 250 and hangarRouteProgrammed and guardStopped and not gotoSpaceship then |
---|
71 | prisoner:resume() |
---|
72 | guardStopped = false |
---|
73 | end |
---|
74 | |
---|
75 | |
---|
76 | if dist( guardX,guardY,guardZ,772.325012, height, -1500.850708) < 200 then |
---|
77 | gotoSpaceship = true |
---|
78 | end |
---|
79 | |
---|
80 | |
---|
81 | end |
---|
82 | |
---|
83 | walkProgrammed = false |
---|
84 | exitProgrammed = false |
---|
85 | function walkInCell(timestep) |
---|
86 | |
---|
87 | |
---|
88 | if not walkProgrammed then |
---|
89 | --prisoner:walkTo( -66.454849, height, 62.363449) |
---|
90 | --prisoner:walkTo( -66.454849, height, 62.363449) |
---|
91 | prisoner:walkTo( -63.214821, height, 62.429710) |
---|
92 | prisoner:walkTo( -56.661182, height, 62.563740) |
---|
93 | prisoner:walkTo( -46.779755, height, 62.765827) |
---|
94 | prisoner:walkTo( -41.634224, height, 71.319214) |
---|
95 | prisoner:walkTo( -38.168526, height, 79.655807) |
---|
96 | prisoner:walkTo( -40.782196, height, 101.285233) |
---|
97 | prisoner:walkTo( -47.722874, height, 114.314980) |
---|
98 | prisoner:walkTo( -54.593349, height, 118.605423) |
---|
99 | prisoner:walkTo( -62.802982, height, 117.947144) |
---|
100 | prisoner:walkTo( -73.180130, height, 116.720863) |
---|
101 | prisoner:walkTo( -85.028603, height, 114.952316) |
---|
102 | prisoner:walkTo( -113.125824, height, 96.362946) |
---|
103 | prisoner:walkTo( -118.218887, height, 87.702599) |
---|
104 | prisoner:walkTo( -120.596275, height, 80.304184) |
---|
105 | prisoner:walkTo( -114.928169, height, 68.971840) |
---|
106 | prisoner:walkTo( -108.606766, height, 62.085098) |
---|
107 | prisoner:walkTo( -90.078171, height, 59.558804) |
---|
108 | prisoner:walkTo( -83.558510, height, 60.516567) |
---|
109 | prisoner:walkTo( -71.352402, height, 63.920750) |
---|
110 | walkProgrammed = true |
---|
111 | end |
---|
112 | |
---|
113 | |
---|
114 | if prisoner:finalGoalReached() and not cellDoorOpened then |
---|
115 | walkProgrammed = false |
---|
116 | end |
---|
117 | |
---|
118 | |
---|
119 | if cellDoorOpened then |
---|
120 | |
---|
121 | if not exitProgrammed then |
---|
122 | prisoner:walkTo( -61.875267, height, 158.254517) |
---|
123 | prisoner:walkTo( -62.335995, height, 170.318756) |
---|
124 | prisoner:walkTo( -62.358681, height, 179.232559) |
---|
125 | prisoner:walkTo( -55.998741, height, 189.289749) |
---|
126 | prisoner:walkTo( -49.237957, height, 195.076263) |
---|
127 | prisoner:walkTo( -39.007496, height, 195.889221) |
---|
128 | prisoner:walkTo( -24.234095, height, 195.547043) |
---|
129 | prisoner:walkTo( -11.409116, height, 196.236069) |
---|
130 | prisoner:walkTo( 2.545602, height, 196.805954) |
---|
131 | prisoner:walkTo( 13.875313, height, 196.377563) |
---|
132 | prisoner:walkTo( 28.379402, height, 195.829132) |
---|
133 | prisoner:walkTo( 41.672989, height, 195.326477) |
---|
134 | prisoner:walkTo( 57.125935, height, 194.742126) |
---|
135 | prisoner:walkTo( 70.114609, height, 194.251007) |
---|
136 | prisoner:walkTo( 81.857407, height, 193.806961) |
---|
137 | prisoner:walkTo( 97.840607, height, 193.974030) |
---|
138 | prisoner:walkTo( 107.569641, height, 196.299652) |
---|
139 | prisoner:walkTo( 120.975266, height, 202.754532) |
---|
140 | prisoner:walkTo( 129.063812, height, 207.099640) |
---|
141 | prisoner:walkTo( 140.468765, height, 214.389191) |
---|
142 | prisoner:walkTo( 145.902267, height, 224.194229) |
---|
143 | prisoner:walkTo( 148.106079, height, 233.095215) |
---|
144 | prisoner:walkTo( 150.907532, height, 244.410049) |
---|
145 | prisoner:walkTo( 153.191757, height, 253.635788) |
---|
146 | prisoner:walkTo( 153.191757, height, 253.635788) |
---|
147 | prisoner:walkTo( 151.838257, height, 257.185974) |
---|
148 | prisoner:walkTo( 153.967865, height, 270.535095) |
---|
149 | prisoner:walkTo( 156.288605, height, 284.582123) |
---|
150 | prisoner:walkTo( 158.034988, height, 300.072937) |
---|
151 | prisoner:walkTo( 158.817184, height, 311.973724) |
---|
152 | prisoner:walkTo( 159.794891, height, 326.848816) |
---|
153 | prisoner:walkTo( 160.789093, height, 342.474060) |
---|
154 | prisoner:walkTo( 161.391815, height, 357.817505) |
---|
155 | prisoner:walkTo( 162.055618, height, 374.715668) |
---|
156 | prisoner:walkTo( 161.595901, height, 389.146759) |
---|
157 | prisoner:walkTo( 160.607056, height, 407.092896) |
---|
158 | prisoner:walkTo( 160.508041, height, 416.996307) |
---|
159 | |
---|
160 | exitProgrammed = true |
---|
161 | end |
---|
162 | |
---|
163 | if prisoner:finalGoalReached() then |
---|
164 | return true |
---|
165 | end |
---|
166 | |
---|
167 | end |
---|
168 | |
---|
169 | return false |
---|
170 | |
---|
171 | end |
---|
172 | |
---|
173 | |
---|
174 | hangarRouteProgrammed = false |
---|
175 | function goToHangar(timestep) |
---|
176 | |
---|
177 | if not hangarRouteProgrammed and playerInLock then |
---|
178 | prisoner:walkTo( 162.624390, height, 425.402435) |
---|
179 | prisoner:walkTo( 162.666931, height, 431.160980) |
---|
180 | prisoner:walkTo( 162.708481, height, 436.786591) |
---|
181 | prisoner:walkTo( 162.789124, height, 447.704620) |
---|
182 | prisoner:walkTo( 162.863098, height, 457.719055) |
---|
183 | prisoner:walkTo( 162.916428, height, 464.939545) |
---|
184 | prisoner:walkTo( 162.975830, height, 472.982452) |
---|
185 | prisoner:walkTo( 163.028259, height, 480.078857) |
---|
186 | prisoner:walkTo( 164.319611, height, 491.340607) |
---|
187 | prisoner:walkTo( 168.597382, height, 497.577728) |
---|
188 | prisoner:walkTo( 186.090088, height, 506.772766) |
---|
189 | prisoner:walkTo( 205.179825, height, 510.814911) |
---|
190 | prisoner:walkTo( 210.280609, height, 511.704041) |
---|
191 | prisoner:walkTo( 216.508865, height, 512.518982) |
---|
192 | prisoner:walkTo( 224.820663, height, 513.199585) |
---|
193 | prisoner:walkTo( 233.553589, height, 513.803711) |
---|
194 | prisoner:walkTo( 275.363922, height, 514.931763) |
---|
195 | prisoner:walkTo( 325.490265, height, 515.918945) |
---|
196 | prisoner:walkTo( 365.214355, height, 516.691833) |
---|
197 | prisoner:walkTo( 403.109619, height, 515.911804) |
---|
198 | prisoner:walkTo( 464.696991, height, 514.644348) |
---|
199 | prisoner:walkTo( 524.817627, height, 513.407104) |
---|
200 | prisoner:walkTo( 565.836670, height, 512.870239) |
---|
201 | prisoner:walkTo( 608.300232, height, 512.717957) |
---|
202 | prisoner:walkTo( 634.151794, height, 512.625183) |
---|
203 | prisoner:walkTo( 656.115234, height, 512.546570) |
---|
204 | prisoner:walkTo( 679.420166, height, 512.462708) |
---|
205 | prisoner:walkTo( 696.694702, height, 512.400635) |
---|
206 | prisoner:walkTo( 712.425781, height, 512.344299) |
---|
207 | prisoner:walkTo( 720.998474, height, 512.273193) |
---|
208 | prisoner:walkTo( 733.098389, height, 512.028137) |
---|
209 | prisoner:walkTo( 755.905273, height, 493.950714) |
---|
210 | prisoner:walkTo( 758.626648, height, 472.345520) |
---|
211 | prisoner:walkTo( 758.944458, height, 464.883545) |
---|
212 | prisoner:walkTo( 760.426208, height, 404.809967) |
---|
213 | prisoner:walkTo( 761.147827, height, 370.829987) |
---|
214 | prisoner:walkTo( 761.848511, height, 337.836395) |
---|
215 | prisoner:walkTo( 762.567932, height, 303.964020) |
---|
216 | prisoner:walkTo( 763.293335, height, 269.808380) |
---|
217 | prisoner:walkTo( 764.076294, height, 232.951477) |
---|
218 | prisoner:walkTo( 765.114441, height, 184.070221) |
---|
219 | prisoner:walkTo( 765.890076, height, 147.545258) |
---|
220 | prisoner:walkTo( 766.753296, height, 106.902954) |
---|
221 | prisoner:walkTo( 767.115967, height, 76.410255) |
---|
222 | prisoner:walkTo( 766.648621, height, 39.034630) |
---|
223 | prisoner:walkTo( 766.501282, height, 3.641552) |
---|
224 | prisoner:walkTo( 766.630615, height, -25.998037) |
---|
225 | prisoner:walkTo( 766.773560, height, -58.753052) |
---|
226 | prisoner:walkTo( 766.897766, height, -87.277809) |
---|
227 | prisoner:walkTo( 766.534546, height, -107.109718) |
---|
228 | prisoner:walkTo( 764.282104, height, -135.666809) |
---|
229 | prisoner:walkTo( 761.187439, height, -155.214981) |
---|
230 | prisoner:walkTo( 756.769043, height, -180.015106) |
---|
231 | prisoner:walkTo( 748.603821, height, -224.832336) |
---|
232 | prisoner:walkTo( 741.901978, height, -259.153870) |
---|
233 | prisoner:walkTo( 735.091492, height, -293.963196) |
---|
234 | prisoner:walkTo( 726.579651, height, -329.477051) |
---|
235 | prisoner:walkTo( 716.802002, height, -367.452911) |
---|
236 | prisoner:walkTo( 706.963806, height, -402.515228) |
---|
237 | prisoner:walkTo( 697.003357, height, -438.013824) |
---|
238 | prisoner:walkTo( 688.261230, height, -471.035400) |
---|
239 | prisoner:walkTo( 683.497986, height, -504.091461) |
---|
240 | prisoner:walkTo( 681.250732, height, -528.006287) |
---|
241 | prisoner:walkTo( 679.264771, height, -554.841125) |
---|
242 | prisoner:walkTo( 678.647949, height, -582.533508) |
---|
243 | prisoner:walkTo( 678.731018, height, -612.342407) |
---|
244 | prisoner:walkTo( 678.873230, height, -663.699585) |
---|
245 | prisoner:walkTo( 683.213135, height, -824.669922) |
---|
246 | prisoner:walkTo( 691.796326, height, -993.215332) |
---|
247 | prisoner:walkTo( 696.237244, height, -1045.909302) |
---|
248 | prisoner:walkTo( 702.897461, height, -1072.645020) |
---|
249 | prisoner:walkTo( 710.501160, height, -1095.735107) |
---|
250 | prisoner:walkTo( 715.637573, height, -1111.740845) |
---|
251 | prisoner:walkTo( 725.408020, height, -1144.843506) |
---|
252 | prisoner:walkTo( 747.384888, height, -1223.670410) |
---|
253 | prisoner:walkTo( 751.330872, height, -1238.939941) |
---|
254 | prisoner:walkTo( 757.179504, height, -1262.104980) |
---|
255 | prisoner:walkTo( 761.473145, height, -1287.161133) |
---|
256 | prisoner:walkTo( 764.180298, height, -1311.035767) |
---|
257 | prisoner:walkTo( 765.995178, height, -1339.139648) |
---|
258 | prisoner:walkTo( 767.811340, height, -1381.138428) |
---|
259 | prisoner:walkTo( 769.017273, height, -1409.277344) |
---|
260 | prisoner:walkTo( 769.463684, height, -1430.375244) |
---|
261 | prisoner:walkTo( 769.351685, height, -1451.503418) |
---|
262 | |
---|
263 | prisoner:walkTo( 775.508972, height, -1457.168213) |
---|
264 | prisoner:walkTo( 776.536743, height, -1462.372925) |
---|
265 | prisoner:walkTo( 778.141663, height, -1470.500732) |
---|
266 | prisoner:walkTo( 779.744995, height, -1478.620117) |
---|
267 | prisoner:walkTo( 782.587646, height, -1489.528198) |
---|
268 | prisoner:walkTo( 785.285156, height, -1497.338013) |
---|
269 | prisoner:walkTo( 788.850159, height, -1506.399414) |
---|
270 | prisoner:walkTo( 792.417053, height, -1515.465820) |
---|
271 | prisoner:walkTo( 796.757446, height, -1525.825684) |
---|
272 | prisoner:walkTo( 802.122009, height, -1534.417847) |
---|
273 | prisoner:walkTo( 808.422058, height, -1541.669067) |
---|
274 | prisoner:walkTo( 816.134949, height, -1549.770508) |
---|
275 | prisoner:walkTo( 824.352783, height, -1557.150024) |
---|
276 | prisoner:walkTo( 832.695801, height, -1563.451172) |
---|
277 | prisoner:walkTo( 843.443665, height, -1571.163818) |
---|
278 | prisoner:walkTo( 850.623901, height, -1576.316284) |
---|
279 | prisoner:walkTo( 859.099182, height, -1580.545166) |
---|
280 | prisoner:walkTo( 868.999939, height, -1585.129028) |
---|
281 | prisoner:walkTo( 879.254211, height, -1588.827148) |
---|
282 | prisoner:walkTo( 888.822021, height, -1592.277832) |
---|
283 | prisoner:walkTo( 895.563293, height, -1594.931885) |
---|
284 | prisoner:walkTo( 900.941589, height, -1597.049438) |
---|
285 | prisoner:walkTo( 907.684387, height, -1599.704102) |
---|
286 | prisoner:walkTo( 914.599243, height, -1604.825928) |
---|
287 | prisoner:walkTo( 919.703430, height, -1609.984619) |
---|
288 | prisoner:walkTo( 925.728088, height, -1616.250977) |
---|
289 | prisoner:walkTo( 930.751343, height, -1621.475830) |
---|
290 | prisoner:walkTo( 934.714905, height, -1625.719360) |
---|
291 | prisoner:walkTo( 940.166260, height, -1631.555664) |
---|
292 | prisoner:walkTo( 946.152344, height, -1637.964600) |
---|
293 | prisoner:walkTo( 953.042297, height, -1646.456421) |
---|
294 | prisoner:walkTo( 958.174194, height, -1654.167847) |
---|
295 | prisoner:walkTo( 964.112854, height, -1663.534424) |
---|
296 | prisoner:walkTo( 968.981812, height, -1670.229248) |
---|
297 | prisoner:walkTo( 975.821045, height, -1678.569946) |
---|
298 | prisoner:walkTo( 982.743835, height, -1687.244385) |
---|
299 | prisoner:walkTo( 990.572571, height, -1697.622559) |
---|
300 | prisoner:walkTo( 995.849670, height, -1704.618164) |
---|
301 | prisoner:walkTo( 1001.152649, height, -1711.648193) |
---|
302 | prisoner:walkTo( 1005.204590, height, -1717.019531) |
---|
303 | prisoner:walkTo( 1012.097412, height, -1725.154907) |
---|
304 | prisoner:walkTo( 1017.283020, height, -1731.152222) |
---|
305 | prisoner:walkTo( 1022.044250, height, -1736.658936) |
---|
306 | prisoner:walkTo( 1028.422852, height, -1744.234863) |
---|
307 | prisoner:walkTo( 1033.080688, height, -1749.780884) |
---|
308 | prisoner:walkTo( 1036.395874, height, -1753.908936) |
---|
309 | prisoner:walkTo( 1040.509155, height, -1759.065186) |
---|
310 | prisoner:walkTo( 1044.627441, height, -1764.227783) |
---|
311 | prisoner:walkTo( 1050.220093, height, -1770.871094) |
---|
312 | prisoner:walkTo( 1054.504883, height, -1775.961060) |
---|
313 | prisoner:walkTo( 1060.259888, height, -1782.490723) |
---|
314 | prisoner:walkTo( 1067.060913, height, -1789.939209) |
---|
315 | prisoner:walkTo( 1072.477173, height, -1795.898315) |
---|
316 | prisoner:walkTo( 1076.556152, height, -1800.990845) |
---|
317 | prisoner:walkTo( 1080.718018, height, -1806.200439) |
---|
318 | prisoner:walkTo( 1085.281494, height, -1811.912476) |
---|
319 | prisoner:walkTo( 1090.934448, height, -1817.621094) |
---|
320 | prisoner:walkTo( 1095.896240, height, -1822.369141) |
---|
321 | prisoner:walkTo( 1100.940430, height, -1827.278564) |
---|
322 | prisoner:walkTo( 1107.045898, height, -1833.460693) |
---|
323 | prisoner:walkTo( 1113.230103, height, -1839.722534) |
---|
324 | |
---|
325 | hangarRouteProgrammed = true |
---|
326 | end |
---|
327 | |
---|
328 | thisX = prisoner:getAbsCoorX() |
---|
329 | thisY = prisoner:getAbsCoorY() |
---|
330 | thisZ = prisoner:getAbsCoorZ() |
---|
331 | |
---|
332 | distance = dist( thisX,thisY,thisZ, 1113.230103, height, -1839.722534) |
---|
333 | --io.write(distance,"\n") |
---|
334 | |
---|
335 | if dist( thisX,thisY,thisZ, 1113.230103, height, -1839.722534) < 40 then |
---|
336 | prisoner:hide() |
---|
337 | return true |
---|
338 | end |
---|
339 | |
---|
340 | |
---|
341 | return false |
---|
342 | |
---|
343 | end |
---|
344 | |
---|
345 | spaceshipRouteProgrammed = false |
---|
346 | function goToSpaceship(timestep) |
---|
347 | |
---|
348 | if not spaceshipRouteProgrammed then |
---|
349 | |
---|
350 | |
---|
351 | spaceshipRouteProgrammed = true |
---|
352 | end |
---|
353 | |
---|
354 | if prisoner:finalGoalReached() then |
---|
355 | return true |
---|
356 | end |
---|
357 | |
---|
358 | return false |
---|
359 | |
---|
360 | end |
---|
361 | |
---|
362 | |
---|
363 | function enterSpaceship(timestep) |
---|
364 | |
---|
365 | return false |
---|
366 | end |
---|
367 | |
---|
368 | |
---|
369 | |
---|
370 | function tick(timestep) |
---|
371 | |
---|
372 | observeGuard() |
---|
373 | observePlayer() |
---|
374 | |
---|
375 | |
---|
376 | if not walkinCellFinished then |
---|
377 | walkinCellFinished = walkInCell(timestep) |
---|
378 | end |
---|
379 | |
---|
380 | |
---|
381 | if walkinCellFinished and not hangarReached then |
---|
382 | hangarReached = goToHangar(timestep) |
---|
383 | end |
---|
384 | |
---|
385 | |
---|
386 | return hangarReached |
---|
387 | end |
---|