Index: /data/branches/single_player_map/scripts/prisoner.lua
===================================================================
--- /data/branches/single_player_map/scripts/prisoner.lua	(revision 3953)
+++ /data/branches/single_player_map/scripts/prisoner.lua	(revision 3954)
@@ -6,54 +6,161 @@
 spaceShipReached = false
 spaceShipEntered = false
+playerInLock = false
 
 randTime = 0
 
-function setCellDoor(timestep)
+function observeGuard()
+guardX = guard:getAbsCoorX()
+guardY = guard:getAbsCoorY()
+guardZ = guard:getAbsCoorZ()
+
+if dist( guardX,guardY,guardZ,35.48, 29, 191.28 ) < 60 then
 cellDoorOpened = true
-return true
-end
-
-
+end
+
+end
+
+function observePlayer()
+playerX = Player:getAbsCoorX()
+playerY = Player:getAbsCoorY()
+playerZ = Player:getAbsCoorZ()
+
+if dist( playerX,playerY,playerZ,161.76,49,358.87 ) < 60 then
+playerInLock = true
+end
+
+walkProgrammed = false
+exitProgrammed = false
 function walkInCell(timestep)
 
+if not walkProgrammed then
+--io.write("Guard called \n")
+prisoner:walkTo(-132, 29, 238.381805)
+prisoner:walkTo(-138.41, 29, 275.25)
+prisoner:walkTo(-143.70, 29, 275.35)
+prisoner:walkTo(-149.10, 29, 226.66)
+prisoner:walkTo(-149.10, 29, 196.83)
+prisoner:walkTo(-145.82, 29, 189.74)
+prisoner:walkTo(-138.48, 29, 184.28)
+prisoner:walkTo(35.48, 29, 191.28)
+prisoner:runTo(102, 29, 203.28)
+prisoner:runTo(164, 29, 245.28)
+
+walkProgrammed = true
+end
+
 if cellDoorOpened then
 
-if randTime == 0 then
-randTime = 30 * math.random()
-else
-randTime = randTime - timestep
-end
-
-if randTime < 0 then
--- goto cellexit
--- if exit reached: return true
-end 
-
-end
-
-
-return false
-
-end
-
-
-
+ if randTime == 0 then
+ randTime = 30 * math.random()
+ else
+ randTime = randTime - timestep
+ end
+
+ if randTime < 0 then
+ -- goto cellexit
+  if not exitProgrammed then
+   prisoner:walkTo(-132, 29, 238.381805)
+   prisoner:walkTo(-138.41, 29, 275.25)
+   prisoner:walkTo(-143.70, 29, 275.35)
+   prisoner:walkTo(-149.10, 29, 226.66)
+   prisoner:walkTo(-149.10, 29, 196.83)
+   prisoner:walkTo(-145.82, 29, 189.74)
+   prisoner:walkTo(-138.48, 29, 184.28)
+   prisoner:walkTo(35.48, 29, 191.28)
+   prisoner:runTo(102, 29, 203.28)
+   prisoner:runTo(164, 29, 245.28)
+
+   exitProgrammed = true
+  end
+
+  if guard:finalGoalReached() then
+   return true
+  end
+
+ end 
+
+return false
+end
+
+
+return false
+
+end
+
+
+gotoExitProgrammed = false
 function goToExit(timestep)
 -- do not forget to make him wait until the player triggeres the trip to the hangar
-
-return false
-end
-
-
+if not gotoExitProgrammed and playerInLock then
+prisoner:walkTo(-132, 29, 238.381805)
+prisoner:walkTo(-138.41, 29, 275.25)
+prisoner:walkTo(-143.70, 29, 275.35)
+prisoner:walkTo(-149.10, 29, 226.66)
+prisoner:walkTo(-149.10, 29, 196.83)
+prisoner:walkTo(-145.82, 29, 189.74)
+prisoner:walkTo(-138.48, 29, 184.28)
+prisoner:walkTo(35.48, 29, 191.28)
+prisoner:runTo(102, 29, 203.28)
+prisoner:runTo(164, 29, 245.28)
+
+gotoExitProgrammed = true
+end
+
+if prisoner:finalGoalReached() then
+   return true
+end
+
+return false
+end
+
+hangarRouteProgrammed = false
 function goToHangar(timestep)
 
-
-return false
-
-end
-
-
+if not hangarRouteProgrammed then
+prisoner:walkTo(-132, 29, 238.381805)
+prisoner:walkTo(-138.41, 29, 275.25)
+prisoner:walkTo(-143.70, 29, 275.35)
+prisoner:walkTo(-149.10, 29, 226.66)
+prisoner:walkTo(-149.10, 29, 196.83)
+prisoner:walkTo(-145.82, 29, 189.74)
+prisoner:walkTo(-138.48, 29, 184.28)
+prisoner:walkTo(35.48, 29, 191.28)
+prisoner:runTo(102, 29, 203.28)
+prisoner:runTo(164, 29, 245.28)
+
+hangarRouteProgrammed = true
+end
+
+if prisoner:finalGoalReached() then
+   return true
+end
+
+return false
+
+end
+
+spaceshipRouteProgrammed = false
 function goToSpaceship(timestep)
 
