Bazaar developer reference

CvHomelandAI::ExecuteMissionaryMoves()

Defined in
CvHomelandAI.cpp, line 4445
Class
CvHomelandAI
Hook name
CivHooks::CvHomelandAI_ExecuteMissionaryMoves

Hooks

static bool BeforeCvHomelandAI_ExecuteMissionaryMoves(CvHomelandAI* self);static void AfterCvHomelandAI_ExecuteMissionaryMoves(CvHomelandAI* self);static void ReplaceCvHomelandAI_ExecuteMissionaryMoves(void (*original)(CvHomelandAI*), CvHomelandAI* self);CivRegisterBefore<CivHooks::CvHomelandAI_ExecuteMissionaryMoves>(host, &BeforeCvHomelandAI_ExecuteMissionaryMoves);CivRegisterAfter<CivHooks::CvHomelandAI_ExecuteMissionaryMoves>(host, &AfterCvHomelandAI_ExecuteMissionaryMoves);CivRegisterReplace<CivHooks::CvHomelandAI_ExecuteMissionaryMoves>(host, &ReplaceCvHomelandAI_ExecuteMissionaryMoves);

Code

4444// Get a missionary to the best city, then spread the word4445void CvHomelandAI::ExecuteMissionaryMoves()4446{4447	FStaticVector< CvHomelandUnit, 64, true, c_eCiv5GameplayDLL >::iterator it;4448	for(it = m_CurrentMoveUnits.begin(); it != m_CurrentMoveUnits.end(); ++it)4449	{4450		UnitHandle pUnit = m_pPlayer->getUnit(it->GetID());4451		if(!pUnit)4452		{4453			continue;4454		}44554456		int iTargetTurns;4457		CvPlot* pTarget = m_pPlayer->GetReligionAI()->ChooseMissionaryTargetPlot(pUnit, &iTargetTurns);4458		if(pTarget)4459		{4460			if(pUnit->plot() == pTarget)4461			{4462				pUnit->PushMission(CvTypes::getMISSION_SPREAD_RELIGION());44634464				if(GC.getLogging() && GC.getAILogging())4465				{4466					CvString strLogString;4467					strLogString.Format("Spreading religion, X: %d, Y: %d", pTarget->getX(), pTarget->getY());4468					LogHomelandMessage(strLogString);4469				}4470			}4471			else if(iTargetTurns < 1)4472			{4473				pUnit->PushMission(CvTypes::getMISSION_MOVE_TO(), pTarget->getX(), pTarget->getY());44744475				if(pUnit->plot() == pTarget && pUnit->canMove())4476				{4477					pUnit->PushMission(CvTypes::getMISSION_SPREAD_RELIGION());44784479					if(GC.getLogging() && GC.getAILogging())4480					{4481						CvString strLogString;4482						strLogString.Format("Move to spread religion, X: %d, Y: %d", pTarget->getX(), pTarget->getY());4483						LogHomelandMessage(strLogString);4484					}4485				}4486				else4487				{4488					CvAssertMsg(false, "Internal error with Missionary AI move, contact Ed.");4489				}4490			}4491			else4492			{4493				m_CurrentBestMoveHighPriorityUnit = NULL;4494				m_CurrentBestMoveUnit = m_pPlayer->getUnit(it->GetID());4495				ExecuteMoveToTarget(pTarget);44964497				if(GC.getLogging() && GC.getAILogging())4498				{4499					CvString strLogString;4500					strLogString.Format("Moving to plot adjacent to conversion city, X: %d, Y: %d, Currently at, X: %d, Y: %d", pTarget->getX(), pTarget->getY(), pUnit->getX(), pUnit->getY());4501					LogHomelandMessage(strLogString);4502				}4503			}4504		}4505	}4506}

Calls

Called by