1 | -- Global Variables |
---|
2 | walkingRouteOne = true -- True if thestranger is walking route one |
---|
3 | exitPositionReached = false |
---|
4 | playerInLock = false |
---|
5 | hangarReached = false |
---|
6 | |
---|
7 | height = 29 |
---|
8 | |
---|
9 | -- Returns the distance between (x1,x2,x3) and (y1,y2,y3) |
---|
10 | function dist( x1,x2,x3, y1,y2,y3 ) |
---|
11 | return math.sqrt( (x1-y1)^2 + (x2-y2)^2 + (x3-y3)^2 ) |
---|
12 | end |
---|
13 | |
---|
14 | |
---|
15 | function observePlayer() |
---|
16 | playerX = Player:getAbsCoorX() |
---|
17 | playerY = Player:getAbsCoorY() |
---|
18 | playerZ = Player:getAbsCoorZ() |
---|
19 | |
---|
20 | if dist( playerX,playerY,playerZ,167.361526,29,483.163818 ) < 60 then |
---|
21 | playerInLock = true |
---|
22 | end |
---|
23 | |
---|
24 | end |
---|
25 | |
---|
26 | routeOneProgrammed = false |
---|
27 | function walkRouteOne(timestep) |
---|
28 | |
---|
29 | if not routeOneProgrammed then |
---|
30 | guard:walkTo( 266.396362, height, 241.398544) |
---|
31 | guard:walkTo( 254.577255, height, 241.159897) |
---|
32 | guard:walkTo( 221.120651, height, 240.484360) |
---|
33 | guard:walkTo( 187.732651, height, 239.810196) |
---|
34 | guard:walkTo( 165.661865, height, 239.364563) |
---|
35 | guard:walkTo( 148.642044, height, 239.020889) |
---|
36 | guard:walkTo( 128.012802, height, 238.604340) |
---|
37 | guard:walkTo( 65.664688, height, 237.345383) |
---|
38 | guard:walkTo( 30.099592, height, 236.627243) |
---|
39 | guard:walkTo( -14.031926, height, 236.483414) |
---|
40 | guard:walkTo( -52.224205, height, 241.776978) |
---|
41 | guard:walkTo( -83.528168, height, 245.757629) |
---|
42 | guard:walkTo( -98.730980, height, 247.394043) |
---|
43 | guard:walkTo( -111.666504, height, 246.585648) |
---|
44 | guard:walkTo( -111.666504, height, 246.585648) |
---|
45 | guard:walkTo( -114.805542, height, 246.144440) |
---|
46 | guard:walkTo( -119.267967, height, 245.360168) |
---|
47 | guard:walkTo( -138.284515, height, 239.281021) |
---|
48 | guard:walkTo( -146.166840, height, 234.512054) |
---|
49 | guard:walkTo( -157.210480, height, 222.620941) |
---|
50 | guard:walkTo( -158.519867, height, 219.674301) |
---|
51 | guard:walkTo( -158.519867, height, 219.674301) |
---|
52 | guard:walkTo( -158.478958, height, 213.490570) |
---|
53 | guard:walkTo( -158.478958, height, 213.490570) |
---|
54 | guard:walkTo( -155.965332, height, 210.303101) |
---|
55 | guard:walkTo( -150.804489, height, 203.959869) |
---|
56 | guard:walkTo( -148.853012, height, 201.561295) |
---|
57 | guard:walkTo( -145.451157, height, 197.554382) |
---|
58 | guard:walkTo( -143.694107, height, 196.373535) |
---|
59 | guard:walkTo( -139.281479, height, 193.407990) |
---|
60 | guard:walkTo( -137.526047, height, 192.228226) |
---|
61 | guard:walkTo( -103.046753, height, 182.510071) |
---|
62 | guard:runTo( -14.992087, height, 181.910767) |
---|
63 | guard:runTo( 46.347664, height, 181.493317) |
---|
64 | guard:runTo( 86.343376, height, 181.221130) |
---|
65 | guard:runTo( 124.465179, height, 194.251617) |
---|
66 | guard:runTo( 136.548996, height, 219.682953) |
---|
67 | guard:runTo( 145.162140, height, 244.268982) |
---|
68 | guard:runTo( 149.328720, height, 256.993256) |
---|
69 | guard:runTo( 162.649582, height, 268.181732) |
---|
70 | |
---|
71 | routeOneProgrammed = true |
---|
72 | end |
---|
73 | |
---|
74 | if guard:finalGoalReached() then |
---|
75 | return false |
---|
76 | end |
---|
77 | |
---|
78 | return true |
---|
79 | end |
---|
80 | |
---|
81 | |
---|
82 | exitRouteProgrammed = false |
---|
83 | function goToExitPosition(timestep) |
---|
84 | |
---|
85 | if not exitRouteProgrammed then |
---|
86 | guard:walkTo( 162.096558, height, 274.944366) |
---|
87 | guard:walkTo( 161.519516, height, 286.673370) |
---|
88 | guard:walkTo( 161.098618, height, 295.228699) |
---|
89 | guard:walkTo( 160.568466, height, 306.004486) |
---|
90 | guard:walkTo( 160.151169, height, 314.486572) |
---|
91 | guard:walkTo( 159.416641, height, 324.925232) |
---|
92 | guard:walkTo( 158.700073, height, 335.108154) |
---|
93 | guard:walkTo( 157.943298, height, 345.862610) |
---|
94 | guard:walkTo( 157.418381, height, 356.131256) |
---|
95 | guard:walkTo( 156.908035, height, 366.115417) |
---|
96 | guard:walkTo( 156.940308, height, 377.467712) |
---|
97 | guard:walkTo( 156.965408, height, 386.287933) |
---|
98 | guard:walkTo( 156.924698, height, 394.296417) |
---|
99 | guard:walkTo( 156.816116, height, 401.564911) |
---|
100 | guard:walkTo( 156.147583, height, 446.314850) |
---|
101 | guard:walkTo( 155.145660, height, 515.473877) |
---|
102 | guard:walkTo( 148.450058, height, 524.572571) |
---|
103 | guard:walkTo( 135.599609, height, 533.407166) |
---|
104 | guard:walkTo( 119.772217, height, 539.609192) |
---|
105 | guard:walkTo( 108.926720, height, 537.174927) |
---|
106 | guard:walkTo( 100.885788, height, 524.737793) |
---|
107 | guard:walkTo( 99.870834, height, 512.540100) |
---|
108 | guard:walkTo( 108.219215, height, 502.064178) |
---|
109 | |
---|
110 | exitRouteProgrammed = true |
---|
111 | end |
---|
112 | |
---|
113 | if guard:finalGoalReached() and playerInLock then |
---|
114 | return true |
---|
115 | end |
---|
116 | |
---|
117 | return false |
---|
118 | end |
---|
119 | |
---|
120 | |
---|
121 | hangarRouteProgrammed = false |
---|
122 | function goToHangar(timestep) |
---|
123 | |
---|
124 | if not hangarRouteProgrammed and playerInLock then |
---|
125 | guard:walkTo( 138.422943, height, 504.832733) |
---|
126 | guard:walkTo( 188.685089, height, 509.034851) |
---|
127 | guard:walkTo( 259.451904, height, 515.326111) |
---|
128 | guard:walkTo( 351.655762, height, 519.210571) |
---|
129 | guard:walkTo( 495.821381, height, 517.551392) |
---|
130 | guard:walkTo( 650.267029, height, 516.826843) |
---|
131 | guard:walkTo( 752.277100, height, 506.265289) |
---|
132 | guard:walkTo( 780.652405, height, 397.283752) |
---|
133 | guard:walkTo( 780.212830, height, 317.386017) |
---|
134 | guard:walkTo( 778.699158, height, 241.875305) |
---|
135 | guard:walkTo( 776.305542, height, 120.869957) |
---|
136 | guard:walkTo( 774.626343, height, 26.204597) |
---|
137 | guard:walkTo( 773.148804, height, -30.654911) |
---|
138 | guard:walkTo( 771.164978, height, -106.990250) |
---|
139 | guard:walkTo( 756.719971, height, -197.656296) |
---|
140 | guard:walkTo( 730.690796, height, -269.808075) |
---|
141 | guard:walkTo( 702.250854, height, -341.732147) |
---|
142 | guard:walkTo( 681.786011, height, -393.487030) |
---|
143 | guard:walkTo( 664.005981, height, -441.609131) |
---|
144 | guard:walkTo( 655.612671, height, -523.194153) |
---|
145 | guard:walkTo( 664.289978, height, -585.003540) |
---|
146 | guard:walkTo( 670.221069, height, -645.366333) |
---|
147 | guard:walkTo( 674.347290, height, -704.953674) |
---|
148 | guard:walkTo( 677.495605, height, -750.421082) |
---|
149 | guard:walkTo( 680.699280, height, -796.687073) |
---|
150 | guard:walkTo( 686.407043, height, -879.117859) |
---|
151 | guard:walkTo( 692.573364, height, -952.031555) |
---|
152 | guard:walkTo( 701.940552, height, -1025.037964) |
---|
153 | guard:walkTo( 710.218628, height, -1086.598389) |
---|
154 | guard:walkTo( 719.834900, height, -1142.248779) |
---|
155 | guard:walkTo( 731.087158, height, -1198.201538) |
---|
156 | guard:walkTo( 745.157715, height, -1258.461182) |
---|
157 | guard:walkTo( 753.189331, height, -1290.539551) |
---|
158 | guard:walkTo( 763.940369, height, -1347.249268) |
---|
159 | guard:walkTo( 768.509949, height, -1377.040039) |
---|
160 | guard:walkTo( 770.845215, height, -1408.751953) |
---|
161 | guard:walkTo( 770.785583, height, -1435.573608) |
---|
162 | guard:walkTo( 765.031799, height, -1462.657593) |
---|
163 | guard:walkTo( 753.982727, height, -1483.425415) |
---|
164 | guard:walkTo( 735.194580, height, -1500.978394) |
---|
165 | guard:walkTo( 707.312500, height, -1514.814575) |
---|
166 | guard:walkTo( 672.638550, height, -1522.803589) |
---|
167 | guard:walkTo( 560.158936, height, -1530.277344) |
---|
168 | guard:walkTo( 500.429626, height, -1532.241577) |
---|
169 | guard:walkTo( 371.231262, height, -1535.953613) |
---|
170 | guard:walkTo( 204.211609, height, -1539.026611) |
---|
171 | guard:walkTo( 104.032593, height, -1546.350220) |
---|
172 | guard:walkTo( 45.058315, height, -1550.720337) |
---|
173 | guard:walkTo( 1.504358, height, -1574.713745) |
---|
174 | guard:walkTo( -20.050890, height, -1627.849854) |
---|
175 | guard:walkTo( -28.036245, height, -1674.240479) |
---|
176 | guard:walkTo( -29.157598, height, -1702.924316) |
---|
177 | guard:walkTo( -29.760004, height, -1730.014526) |
---|
178 | guard:walkTo( -29.538343, height, -1759.887329) |
---|
179 | guard:walkTo( -21.584003, height, -1790.162842) |
---|
180 | guard:walkTo( -8.572795, height, -1823.067871) |
---|
181 | guard:walkTo( 13.254844, height, -1861.705688) |
---|
182 | hangarRouteProgrammed = true |
---|
183 | end |
---|
184 | |
---|
185 | if guard:finalGoalReached() then |
---|
186 | return true |
---|
187 | end |
---|
188 | |
---|
189 | return false |
---|
190 | end |
---|
191 | |
---|
192 | |
---|
193 | function waveToSpaceship(timestep) |
---|
194 | |
---|
195 | end |
---|
196 | |
---|
197 | |
---|
198 | function tick(timestep) |
---|
199 | --io.write("Guard called \n") |
---|
200 | observePlayer() |
---|
201 | |
---|
202 | if walkingRouteOne then |
---|
203 | walkingRouteOne = walkRouteOne(timestep) |
---|
204 | end |
---|
205 | |
---|
206 | if not walkingRouteOne and not exitPositionReached then |
---|
207 | exitPositionReached = goToExitPosition(timestep) |
---|
208 | end |
---|
209 | |
---|
210 | if not hangarReached and exitPositionReached then |
---|
211 | hangarReached = goToHangar(timestep) |
---|
212 | end |
---|
213 | |
---|
214 | if hangarReached then |
---|
215 | waveToSpaceship(timestep) |
---|
216 | end |
---|
217 | |
---|
218 | return false |
---|
219 | end |
---|
220 | |
---|