+if not spaceshipRouteProgrammed then
+prisoner:walkTo(-132, 29, 238.381805)
+prisoner:walkTo(-138.41, 29, 275.25)
+prisoner:walkTo(-143.70, 29, 275.35)
+prisoner:walkTo(-149.10, 29, 226.66)
+prisoner:walkTo(-149.10, 29, 196.83)
+prisoner:walkTo(-145.82, 29, 189.74)
+prisoner:walkTo(-138.48, 29, 184.28)
+prisoner:walkTo(35.48, 29, 191.28)
+prisoner:runTo(102, 29, 203.28)
+prisoner:runTo(164, 29, 245.28)
+
+spaceshipRouteProgrammed = true
+end
+
+if prisoner:finalGoalReached() then
+   return true
+end
+
 return false
 
@@ -71,4 +178,8 @@
 
 --io.write("Prisoner called \n")
+
+ observeGuard()
+ observePlayer()
+
 
 if not cellDoorOpend then
Index: /data/branches/single_player_map/scripts/secondguard.lua
===================================================================
--- /data/branches/single_player_map/scripts/secondguard.lua	(revision 3953)
+++ /data/branches/single_player_map/scripts/secondguard.lua	(revision 3954)
@@ -9,7 +9,5 @@
 -- 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
 
@@ -20,5 +18,5 @@
 guardZ = guard:getAbsCoorZ()
 
-if dist( guardX,guardY,guardZ,161.76,49,358.87 ) < 60 then
+if dist( guardX,guardY,guardZ,35.48, 29, 191.28 ) < 60 then
 allOk = false
 end
@@ -38,18 +36,81 @@
 end
 
+cellProgrammed = false
+function goToCell(timestep)
 
-function goToCell(timestep)
+if not cellProgrammed then
+--io.write("Guard called \n")
+secondguard:walkTo(-132, 29, 238.381805)
+secondguard:walkTo(-138.41, 29, 275.25)
+secondguard:walkTo(-143.70, 29, 275.35)
+secondguard:walkTo(-149.10, 29, 226.66)
+secondguard:walkTo(-149.10, 29, 196.83)
+secondguard:walkTo(-145.82, 29, 189.74)
+secondguard:walkTo(-138.48, 29, 184.28)
+secondguard:walkTo(35.48, 29, 191.28)
+secondguard:runTo(102, 29, 203.28)
+secondguard:runTo(164, 29, 245.28)
+
+cellProgrammed = true
+end
+
+if secondguard:finalGoalReached() then
+return true
+end
 
 return false
 end
 
+guideProgrammed = false
 function goToGuidePosition(timestep)
+
+if not guideProgrammed then
+--io.write("Guard called \n")
+secondguard:walkTo(-132, 29, 238.381805)
+secondguard:walkTo(-138.41, 29, 275.25)
+secondguard:walkTo(-143.70, 29, 275.35)
+secondguard:walkTo(-149.10, 29, 226.66)
+secondguard:walkTo(-149.10, 29, 196.83)
+secondguard:walkTo(-145.82, 29, 189.74)
+secondguard:walkTo(-138.48, 29, 184.28)
+secondguard:walkTo(35.48, 29, 191.28)
+secondguard:runTo(102, 29, 203.28)
+secondguard:runTo(164, 29, 245.28)
+
+guideProgrammed = true
+end
+
+if secondguard:finalGoalReached() then
+return true
+end
 
 return false
 end
 
+hangarProgrammed = false
 function goToHangar(timestep)
 
+if not hangarProgrammed then
+--io.write("Guard called \n")
+secondguard:walkTo(-132, 29, 238.381805)
+secondguard:walkTo(-138.41, 29, 275.25)
+secondguard:walkTo(-143.70, 29, 275.35)
+secondguard:walkTo(-149.10, 29, 226.66)
+secondguard:walkTo(-149.10, 29, 196.83)
+secondguard:walkTo(-145.82, 29, 189.74)
+secondguard:walkTo(-138.48, 29, 184.28)
+secondguard:walkTo(35.48, 29, 191.28)
+secondguard:runTo(102, 29, 203.28)
+secondguard:runTo(164, 29, 245.28)
+
+hangarProgrammed = true
+end
+
+if secondguard:finalGoalReached() then
+return true
+end
+
 return false
+
 end
 
Index: /data/branches/single_player_map/worlds/sp_level_ambush_at_jupiter.oxw
===================================================================
--- /data/branches/single_player_map/worlds/sp_level_ambush_at_jupiter.oxw	(revision 3953)
+++ /data/branches/single_player_map/worlds/sp_level_ambush_at_jupiter.oxw	(revision 3954)
@@ -34,4 +34,5 @@
      <object>GenericNPC, Prisoner</object>
      <object>FPSPlayer, Player</object>
+     <object>GenericNPC, guard</object>
     </Script>
 
