void CvUnitAI::AI_attackMove()
{
PROFILE_FUNC();
bool bDanger = (GET_PLAYER(getOwnerINLINE()).AI_getPlotDanger(plot(), 3) > 0);
{
PROFILE("CvUnitAI::AI_attackMove() 1");
if (AI_guardCity(true))
{
return;
}
if (AI_heal(30, 1))
{
return;
}
if (!bDanger)
{
if (AI_group(UNITAI_SETTLE, 1, -1, -1, false, false, false, 3, true))
{
return;
}
if (AI_group(UNITAI_SETTLE, 2, -1, -1, false, false, false, 3, true))
{
return;
}
}
if (AI_guardCityAirlift())
{
return;
}
if (AI_guardCity(false, true, 1))
{
return;
}
//join any city attacks in progress
if (plot()->getOwnerINLINE() != getOwnerINLINE())
{
if (AI_groupMergeRange(UNITAI_ATTACK_CITY, 1, true, true))
{
return;
}
}
AreaAITypes eAreaAIType = area()->getAreaAIType(getTeam());
if (plot()->isCity())
{
if (plot()->getOwnerINLINE() == getOwnerINLINE())
{
if ((eAreaAIType == AREAAI_ASSAULT) || (eAreaAIType == AREAAI_ASSAULT_ASSIST))
{
if (AI_offensiveAirlift())
{
return;
}
}
}
}
if (bDanger)
{
if (AI_cityAttack(1, 55))
{
return;
}
if (AI_anyAttack(1, 65))
{
return;
}
if (collateralDamage() > 0)
{
if (AI_anyAttack(1, 45, 3))
{
return;
}
}
}
if (!noDefensiveBonus())
{
if (AI_guardCity(false, false))
{
return;
}
}
if (!bDanger)
{
if (plot()->getOwnerINLINE() == getOwnerINLINE())
{
if (AI_load(UNITAI_SETTLER_SEA, MISSIONAI_LOAD_SETTLER, UNITAI_SETTLE, 3, -1, -1, -1, MOVE_SAFE_TERRITORY, 3))
{
return;
}
if (AI_load(UNITAI_ASSAULT_SEA, MISSIONAI_LOAD_ASSAULT, NO_UNITAI, -1, 2, -1, -1, MOVE_SAFE_TERRITORY, 4))
{
return;
}
if (GET_PLAYER(getOwnerINLINE()).AI_unitTargetMissionAIs(this, MISSIONAI_GROUP) > 0)
{
getGroup()->pushMission(MISSION_SKIP);
return;
}
}
}
if (bDanger)
{
if (AI_pillageRange(1, 20))
{
return;
}
if (AI_cityAttack(1, 35))
{
return;
}
if (AI_anyAttack(1, 45))
{
return;
}
if (AI_pillageRange(3, 20))
{
return;
}
if (AI_choke(1))
{
return;
}
}
if (AI_goody(3))
{
return;
}
if (AI_anyAttack(1, 70))
{
return;
}
}
{
PROFILE("CvUnitAI::AI_attackMove() 2");
if (bDanger)
{
if (AI_cityAttack(4, 30))
{
return;
}
if (AI_anyAttack(2, 40))
{
return;
}
}
if (!isEnemy(plot()->getTeam()))
{
if (AI_heal())
{
return;
}
}
if ((GET_PLAYER(getOwnerINLINE()).AI_getNumAIUnits(UNITAI_CITY_DEFENSE) > 0) || (GET_TEAM(getTeam()).getAtWarCount(true) > 0))
{
if (AI_group(UNITAI_ATTACK_CITY, /*iMaxGroup*/ 1, /*iMaxOwnUnitAI*/ 1, -1, true, true, true, /*iMaxPath*/ 5))
{
return;
}
if (AI_group(UNITAI_ATTACK, /*iMaxGroup*/ 1, /*iMaxOwnUnitAI*/ 1, -1, true, true, false, /*iMaxPath*/ 4))
{
return;
}
if ((getMoves() > 1) && GET_PLAYER(getOwnerINLINE()).AI_isDoStrategy(AI_STRATEGY_FASTMOVERS))
{
if (AI_group(UNITAI_ATTACK, /*iMaxGroup*/ 4, /*iMaxOwnUnitAI*/ 1, -1, true, false, false, /*iMaxPath*/ 3))
{
return;
}
}
}
if (area()->getAreaAIType(getTeam()) != AREAAI_OFFENSIVE)
{
if (area()->getCitiesPerPlayer(BARBARIAN_PLAYER) > 0)
{
if (AI_targetBarbCity())
{
return;
}
}
}
else
{
if (getGroup()->getNumUnits() > 1)
{
if (AI_targetCity())
{
return;
}
}
}
if (AI_guardCity(false, true, 3))
{
return;
}
if ((GET_PLAYER(getOwnerINLINE()).getNumCities() > 1) && (getGroup()->getNumUnits() == 1))
{
if (area()->getAreaAIType(getTeam()) != AREAAI_DEFENSIVE)
{
if (area()->getNumUnrevealedTiles(getTeam()) > 0)
{
if (GET_PLAYER(getOwnerINLINE()).AI_areaMissionAIs(area(), MISSIONAI_EXPLORE, getGroup()) < (GET_PLAYER(getOwnerINLINE()).AI_neededExplorers(area()) + 1))
{
if (AI_exploreRange(3))
{
return;
}
if (AI_explore())
{
return;
}
}
}
}
}
if (AI_protect(35))
{
return;
}
if (AI_offensiveAirlift())
{
return;
}
if (AI_defend())
{
return;
}
if (AI_travelToUpgradeCity())
{
return;
}
if (AI_patrol())
{
return;
}
if (AI_retreatToCity())
{
return;
}
if (AI_safety())
{
return;
}
}
getGroup()->pushMission(MISSION_SKIP);
return;
}