void CvGame::updateMoves()
{
[...]
if (!(player.hasBusyUnit()))
{
/*************************************************************************************************/
/** BETTER AI (Unloading Transports in Danger at end of turn) Sephi **/
/** **/
/*************************************************************************************************/
if (!player.isHuman())
{
for(CvUnit* pLoopUnit = player.firstUnit(&iLoop); pLoopUnit != NULL; pLoopUnit = player.nextUnit(&iLoop))
{
if(pLoopUnit->canUnloadAll() && (!pLoopUnit->plot()->isWater()))
{
bool bDanger=false;
// Are we in Danger?
int iOurDefense = player.AI_getOurPlotStrength(pLoopUnit->plot(), 0, true, false);
int iEnemyOffense = player.AI_getEnemyPlotStrength(pLoopUnit->plot(), 4, false, true);
if (iOurDefense < iEnemyOffense)
{
bDanger = true;
}
if (bDanger)
{
pLoopUnit->unloadAll();
}
}
}
}
/*************************************************************************************************/
/** END **/
/*************************************************************************************************/
player.setAutoMoves(false);
}
}
}
}
}
}
in player.h
/*************************************************************************************************/
/** BETTER AI (Unloading Transports in Danger at end of turn) Sephi **/
/** Make sure we can call these functions in CvGame.cpp **/
/*************************************************************************************************/
virtual int AI_getOurPlotStrength(CvPlot* pPlot, int iRange, bool bDefensiveBonuses, bool bTestMoves) const = 0;
virtual int AI_getEnemyPlotStrength(CvPlot* pPlot, int iRange, bool bDefensiveBonuses, bool bTestMoves) const = 0;
/*************************************************************************************************/
/** END **/
/*************************************************************************************************/