Bazaar developer reference

CvTacticalAI::ProcessDominanceZones()

Defined in
CvTacticalAI.cpp, line 1592
Class
CvTacticalAI
Hook name
CivHooks::CvTacticalAI_ProcessDominanceZones

Hooks

static bool BeforeCvTacticalAI_ProcessDominanceZones(CvTacticalAI* self);static void AfterCvTacticalAI_ProcessDominanceZones(CvTacticalAI* self);static void ReplaceCvTacticalAI_ProcessDominanceZones(void (*original)(CvTacticalAI*), CvTacticalAI* self);CivRegisterBefore<CivHooks::CvTacticalAI_ProcessDominanceZones>(host, &BeforeCvTacticalAI_ProcessDominanceZones);CivRegisterAfter<CivHooks::CvTacticalAI_ProcessDominanceZones>(host, &AfterCvTacticalAI_ProcessDominanceZones);CivRegisterReplace<CivHooks::CvTacticalAI_ProcessDominanceZones>(host, &ReplaceCvTacticalAI_ProcessDominanceZones);

Code

1592void CvTacticalAI::ProcessDominanceZones()1593{1594	CvTacticalDominanceZone* pZone;1595	FStaticVector<CvTacticalMove, 256, true, c_eCiv5GameplayDLL >::iterator it;15961597	// Barbarian processing is straightforward -- just one big list of priorites and everything is considered at once1598	if(m_pPlayer->isBarbarian())1599	{1600		EstablishBarbarianPriorities();1601		ExtractTargetsForZone(NULL);1602		AssignBarbarianMoves();1603	}16041605	else1606	{1607		EstablishTacticalPriorities();1608		UpdatePostures();16091610		// Proceed in priority order1611		for(it = m_MovePriorityList.begin(); it != m_MovePriorityList.end(); it++)1612		{1613			CvTacticalMove move = *it;16141615			if(move.m_iPriority >= 0)1616			{1617				CvTacticalMoveXMLEntry* pkTacticalMoveInfo = GC.getTacticalMoveInfo(move.m_eMoveType);1618				if(pkTacticalMoveInfo && pkTacticalMoveInfo->IsDominanceZoneMove())1619				{1620					for(int iI = 0; iI < m_pMap->GetNumZones(); iI++)1621					{1622						m_iCurrentZoneIndex = iI;1623						pZone = m_pMap->GetZone(iI);1624						AITacticalPosture ePosture = FindPosture(pZone);1625						CvString strMoveName = (CvString)pkTacticalMoveInfo->GetType();1626						CvTacticalMove moveToPassOn = move;16271628						// Is this move of the right type for this zone?1629						bool bMatch = false;1630						if(strMoveName == "TACTICAL_CLOSE_ON_TARGET")    // This one okay for all zones1631						{1632							bMatch = true;1633						}1634						else if(ePosture == AI_TACTICAL_POSTURE_WITHDRAW && strMoveName == "TACTICAL_POSTURE_WITHDRAW")1635						{1636							bMatch = true;1637						}1638						else if(ePosture == AI_TACTICAL_POSTURE_HEDGEHOG && strMoveName == "TACTICAL_POSTURE_HEDGEHOG")1639						{1640							bMatch = true;1641						}1642						else if(ePosture == AI_TACTICAL_POSTURE_SHORE_BOMBARDMENT && strMoveName == "TACTICAL_POSTURE_SHORE_BOMBARDMENT")1643						{1644							bMatch = true;1645						}1646						else if(pZone->GetDominanceFlag() != TACTICAL_DOMINANCE_FRIENDLY && pZone->GetTerritoryType() == TACTICAL_TERRITORY_FRIENDLY && strMoveName == "TACTICAL_EMERGENCY_PURCHASES")1647						{1648							bMatch = true;1649						}1650						else if(pZone->GetDominanceFlag() != TACTICAL_DOMINANCE_FRIENDLY && pZone->GetTerritoryType() == TACTICAL_TERRITORY_FRIENDLY && strMoveName == "TACTICAL_DEFENSIVE_AIRLIFT")1651						{1652							bMatch = true;1653						}1654						else if (strMoveName == "TACTICAL_OFFENSIVE_POSTURE_MOVES")1655						{1656							// If this is an offensive posture move, map us to the detailed move type.  Why?  Well we want these offensive moves1657							// processed in order of zone priority. This allows us to set them all to the same priority but then break them out1658							// into individual move types that get passed into AssignTacticalMove()1659							bMatch = true;1660							1661							switch (ePosture)1662							{1663							case AI_TACTICAL_POSTURE_SIT_AND_BOMBARD:1664								moveToPassOn.m_eMoveType = (TacticalAIMoveTypes)m_CachedInfoTypes[eTACTICAL_POSTURE_SIT_AND_BOMBARD];1665								break;1666							case AI_TACTICAL_POSTURE_ATTRIT_FROM_RANGE:1667								moveToPassOn.m_eMoveType = (TacticalAIMoveTypes)m_CachedInfoTypes[eTACTICAL_POSTURE_ATTRIT_FROM_RANGE];1668								break;1669							case AI_TACTICAL_POSTURE_EXPLOIT_FLANKS:1670								moveToPassOn.m_eMoveType = (TacticalAIMoveTypes)m_CachedInfoTypes[eTACTICAL_POSTURE_EXPLOIT_FLANKS];1671								break;1672							case AI_TACTICAL_POSTURE_STEAMROLL:1673								moveToPassOn.m_eMoveType = (TacticalAIMoveTypes)m_CachedInfoTypes[eTACTICAL_POSTURE_STEAMROLL];1674								break;1675							case AI_TACTICAL_POSTURE_SURGICAL_CITY_STRIKE:1676								moveToPassOn.m_eMoveType = (TacticalAIMoveTypes)m_CachedInfoTypes[eTACTICAL_POSTURE_SURGICAL_CITY_STRIKE];1677								break;1678							case AI_TACTICAL_POSTURE_COUNTERATTACK:1679								moveToPassOn.m_eMoveType = (TacticalAIMoveTypes)m_CachedInfoTypes[eTACTICAL_POSTURE_COUNTERATTACK];1680								break;1681							default:1682								bMatch = false;1683								break;1684							}1685						}16861687						if(bMatch)1688						{1689							if(!UseThisDominanceZone(pZone))1690							{1691								continue;1692							}16931694							ExtractTargetsForZone(pZone);16951696							// Must have some moves to continue or it must be land around an enemy city (which we always want to process because1697							// we might have an operation targeting it)1698							if(m_ZoneTargets.size() <= 0 && pZone->GetTerritoryType() != TACTICAL_TERRITORY_TEMP_ZONE && (pZone->GetTerritoryType() != TACTICAL_TERRITORY_ENEMY || pZone->IsWater()))1699							{1700								continue;1701							}17021703							AssignTacticalMove(moveToPassOn);1704						}1705					}1706				}1707				else1708				{1709					ExtractTargetsForZone(NULL);1710					AssignTacticalMove(move);1711				}1712			}1713		}1714	}1715}

Calls

Called by