Changeset 3954 for data/branches/single_player_map/scripts
- Timestamp:
- Jun 29, 2006, 7:25:25 PM (18 years ago)
- Location:
- data/branches/single_player_map/scripts
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
data/branches/single_player_map/scripts/prisoner.lua
r3946 r3954 6 6 spaceShipReached = false 7 7 spaceShipEntered = false 8 playerInLock = false 8 9 9 10 randTime = 0 10 11 11 function setCellDoor(timestep) 12 function observeGuard() 13 guardX = guard:getAbsCoorX() 14 guardY = guard:getAbsCoorY() 15 guardZ = guard:getAbsCoorZ() 16 17 if dist( guardX,guardY,guardZ,35.48, 29, 191.28 ) < 60 then 12 18 cellDoorOpened = true 13 return true 14 end 15 16 19 end 20 21 end 22 23 function observePlayer() 24 playerX = Player:getAbsCoorX() 25 playerY = Player:getAbsCoorY() 26 playerZ = Player:getAbsCoorZ() 27 28 if dist( playerX,playerY,playerZ,161.76,49,358.87 ) < 60 then 29 playerInLock = true 30 end 31 32 walkProgrammed = false 33 exitProgrammed = false 17 34 function walkInCell(timestep) 18 35 36 if not walkProgrammed then 37 --io.write("Guard called \n") 38 prisoner:walkTo(-132, 29, 238.381805) 39 prisoner:walkTo(-138.41, 29, 275.25) 40 prisoner:walkTo(-143.70, 29, 275.35) 41 prisoner:walkTo(-149.10, 29, 226.66) 42 prisoner:walkTo(-149.10, 29, 196.83) 43 prisoner:walkTo(-145.82, 29, 189.74) 44 prisoner:walkTo(-138.48, 29, 184.28) 45 prisoner:walkTo(35.48, 29, 191.28) 46 prisoner:runTo(102, 29, 203.28) 47 prisoner:runTo(164, 29, 245.28) 48 49 walkProgrammed = true 50 end 51 19 52 if cellDoorOpened then 20 53 21 if randTime == 0 then 22 randTime = 30 * math.random() 23 else 24 randTime = randTime - timestep 25 end 26 27 if randTime < 0 then 28 -- goto cellexit 29 -- if exit reached: return true 30 end 31 32 end 33 34 35 return false 36 37 end 38 39 40 54 if randTime == 0 then 55 randTime = 30 * math.random() 56 else 57 randTime = randTime - timestep 58 end 59 60 if randTime < 0 then 61 -- goto cellexit 62 if not exitProgrammed then 63 prisoner:walkTo(-132, 29, 238.381805) 64 prisoner:walkTo(-138.41, 29, 275.25) 65 prisoner:walkTo(-143.70, 29, 275.35) 66 prisoner:walkTo(-149.10, 29, 226.66) 67 prisoner:walkTo(-149.10, 29, 196.83) 68 prisoner:walkTo(-145.82, 29, 189.74) 69 prisoner:walkTo(-138.48, 29, 184.28) 70 prisoner:walkTo(35.48, 29, 191.28) 71 prisoner:runTo(102, 29, 203.28) 72 prisoner:runTo(164, 29, 245.28) 73 74 exitProgrammed = true 75 end 76 77 if guard:finalGoalReached() then 78 return true 79 end 80 81 end 82 83 return false 84 end 85 86 87 return false 88 89 end 90 91 92 gotoExitProgrammed = false 41 93 function goToExit(timestep) 42 94 -- do not forget to make him wait until the player triggeres the trip to the hangar 43 44 return false 45 end 46 47 95 if not gotoExitProgrammed and playerInLock then 96 prisoner:walkTo(-132, 29, 238.381805) 97 prisoner:walkTo(-138.41, 29, 275.25) 98 prisoner:walkTo(-143.70, 29, 275.35) 99 prisoner:walkTo(-149.10, 29, 226.66) 100 prisoner:walkTo(-149.10, 29, 196.83) 101 prisoner:walkTo(-145.82, 29, 189.74) 102 prisoner:walkTo(-138.48, 29, 184.28) 103 prisoner:walkTo(35.48, 29, 191.28) 104 prisoner:runTo(102, 29, 203.28) 105 prisoner:runTo(164, 29, 245.28) 106 107 gotoExitProgrammed = true 108 end 109 110 if prisoner:finalGoalReached() then 111 return true 112 end 113 114 return false 115 end 116 117 hangarRouteProgrammed = false 48 118 function goToHangar(timestep) 49 119 50 51 return false 52 53 end 54 55 120 if not hangarRouteProgrammed then 121 prisoner:walkTo(-132, 29, 238.381805) 122 prisoner:walkTo(-138.41, 29, 275.25) 123 prisoner:walkTo(-143.70, 29, 275.35) 124 prisoner:walkTo(-149.10, 29, 226.66) 125 prisoner:walkTo(-149.10, 29, 196.83) 126 prisoner:walkTo(-145.82, 29, 189.74) 127 prisoner:walkTo(-138.48, 29, 184.28) 128 prisoner:walkTo(35.48, 29, 191.28) 129 prisoner:runTo(102, 29, 203.28) 130 prisoner:runTo(164, 29, 245.28) 131 132 hangarRouteProgrammed = true 133 end 134 135 if prisoner:finalGoalReached() then 136 return true 137 end 138 139 return false 140 141 end 142 143 spaceshipRouteProgrammed = false 56 144 function goToSpaceship(timestep) 57 145 146 if not spaceshipRouteProgrammed then 147 prisoner:walkTo(-132, 29, 238.381805) 148 prisoner:walkTo(-138.41, 29, 275.25) 149 prisoner:walkTo(-143.70, 29, 275.35) 150 prisoner:walkTo(-149.10, 29, 226.66) 151 prisoner:walkTo(-149.10, 29, 196.83) 152 prisoner:walkTo(-145.82, 29, 189.74) 153 prisoner:walkTo(-138.48, 29, 184.28) 154 prisoner:walkTo(35.48, 29, 191.28) 155 prisoner:runTo(102, 29, 203.28) 156 prisoner:runTo(164, 29, 245.28) 157 158 spaceshipRouteProgrammed = true 159 end 160 161 if prisoner:finalGoalReached() then 162 return true 163 end 164 58 165 return false 59 166 … … 71 178 72 179 --io.write("Prisoner called \n") 180 181 observeGuard() 182 observePlayer() 183 73 184 74 185 if not cellDoorOpend then -
data/branches/single_player_map/scripts/secondguard.lua
r3951 r3954 9 9 -- Returns the distance between (x1,x2,x3) and (y1,y2,y3) 10 10 function dist( x1,x2,x3, y1,y2,y3 ) 11 12 11 return math.sqrt( (x1-y1)^2 + (x2-y2)^2 + (x3-y3)^2 ) 13 14 12 end 15 13 … … 20 18 guardZ = guard:getAbsCoorZ() 21 19 22 if dist( guardX,guardY,guardZ, 161.76,49,358.87) < 60 then20 if dist( guardX,guardY,guardZ,35.48, 29, 191.28 ) < 60 then 23 21 allOk = false 24 22 end … … 38 36 end 39 37 38 cellProgrammed = false 39 function goToCell(timestep) 40 40 41 function goToCell(timestep) 41 if not cellProgrammed then 42 --io.write("Guard called \n") 43 secondguard:walkTo(-132, 29, 238.381805) 44 secondguard:walkTo(-138.41, 29, 275.25) 45 secondguard:walkTo(-143.70, 29, 275.35) 46 secondguard:walkTo(-149.10, 29, 226.66) 47 secondguard:walkTo(-149.10, 29, 196.83) 48 secondguard:walkTo(-145.82, 29, 189.74) 49 secondguard:walkTo(-138.48, 29, 184.28) 50 secondguard:walkTo(35.48, 29, 191.28) 51 secondguard:runTo(102, 29, 203.28) 52 secondguard:runTo(164, 29, 245.28) 53 54 cellProgrammed = true 55 end 56 57 if secondguard:finalGoalReached() then 58 return true 59 end 42 60 43 61 return false 44 62 end 45 63 64 guideProgrammed = false 46 65 function goToGuidePosition(timestep) 66 67 if not guideProgrammed then 68 --io.write("Guard called \n") 69 secondguard:walkTo(-132, 29, 238.381805) 70 secondguard:walkTo(-138.41, 29, 275.25) 71 secondguard:walkTo(-143.70, 29, 275.35) 72 secondguard:walkTo(-149.10, 29, 226.66) 73 secondguard:walkTo(-149.10, 29, 196.83) 74 secondguard:walkTo(-145.82, 29, 189.74) 75 secondguard:walkTo(-138.48, 29, 184.28) 76 secondguard:walkTo(35.48, 29, 191.28) 77 secondguard:runTo(102, 29, 203.28) 78 secondguard:runTo(164, 29, 245.28) 79 80 guideProgrammed = true 81 end 82 83 if secondguard:finalGoalReached() then 84 return true 85 end 47 86 48 87 return false 49 88 end 50 89 90 hangarProgrammed = false 51 91 function goToHangar(timestep) 52 92 93 if not hangarProgrammed then 94 --io.write("Guard called \n") 95 secondguard:walkTo(-132, 29, 238.381805) 96 secondguard:walkTo(-138.41, 29, 275.25) 97 secondguard:walkTo(-143.70, 29, 275.35) 98 secondguard:walkTo(-149.10, 29, 226.66) 99 secondguard:walkTo(-149.10, 29, 196.83) 100 secondguard:walkTo(-145.82, 29, 189.74) 101 secondguard:walkTo(-138.48, 29, 184.28) 102 secondguard:walkTo(35.48, 29, 191.28) 103 secondguard:runTo(102, 29, 203.28) 104 secondguard:runTo(164, 29, 245.28) 105 106 hangarProgrammed = true 107 end 108 109 if secondguard:finalGoalReached() then 110 return true 111 end 112 53 113 return false 114 54 115 end 55 116
Note: See TracChangeset
for help on using the changeset viewer.