CvPlayer::DoUnitReset()
- Defined in
- CvPlayer.cpp, line 5043
- Class
- CvPlayer
- Hook name
CivHooks::CvPlayer_DoUnitReset
Hooks
static bool BeforeCvPlayer_DoUnitReset(CvPlayer* self);static void AfterCvPlayer_DoUnitReset(CvPlayer* self);static void ReplaceCvPlayer_DoUnitReset(void (*original)(CvPlayer*), CvPlayer* self);CivRegisterBefore<CivHooks::CvPlayer_DoUnitReset>(host, &BeforeCvPlayer_DoUnitReset);CivRegisterAfter<CivHooks::CvPlayer_DoUnitReset>(host, &AfterCvPlayer_DoUnitReset);CivRegisterReplace<CivHooks::CvPlayer_DoUnitReset>(host, &ReplaceCvPlayer_DoUnitReset);
Code
5042/// Units heal and then get their movement back5043void CvPlayer::DoUnitReset()5044{5045 CvUnit* pLoopUnit;5046 int iLoop;50475048 for(pLoopUnit = firstUnit(&iLoop); pLoopUnit != NULL; pLoopUnit = nextUnit(&iLoop))5049 {5050 // HEAL UNIT?5051 if(!pLoopUnit->isEmbarked())5052 {5053 if(pLoopUnit->hasMoved())5054 {5055 if(pLoopUnit->isAlwaysHeal())5056 {5057 pLoopUnit->doHeal();5058 }5059 }5060 else5061 {5062 if(pLoopUnit->IsHurt())5063 {5064 pLoopUnit->doHeal();5065 }5066 }5067 }50685069 int iCitadelDamage;5070 if(pLoopUnit->IsNearEnemyCitadel(iCitadelDamage))5071 {5072#if defined(MOD_API_UNIT_STATS)5073 pLoopUnit->changeDamage(iCitadelDamage, NO_PLAYER, -1, /*fAdditionalTextDelay*/ 0.5f);5074#else5075 pLoopUnit->changeDamage(iCitadelDamage, NO_PLAYER, /*fAdditionalTextDelay*/ 0.5f);5076#endif5077 }50785079 // Finally (now that healing is done), restore movement points5080 pLoopUnit->setMoves(pLoopUnit->maxMoves());5081#if defined(MOD_PROMOTIONS_FLAGSHIP)5082 if(pLoopUnit->IsGreatGeneral() || (MOD_PROMOTIONS_FLAGSHIP && pLoopUnit->IsGreatAdmiral()))5083#else5084 if(pLoopUnit->IsGreatGeneral())5085#endif5086 {5087 pLoopUnit->setMoves(pLoopUnit->GetGreatGeneralStackMovement());5088 }50895090 // Archaeologist can't move on turn he finishes a dig (while waiting for user to decide his next action)5091 else if (pLoopUnit->AI_getUnitAIType() == UNITAI_ARCHAEOLOGIST)5092 {5093 CvPlayer &kPlayer = GET_PLAYER(pLoopUnit->getOwner());5094 if (kPlayer.GetCulture()->HasDigCompleteHere(pLoopUnit->plot()))5095 {5096 pLoopUnit->setMoves(0);5097 }5098 }50995100 pLoopUnit->SetIgnoreDangerWakeup(false);5101 pLoopUnit->setMadeAttack(false);5102 pLoopUnit->setMadeInterception(false);51035104 if(!isHuman())5105 {5106 const MissionData* pkMissionData = pLoopUnit->GetHeadMissionData();5107 if(pkMissionData)5108 {5109 if(pkMissionData->eMissionType == CvTypes::getMISSION_RANGE_ATTACK() ||5110 pkMissionData->eMissionType == CvTypes::getMISSION_AIRSTRIKE() ||5111 pkMissionData->eMissionType == CvTypes::getMISSION_AIR_SWEEP() ||5112 pkMissionData->eMissionType == CvTypes::getMISSION_NUKE())5113 {5114 CvAssertMsg(0, "An AI unit has a combat mission queued at the end of its turn.");5115 pLoopUnit->ClearMissionQueue(); // Clear the whole thing, the AI will re-evaluate next turn.5116 }5117 }5118 }5119 }5120}
Calls
- CustomMods::isPROMOTIONS_FLAGSHIP()
- CvPlayer::firstUnit(int *, bool)
- CvPlayer::GetCulture() const
- CvPlayer::isHuman() const
- CvPlayer::nextUnit(int *, bool)
- CvPlayerAI::getPlayer(PlayerTypes)
- CvPlayerCulture::HasDigCompleteHere(CvPlot *) const
- CvTypes::getMISSION_AIR_SWEEP()
- CvTypes::getMISSION_AIRSTRIKE()
- CvTypes::getMISSION_NUKE()
- CvTypes::getMISSION_RANGE_ATTACK()
- CvUnit::AI_getUnitAIType() const
- CvUnit::changeDamage(int, PlayerTypes, int, float, const CvString *)
- CvUnit::ClearMissionQueue(int)
- CvUnit::doHeal()
- CvUnit::GetGreatGeneralStackMovement() const
- CvUnit::GetHeadMissionData()
- CvUnit::getOwner() const
- CvUnit::hasMoved() const
- CvUnit::isAlwaysHeal() const
- CvUnit::isEmbarked() const
- CvUnit::IsGreatAdmiral() const
- CvUnit::IsGreatGeneral() const
- CvUnit::IsHurt() const
- CvUnit::IsNearEnemyCitadel(int &)
- CvUnit::maxMoves() const
- CvUnit::plot() const
- CvUnit::SetIgnoreDangerWakeup(bool)
- CvUnit::setMadeAttack(bool)
- CvUnit::setMadeInterception(bool)
- CvUnit::setMoves(int)