-- Global Variables allOk = true cellReached = false guidePositionReached = false prisonerReachedLock = false hangarReached = false -- 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 observeGuard() guardX = guard:getAbsCoorX() guardY = guard:getAbsCoorY() guardZ = guard:getAbsCoorZ() if dist( guardX,guardY,guardZ,161.76,49,358.87 ) < 60 then allOk = false end end function observePrisoner() prisonerX = Prisoner:getAbsCoorX() prisonerY = Prisoner:getAbsCoorY() prisonerZ = Prisoner:getAbsCoorZ() if dist( prisonerX,prisonerY,prisonerZ,161.76,49,358.87 ) < 60 then prisonerReachedLock = true end end function goToCell(timestep) return false end function goToGuidePosition(timestep) return false end function goToHangar(timestep) return false end function tick(timestep) --io.write("Secondguard called \n") observePrisoner() if not allOk then cellReached = goToCell(timestep) end if cellReached and not guidePositionReached then guidePositionReached = goToGuidePosition(timestep) end if guidePositionReached and prisonerReachedLock then hangarReached = goToHangar(timestep) end if hangarReached then return true end return false end