[4051] | 1 | -- Get objects from orxonox |
---|
| 2 | thisscript:addObject("GenericNPC","guard") |
---|
| 3 | thisscript:addObject("FPSPlayer", "Player") |
---|
| 4 | |
---|
[3945] | 5 | -- Global Variables |
---|
[3947] | 6 | walkingRouteOne = true -- True if thestranger is walking route one |
---|
[3945] | 7 | exitPositionReached = false |
---|
| 8 | playerInLock = false |
---|
| 9 | hangarReached = false |
---|
[4057] | 10 | guardStopped = false |
---|
[3945] | 11 | |
---|
[4063] | 12 | height = 35 |
---|
[3962] | 13 | |
---|
[3946] | 14 | -- Returns the distance between (x1,x2,x3) and (y1,y2,y3) |
---|
| 15 | function dist( x1,x2,x3, y1,y2,y3 ) |
---|
| 16 | return math.sqrt( (x1-y1)^2 + (x2-y2)^2 + (x3-y3)^2 ) |
---|
| 17 | end |
---|
| 18 | |
---|
[3945] | 19 | |
---|
[3946] | 20 | function observePlayer() |
---|
[4057] | 21 | |
---|
| 22 | guardX = guard:getAbsCoorX() |
---|
| 23 | guardY = guard:getAbsCoorY() |
---|
| 24 | guardZ = guard:getAbsCoorZ() |
---|
| 25 | |
---|
[3946] | 26 | playerX = Player:getAbsCoorX() |
---|
| 27 | playerY = Player:getAbsCoorY() |
---|
| 28 | playerZ = Player:getAbsCoorZ() |
---|
| 29 | |
---|
[4057] | 30 | if dist( guardX,guardY,guardZ,playerX, playerX, playerX) > 30 and hangarRouteProgrammed then |
---|
| 31 | --guard:stop() |
---|
| 32 | guardStopped = true |
---|
| 33 | end |
---|
| 34 | |
---|
| 35 | if dist( guardX,guardY,guardZ,playerX, playerX, playerX) < 30 and hangarRouteProgrammed and guardStopped then |
---|
| 36 | --guard:continue() |
---|
| 37 | guardStopped = false |
---|
| 38 | end |
---|
| 39 | |
---|
[3965] | 40 | if dist( playerX,playerY,playerZ,167.361526,29,483.163818 ) < 60 then |
---|
[3947] | 41 | playerInLock = true |
---|
[3945] | 42 | end |
---|
| 43 | |
---|
[3947] | 44 | end |
---|
| 45 | |
---|
| 46 | routeOneProgrammed = false |
---|
[3945] | 47 | function walkRouteOne(timestep) |
---|
| 48 | |
---|
[3947] | 49 | if not routeOneProgrammed then |
---|
[3964] | 50 | guard:walkTo( 266.396362, height, 241.398544) |
---|
| 51 | guard:walkTo( 254.577255, height, 241.159897) |
---|
| 52 | guard:walkTo( 221.120651, height, 240.484360) |
---|
| 53 | guard:walkTo( 187.732651, height, 239.810196) |
---|
| 54 | guard:walkTo( 165.661865, height, 239.364563) |
---|
| 55 | guard:walkTo( 148.642044, height, 239.020889) |
---|
| 56 | guard:walkTo( 128.012802, height, 238.604340) |
---|
| 57 | guard:walkTo( 65.664688, height, 237.345383) |
---|
| 58 | guard:walkTo( 30.099592, height, 236.627243) |
---|
| 59 | guard:walkTo( -14.031926, height, 236.483414) |
---|
| 60 | guard:walkTo( -52.224205, height, 241.776978) |
---|
| 61 | guard:walkTo( -83.528168, height, 245.757629) |
---|
| 62 | guard:walkTo( -98.730980, height, 247.394043) |
---|
| 63 | guard:walkTo( -111.666504, height, 246.585648) |
---|
| 64 | guard:walkTo( -111.666504, height, 246.585648) |
---|
| 65 | guard:walkTo( -114.805542, height, 246.144440) |
---|
| 66 | guard:walkTo( -119.267967, height, 245.360168) |
---|
| 67 | guard:walkTo( -138.284515, height, 239.281021) |
---|
| 68 | guard:walkTo( -146.166840, height, 234.512054) |
---|
| 69 | guard:walkTo( -157.210480, height, 222.620941) |
---|
| 70 | guard:walkTo( -158.519867, height, 219.674301) |
---|
| 71 | guard:walkTo( -158.519867, height, 219.674301) |
---|
| 72 | guard:walkTo( -158.478958, height, 213.490570) |
---|
| 73 | guard:walkTo( -158.478958, height, 213.490570) |
---|
| 74 | guard:walkTo( -155.965332, height, 210.303101) |
---|
| 75 | guard:walkTo( -150.804489, height, 203.959869) |
---|
| 76 | guard:walkTo( -148.853012, height, 201.561295) |
---|
| 77 | guard:walkTo( -145.451157, height, 197.554382) |
---|
| 78 | guard:walkTo( -143.694107, height, 196.373535) |
---|
| 79 | guard:walkTo( -139.281479, height, 193.407990) |
---|
| 80 | guard:walkTo( -137.526047, height, 192.228226) |
---|
| 81 | guard:walkTo( -103.046753, height, 182.510071) |
---|
[3965] | 82 | guard:runTo( -14.992087, height, 181.910767) |
---|
| 83 | guard:runTo( 46.347664, height, 181.493317) |
---|
| 84 | guard:runTo( 86.343376, height, 181.221130) |
---|
| 85 | guard:runTo( 124.465179, height, 194.251617) |
---|
| 86 | guard:runTo( 136.548996, height, 219.682953) |
---|
| 87 | guard:runTo( 145.162140, height, 244.268982) |
---|
| 88 | guard:runTo( 149.328720, height, 256.993256) |
---|
| 89 | guard:runTo( 162.649582, height, 268.181732) |
---|
[3951] | 90 | |
---|
[3947] | 91 | routeOneProgrammed = true |
---|
| 92 | end |
---|
[3945] | 93 | |
---|
[3951] | 94 | if guard:finalGoalReached() then |
---|
| 95 | return false |
---|
[3945] | 96 | end |
---|
| 97 | |
---|
[3951] | 98 | return true |
---|
| 99 | end |
---|
| 100 | |
---|
| 101 | |
---|
| 102 | exitRouteProgrammed = false |
---|
[3945] | 103 | function goToExitPosition(timestep) |
---|
| 104 | |
---|
[3951] | 105 | if not exitRouteProgrammed then |
---|
[3962] | 106 | guard:walkTo( 162.096558, height, 274.944366) |
---|
| 107 | guard:walkTo( 161.519516, height, 286.673370) |
---|
| 108 | guard:walkTo( 161.098618, height, 295.228699) |
---|
| 109 | guard:walkTo( 160.568466, height, 306.004486) |
---|
| 110 | guard:walkTo( 160.151169, height, 314.486572) |
---|
| 111 | guard:walkTo( 159.416641, height, 324.925232) |
---|
| 112 | guard:walkTo( 158.700073, height, 335.108154) |
---|
| 113 | guard:walkTo( 157.943298, height, 345.862610) |
---|
| 114 | guard:walkTo( 157.418381, height, 356.131256) |
---|
| 115 | guard:walkTo( 156.908035, height, 366.115417) |
---|
| 116 | guard:walkTo( 156.940308, height, 377.467712) |
---|
| 117 | guard:walkTo( 156.965408, height, 386.287933) |
---|
| 118 | guard:walkTo( 156.924698, height, 394.296417) |
---|
| 119 | guard:walkTo( 156.816116, height, 401.564911) |
---|
| 120 | guard:walkTo( 156.147583, height, 446.314850) |
---|
| 121 | guard:walkTo( 155.145660, height, 515.473877) |
---|
| 122 | guard:walkTo( 148.450058, height, 524.572571) |
---|
| 123 | guard:walkTo( 135.599609, height, 533.407166) |
---|
| 124 | guard:walkTo( 119.772217, height, 539.609192) |
---|
| 125 | guard:walkTo( 108.926720, height, 537.174927) |
---|
| 126 | guard:walkTo( 100.885788, height, 524.737793) |
---|
| 127 | guard:walkTo( 99.870834, height, 512.540100) |
---|
| 128 | guard:walkTo( 108.219215, height, 502.064178) |
---|
| 129 | |
---|
[3951] | 130 | exitRouteProgrammed = true |
---|
| 131 | end |
---|
| 132 | |
---|
| 133 | if guard:finalGoalReached() and playerInLock then |
---|
| 134 | return true |
---|
| 135 | end |
---|
| 136 | |
---|
[3945] | 137 | return false |
---|
| 138 | end |
---|
| 139 | |
---|
| 140 | |
---|
[3951] | 141 | hangarRouteProgrammed = false |
---|
[3945] | 142 | function goToHangar(timestep) |
---|
| 143 | |
---|
[3964] | 144 | if not hangarRouteProgrammed and playerInLock then |
---|
[4056] | 145 | guard:walkTo( 120.981117, height, 503.008972) |
---|
| 146 | guard:walkTo( 133.354797, height, 504.669128) |
---|
| 147 | guard:walkTo( 147.490158, height, 507.034393) |
---|
| 148 | guard:walkTo( 157.640610, height, 508.901001) |
---|
| 149 | guard:walkTo( 168.830688, height, 510.958710) |
---|
| 150 | guard:walkTo( 185.020630, height, 512.736206) |
---|
| 151 | guard:walkTo( 201.232452, height, 513.413818) |
---|
| 152 | guard:walkTo( 265.666138, height, 513.736023) |
---|
| 153 | guard:walkTo( 362.377960, height, 515.575806) |
---|
| 154 | guard:walkTo( 426.176392, height, 515.666748) |
---|
| 155 | guard:walkTo( 500.031677, height, 515.197266) |
---|
| 156 | guard:walkTo( 551.294250, height, 514.430237) |
---|
| 157 | guard:walkTo( 604.974731, height, 515.106323) |
---|
| 158 | guard:walkTo( 651.117920, height, 516.026550) |
---|
| 159 | guard:walkTo( 664.581909, height, 516.295227) |
---|
| 160 | guard:walkTo( 683.122803, height, 516.665100) |
---|
| 161 | guard:walkTo( 694.547485, height, 516.892944) |
---|
| 162 | guard:walkTo( 704.408569, height, 517.089539) |
---|
| 163 | guard:walkTo( 714.413208, height, 517.289185) |
---|
| 164 | guard:walkTo( 739.045288, height, 515.581970) |
---|
| 165 | guard:walkTo( 763.904541, height, 497.281738) |
---|
| 166 | guard:walkTo( 767.672791, height, 481.974457) |
---|
| 167 | guard:walkTo( 769.436951, height, 468.704559) |
---|
| 168 | guard:walkTo( 770.490967, height, 453.283386) |
---|
| 169 | guard:walkTo( 771.185303, height, 435.960114) |
---|
| 170 | guard:walkTo( 771.952820, height, 379.502045) |
---|
| 171 | guard:walkTo( 771.938293, height, 310.049042) |
---|
| 172 | guard:walkTo( 772.514526, height, 231.579498) |
---|
| 173 | guard:walkTo( 773.601074, height, 135.177933) |
---|
| 174 | guard:walkTo( 773.790771, height, 50.675163) |
---|
| 175 | guard:walkTo( 773.316162, height, -36.961666) |
---|
| 176 | guard:walkTo( 772.885986, height, -116.407944) |
---|
| 177 | guard:walkTo( 772.841309, height, -124.651726) |
---|
| 178 | guard:walkTo( 772.491333, height, -137.742279) |
---|
| 179 | guard:walkTo( 770.644775, height, -153.245926) |
---|
| 180 | guard:walkTo( 768.774414, height, -163.767120) |
---|
| 181 | guard:walkTo( 766.336426, height, -174.224228) |
---|
| 182 | guard:walkTo( 762.794128, height, -187.312271) |
---|
| 183 | guard:walkTo( 733.548279, height, -274.004791) |
---|
| 184 | guard:walkTo( 713.113647, height, -329.657959) |
---|
| 185 | guard:walkTo( 694.801819, height, -379.530243) |
---|
| 186 | guard:walkTo( 681.276062, height, -422.047028) |
---|
| 187 | guard:walkTo( 672.579102, height, -458.540985) |
---|
| 188 | guard:walkTo( 670.843384, height, -465.824615) |
---|
| 189 | guard:walkTo( 669.948364, height, -480.910645) |
---|
| 190 | guard:walkTo( 669.361511, height, -493.648529) |
---|
| 191 | guard:walkTo( 669.686829, height, -501.598572) |
---|
| 192 | guard:walkTo( 674.055664, height, -582.077637) |
---|
| 193 | guard:walkTo( 676.046387, height, -630.403809) |
---|
| 194 | guard:walkTo( 677.839050, height, -674.209534) |
---|
| 195 | guard:walkTo( 680.754944, height, -765.965515) |
---|
| 196 | guard:walkTo( 681.034180, height, -803.351135) |
---|
| 197 | guard:walkTo( 680.088806, height, -844.069031) |
---|
| 198 | guard:walkTo( 677.801514, height, -899.952148) |
---|
| 199 | guard:walkTo( 675.205627, height, -950.496460) |
---|
| 200 | guard:walkTo( 672.847778, height, -996.413574) |
---|
| 201 | guard:walkTo( 676.204041, height, -1043.556274) |
---|
| 202 | guard:walkTo( 691.304382, height, -1088.596558) |
---|
| 203 | guard:walkTo( 705.101318, height, -1128.320312) |
---|
| 204 | guard:walkTo( 720.476013, height, -1164.364380) |
---|
| 205 | guard:walkTo( 729.216797, height, -1183.948364) |
---|
| 206 | guard:walkTo( 740.145203, height, -1212.598267) |
---|
| 207 | guard:walkTo( 746.547363, height, -1238.340576) |
---|
| 208 | guard:walkTo( 756.866211, height, -1280.605347) |
---|
| 209 | guard:walkTo( 763.380554, height, -1314.622314) |
---|
| 210 | guard:walkTo( 768.731506, height, -1347.977539) |
---|
| 211 | guard:walkTo( 772.446655, height, -1381.641479) |
---|
| 212 | guard:walkTo( 772.721069, height, -1421.184937) |
---|
| 213 | guard:walkTo( 772.414734, height, -1457.349121) |
---|
| 214 | guard:walkTo( 772.803284, height, -1489.560913) |
---|
| 215 | |
---|
[3951] | 216 | hangarRouteProgrammed = true |
---|
| 217 | end |
---|
| 218 | |
---|
| 219 | if guard:finalGoalReached() then |
---|
| 220 | return true |
---|
| 221 | end |
---|
| 222 | |
---|
[3945] | 223 | return false |
---|
| 224 | end |
---|
| 225 | |
---|
| 226 | |
---|
| 227 | function waveToSpaceship(timestep) |
---|
| 228 | |
---|
| 229 | end |
---|
| 230 | |
---|
| 231 | |
---|
| 232 | function tick(timestep) |
---|
[3946] | 233 | --io.write("Guard called \n") |
---|
| 234 | observePlayer() |
---|
[3945] | 235 | |
---|
| 236 | if walkingRouteOne then |
---|
[3951] | 237 | walkingRouteOne = walkRouteOne(timestep) |
---|
[3945] | 238 | end |
---|
| 239 | |
---|
| 240 | if not walkingRouteOne and not exitPositionReached then |
---|
| 241 | exitPositionReached = goToExitPosition(timestep) |
---|
| 242 | end |
---|
| 243 | |
---|
[3964] | 244 | if not hangarReached and exitPositionReached then |
---|
[3945] | 245 | hangarReached = goToHangar(timestep) |
---|
| 246 | end |
---|
| 247 | |
---|
| 248 | if hangarReached then |
---|
| 249 | waveToSpaceship(timestep) |
---|
| 250 | end |
---|
| 251 | |
---|
| 252 | return false |
---|
| 253 | end |
---|
| 254 | |
---|