Bazaar developer reference

CvTacticalAI::PlotHealMoves()

Defined in
CvTacticalAI.cpp, line 3042
Class
CvTacticalAI
Hook name
CivHooks::CvTacticalAI_PlotHealMoves

Hooks

static bool BeforeCvTacticalAI_PlotHealMoves(CvTacticalAI* self);static void AfterCvTacticalAI_PlotHealMoves(CvTacticalAI* self);static void ReplaceCvTacticalAI_PlotHealMoves(void (*original)(CvTacticalAI*), CvTacticalAI* self);CivRegisterBefore<CivHooks::CvTacticalAI_PlotHealMoves>(host, &BeforeCvTacticalAI_PlotHealMoves);CivRegisterAfter<CivHooks::CvTacticalAI_PlotHealMoves>(host, &AfterCvTacticalAI_PlotHealMoves);CivRegisterReplace<CivHooks::CvTacticalAI_PlotHealMoves>(host, &ReplaceCvTacticalAI_PlotHealMoves);

Code

3041/// Assigns units to heal3042void CvTacticalAI::PlotHealMoves()3043{3044	list<int>::iterator it;3045	m_CurrentMoveUnits.clear();3046	CvTacticalUnit unit;30473048	// Loop through all recruited units3049	for(it = m_CurrentTurnUnits.begin(); it != m_CurrentTurnUnits.end(); it++)3050	{3051		UnitHandle pUnit = m_pPlayer->getUnit(*it);3052		if(pUnit)3053		{3054			// Am I under 100% health and not embarked or already in a city?3055			if(pUnit->GetCurrHitPoints() < pUnit->GetMaxHitPoints() && !pUnit->isEmbarked() && !pUnit->plot()->isCity())3056			{3057				// If I'm a naval unit I need to be in friendly territory3058				if(pUnit->getDomainType() != DOMAIN_SEA || pUnit->plot()->IsFriendlyTerritory(m_pPlayer->GetID()))3059				{3060					if (!pUnit->IsUnderEnemyRangedAttack())3061					{3062						unit.SetID(pUnit->GetID());3063						m_CurrentMoveUnits.push_back(unit);30643065						if(GC.getLogging() && GC.getAILogging())3066						{3067							CvString strLogString;3068							strLogString.Format("Healing at, X: %d, Y: %d", pUnit->getX(), pUnit->getY());3069							LogTacticalMessage(strLogString);3070						}3071					}3072				}3073			}3074		}3075	}30763077	if(m_CurrentMoveUnits.size() > 0)3078	{3079		ExecuteHeals();3080	}3081}

Calls

Called by