PHP-Code:
def onUnitMove(self, argsList):
'unit move'
pPlot,pUnit,pOldPlot = argsList
player = PyPlayer(pUnit.getOwner())
unitInfo = PyInfo.UnitInfo(pUnit.getUnitType())
###sinking ships start
InitialSinkingChanceOcean = 80
InitialSinkingChanceCoast = 50
SinkingChanceWithCompass = 20
SinkingChanceWithAstronomy = 5
if (pPlot.isWater()) and (not (pPlot.isCity())):
if pUnit.getDomainType ()==gc.getInfoTypeForString("DOMAIN_SEA"):
pPlayer = gc.getPlayer(pUnit.getOwner())
pTeam = gc.getTeam(pPlayer.getTeam())
if pPlot.getTerrainType ()==gc.getInfoTypeForString("TERRAIN_OCEAN"):
SinkChance = InitialSinkingChanceOcean
if pPlot.getTerrainType ()==gc.getInfoTypeForString("TERRAIN_COAST"):
SinkChance = InitialSinkingChanceCoast
if pTeam.isHasTech(gc.getInfoTypeForString("TECH_COMPASS")):
SinkChance = SinkingChanceWithCompass
if pTeam.isHasTech(gc.getInfoTypeForString("TECH_ASTRONOMY")):
SinkChance = SinkingChanceWithAstronomy
SinkingDescission = CyGame().getSorenRandNum(100, "WillItSink")
if SinkingDescission < SinkChance:
iUnitType = pUnit.getUnitType()
strUnitButton = gc.getUnitInfo(iUnitType).getButton ()
iX = pUnit.getX()
iY = pUnit.getY()
pUnit.kill(False,-1)
CyInterface().addMessage(pPlayer.getID(),False,15,CyTranslator().getText("TXT_SHIP_SUNK",()),'',0,strUnitButton,ColorTypes(gc.getInfoTypeForString("COLOR_RED")), iX, iY, True,True)
###sinking ships end
if (not self.__LOG_MOVEMENT):
return
if player and unitInfo:
CvUtil.pyPrint('Player %d Civilization %s unit %s is moving to %d, %d'
%(player.getID(), player.getCivilizationName(), unitInfo.getDescription(),
pUnit.getX(), pUnit.getY()))