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