CvHomelandAI::PlotHealMoves()
- Defined in
- CvHomelandAI.cpp, line 960
- Class
- CvHomelandAI
- Hook name
CivHooks::CvHomelandAI_PlotHealMoves
Hooks
static bool BeforeCvHomelandAI_PlotHealMoves(CvHomelandAI* self);static void AfterCvHomelandAI_PlotHealMoves(CvHomelandAI* self);static void ReplaceCvHomelandAI_PlotHealMoves(void (*original)(CvHomelandAI*), CvHomelandAI* self);CivRegisterBefore<CivHooks::CvHomelandAI_PlotHealMoves>(host, &BeforeCvHomelandAI_PlotHealMoves);CivRegisterAfter<CivHooks::CvHomelandAI_PlotHealMoves>(host, &AfterCvHomelandAI_PlotHealMoves);CivRegisterReplace<CivHooks::CvHomelandAI_PlotHealMoves>(host, &ReplaceCvHomelandAI_PlotHealMoves);
Code
959/// Find out which units would like to heal960void CvHomelandAI::PlotHealMoves()961{962 ClearCurrentMoveUnits();963964 // Loop through all recruited units965 for(list<int>::iterator it = m_CurrentTurnUnits.begin(); it != m_CurrentTurnUnits.end(); ++it)966 {967 UnitHandle pUnit = m_pPlayer->getUnit(*it);968 if(pUnit && !pUnit->isHuman())969 {970#if defined(MOD_AI_SMART_V3)971 int iHealingLimit = pUnit->GetMaxHitPoints();972973 if (MOD_AI_SMART_V3)974 {975 CvPlot* unitPlot = pUnit->plot();976 if (!unitPlot->isCity() && (unitPlot->getOwner() != pUnit->getOwner()) && m_pPlayer->GetPlotDanger(*unitPlot) > 0)977 {978 iHealingLimit /= 2;979 }980 }981982 // Am I under my health limit and not at sea or already in a city?983 if(pUnit->GetCurrHitPoints() < iHealingLimit && !pUnit->isEmbarked() && !pUnit->plot()->isCity())984#else985 // Am I under 100% health and not at sea or already in a city?986 if(pUnit->GetCurrHitPoints() < pUnit->GetMaxHitPoints() && !pUnit->isEmbarked() && !pUnit->plot()->isCity())987#endif988 {989 // If I'm a naval unit I need to be in friendly territory990 if(pUnit->getDomainType() != DOMAIN_SEA || pUnit->plot()->IsFriendlyTerritory(m_pPlayer->GetID()))991 {992 if (!pUnit->IsUnderEnemyRangedAttack())993 {994 CvHomelandUnit unit;995 unit.SetID(pUnit->GetID());996 m_CurrentMoveUnits.push_back(unit);997998 if(GC.getLogging() && GC.getAILogging())999 {1000 CvString strLogString;1001 CvString strTemp;10021003 strTemp = pUnit->getUnitInfo().GetDescription();1004 strLogString.Format("%s healing at, X: %d, Y: %d", strTemp.GetCString(), pUnit->getX(), pUnit->getY());1005 LogHomelandMessage(strLogString);1006 }1007 }1008 }1009 }1010 }1011 }10121013 if(m_CurrentMoveUnits.size() > 0)1014 {1015 ExecuteHeals();1016 }1017}
Calls
BaseVector::size- CustomMods::isAI_SMART_V3()
- CvBaseInfo::GetDescription() const
- CvGlobals::getAILogging()
- CvGlobals::getLogging()
- CvHomelandAI::ClearCurrentMoveUnits()
- CvHomelandAI::ExecuteHeals()
- CvHomelandAI::LogHomelandMessage(CvString &)
- CvHomelandUnit::CvHomelandUnit()
- CvHomelandUnit::SetID(int)
- CvPlayer::GetID() const
- CvPlayer::GetPlotDanger(CvPlot &) const
- CvPlayer::getUnit(int)
- CvPlot::getOwner() const
- CvPlot::isCity() const
- CvPlot::IsFriendlyTerritory(PlayerTypes) const
CvString::CvStringCvString::FormatCvString::GetCStringCvString::operator=- CvUnit::GetCurrHitPoints() const
- CvUnit::getDomainType() const
- CvUnit::GetID() const
- CvUnit::GetMaxHitPoints() const
- CvUnit::getOwner() const
- CvUnit::getUnitInfo() const
- CvUnit::getX() const
- CvUnit::getY() const
- CvUnit::isEmbarked() const
- CvUnit::isHuman() const
- CvUnit::IsUnderEnemyRangedAttack() const
- CvUnit::plot() const
FObjectHandle::FObjectHandleFObjectHandle::operator boolFObjectHandle::operator->FStaticVector::push_backstd::list::_Const_iterator::operator!=std::list::_Iterator::operator*std::list::_Iterator::operator++std::list::beginstd::list::end