-- Global Variables walkingRouteOne = true -- True if thestranger is walking route one exitPositionReached = false playerInLock = false hangarReached = false height = 29 -- Returns the distance between (x1,x2,x3) and (y1,y2,y3) function dist( x1,x2,x3, y1,y2,y3 ) return math.sqrt( (x1-y1)^2 + (x2-y2)^2 + (x3-y3)^2 ) end function observePlayer() playerX = Player:getAbsCoorX() playerY = Player:getAbsCoorY() playerZ = Player:getAbsCoorZ() if dist( playerX,playerY,playerZ,167.361526,29,483.163818 ) < 60 then playerInLock = true end end routeOneProgrammed = false function walkRouteOne(timestep) if not routeOneProgrammed then guard:walkTo( 266.396362, height, 241.398544) guard:walkTo( 254.577255, height, 241.159897) guard:walkTo( 221.120651, height, 240.484360) guard:walkTo( 187.732651, height, 239.810196) guard:walkTo( 165.661865, height, 239.364563) guard:walkTo( 148.642044, height, 239.020889) guard:walkTo( 128.012802, height, 238.604340) guard:walkTo( 65.664688, height, 237.345383) guard:walkTo( 30.099592, height, 236.627243) guard:walkTo( -14.031926, height, 236.483414) guard:walkTo( -52.224205, height, 241.776978) guard:walkTo( -83.528168, height, 245.757629) guard:walkTo( -98.730980, height, 247.394043) guard:walkTo( -111.666504, height, 246.585648) guard:walkTo( -111.666504, height, 246.585648) guard:walkTo( -114.805542, height, 246.144440) guard:walkTo( -119.267967, height, 245.360168) guard:walkTo( -138.284515, height, 239.281021) guard:walkTo( -146.166840, height, 234.512054) guard:walkTo( -157.210480, height, 222.620941) guard:walkTo( -158.519867, height, 219.674301) guard:walkTo( -158.519867, height, 219.674301) guard:walkTo( -158.478958, height, 213.490570) guard:walkTo( -158.478958, height, 213.490570) guard:walkTo( -155.965332, height, 210.303101) guard:walkTo( -150.804489, height, 203.959869) guard:walkTo( -148.853012, height, 201.561295) guard:walkTo( -145.451157, height, 197.554382) guard:walkTo( -143.694107, height, 196.373535) guard:walkTo( -139.281479, height, 193.407990) guard:walkTo( -137.526047, height, 192.228226) guard:walkTo( -103.046753, height, 182.510071) guard:runTo( -14.992087, height, 181.910767) guard:runTo( 46.347664, height, 181.493317) guard:runTo( 86.343376, height, 181.221130) guard:runTo( 124.465179, height, 194.251617) guard:runTo( 136.548996, height, 219.682953) guard:runTo( 145.162140, height, 244.268982) guard:runTo( 149.328720, height, 256.993256) guard:runTo( 162.649582, height, 268.181732) routeOneProgrammed = true end if guard:finalGoalReached() then return false end return true end exitRouteProgrammed = false function goToExitPosition(timestep) if not exitRouteProgrammed then guard:walkTo( 162.096558, height, 274.944366) guard:walkTo( 161.519516, height, 286.673370) guard:walkTo( 161.098618, height, 295.228699) guard:walkTo( 160.568466, height, 306.004486) guard:walkTo( 160.151169, height, 314.486572) guard:walkTo( 159.416641, height, 324.925232) guard:walkTo( 158.700073, height, 335.108154) guard:walkTo( 157.943298, height, 345.862610) guard:walkTo( 157.418381, height, 356.131256) guard:walkTo( 156.908035, height, 366.115417) guard:walkTo( 156.940308, height, 377.467712) guard:walkTo( 156.965408, height, 386.287933) guard:walkTo( 156.924698, height, 394.296417) guard:walkTo( 156.816116, height, 401.564911) guard:walkTo( 156.147583, height, 446.314850) guard:walkTo( 155.145660, height, 515.473877) guard:walkTo( 148.450058, height, 524.572571) guard:walkTo( 135.599609, height, 533.407166) guard:walkTo( 119.772217, height, 539.609192) guard:walkTo( 108.926720, height, 537.174927) guard:walkTo( 100.885788, height, 524.737793) guard:walkTo( 99.870834, height, 512.540100) guard:walkTo( 108.219215, height, 502.064178) exitRouteProgrammed = true end if guard:finalGoalReached() and playerInLock then return true end return false end hangarRouteProgrammed = false function goToHangar(timestep) if not hangarRouteProgrammed and playerInLock then guard:walkTo( 138.422943, height, 504.832733) guard:walkTo( 188.685089, height, 509.034851) guard:walkTo( 259.451904, height, 515.326111) guard:walkTo( 351.655762, height, 519.210571) guard:walkTo( 495.821381, height, 517.551392) guard:walkTo( 650.267029, height, 516.826843) guard:walkTo( 752.277100, height, 506.265289) guard:walkTo( 780.652405, height, 397.283752) guard:walkTo( 780.212830, height, 317.386017) guard:walkTo( 778.699158, height, 241.875305) guard:walkTo( 776.305542, height, 120.869957) guard:walkTo( 774.626343, height, 26.204597) guard:walkTo( 773.148804, height, -30.654911) guard:walkTo( 771.164978, height, -106.990250) guard:walkTo( 756.719971, height, -197.656296) guard:walkTo( 730.690796, height, -269.808075) guard:walkTo( 702.250854, height, -341.732147) guard:walkTo( 681.786011, height, -393.487030) guard:walkTo( 664.005981, height, -441.609131) guard:walkTo( 655.612671, height, -523.194153) guard:walkTo( 664.289978, height, -585.003540) guard:walkTo( 670.221069, height, -645.366333) guard:walkTo( 674.347290, height, -704.953674) guard:walkTo( 677.495605, height, -750.421082) guard:walkTo( 680.699280, height, -796.687073) guard:walkTo( 686.407043, height, -879.117859) guard:walkTo( 692.573364, height, -952.031555) guard:walkTo( 701.940552, height, -1025.037964) guard:walkTo( 710.218628, height, -1086.598389) guard:walkTo( 719.834900, height, -1142.248779) guard:walkTo( 731.087158, height, -1198.201538) guard:walkTo( 745.157715, height, -1258.461182) guard:walkTo( 753.189331, height, -1290.539551) guard:walkTo( 763.940369, height, -1347.249268) guard:walkTo( 768.509949, height, -1377.040039) guard:walkTo( 770.845215, height, -1408.751953) guard:walkTo( 770.785583, height, -1435.573608) guard:walkTo( 765.031799, height, -1462.657593) guard:walkTo( 753.982727, height, -1483.425415) guard:walkTo( 735.194580, height, -1500.978394) guard:walkTo( 707.312500, height, -1514.814575) guard:walkTo( 672.638550, height, -1522.803589) guard:walkTo( 560.158936, height, -1530.277344) guard:walkTo( 500.429626, height, -1532.241577) guard:walkTo( 371.231262, height, -1535.953613) guard:walkTo( 204.211609, height, -1539.026611) guard:walkTo( 104.032593, height, -1546.350220) guard:walkTo( 45.058315, height, -1550.720337) guard:walkTo( 1.504358, height, -1574.713745) guard:walkTo( -20.050890, height, -1627.849854) guard:walkTo( -28.036245, height, -1674.240479) guard:walkTo( -29.157598, height, -1702.924316) guard:walkTo( -29.760004, height, -1730.014526) guard:walkTo( -29.538343, height, -1759.887329) guard:walkTo( -21.584003, height, -1790.162842) guard:walkTo( -8.572795, height, -1823.067871) guard:walkTo( 13.254844, height, -1861.705688) hangarRouteProgrammed = true end if guard:finalGoalReached() then return true end return false end function waveToSpaceship(timestep) end function tick(timestep) --io.write("Guard called \n") observePlayer() if walkingRouteOne then walkingRouteOne = walkRouteOne(timestep) end if not walkingRouteOne and not exitPositionReached then exitPositionReached = goToExitPosition(timestep) end if not hangarReached and exitPositionReached then hangarReached = goToHangar(timestep) end if hangarReached then waveToSpaceship(timestep) end return false end