CvUnit::doTurn()
- Defined in
- CvUnit.cpp, line 2086
- Class
- CvUnit
- Hook name
CivHooks::CvUnit_doTurn
Hooks
static bool BeforeCvUnit_doTurn(CvUnit* self);static void AfterCvUnit_doTurn(CvUnit* self);static void ReplaceCvUnit_doTurn(void (*original)(CvUnit*), CvUnit* self);CivRegisterBefore<CivHooks::CvUnit_doTurn>(host, &BeforeCvUnit_doTurn);CivRegisterAfter<CivHooks::CvUnit_doTurn>(host, &AfterCvUnit_doTurn);CivRegisterReplace<CivHooks::CvUnit_doTurn>(host, &ReplaceCvUnit_doTurn);
Code
2086void CvUnit::doTurn()2087{2088 VALIDATE_OBJECT2089 CvAssertMsg(!IsDead(), "isDead did not return false as expected");20902091 // Wake unit if skipped last turn2092 ActivityTypes eActivityType = GetActivityType();2093 bool bHoldCheck = (eActivityType == ACTIVITY_HOLD) && (isHuman() || !getFortifyTurns());2094 bool bHealCheck = (eActivityType == ACTIVITY_HEAL) && (!isHuman() || IsAutomated() || !IsHurt());2095#if defined(MOD_BUGFIX_UNITS_AWAKE_IN_DANGER)2096 if (MOD_BUGFIX_UNITS_AWAKE_IN_DANGER) {2097 // Healing units will awaken if they can see an enemy unit2098 bHealCheck = bHealCheck || ((eActivityType == ACTIVITY_HEAL) && SentryAlert(true));2099 }2100#endif2101 bool bSentryCheck = (eActivityType == ACTIVITY_SENTRY) && SentryAlert();2102 bool bInterceptCheck = eActivityType == ACTIVITY_INTERCEPT && !isHuman();21032104 if (bHoldCheck || bHealCheck || bSentryCheck || bInterceptCheck) 2105 {2106 SetActivityType(ACTIVITY_AWAKE);2107 }21082109 testPromotionReady();21102111#if defined(MOD_API_PLOT_BASED_DAMAGE)2112 if (MOD_API_PLOT_BASED_DAMAGE) {2113 // Do nothing, feature damage is included in with the terrain (mountains) damage taken at the end of the turn2114 } else { 2115#endif2116 FeatureTypes eFeature = plot()->getFeatureType();2117 if(NO_FEATURE != eFeature)2118 {2119 if(0 != GC.getFeatureInfo(eFeature)->getTurnDamage())2120 {2121#if defined(MOD_API_UNIT_STATS)2122 changeDamage(GC.getFeatureInfo(eFeature)->getTurnDamage());2123#else2124 changeDamage(GC.getFeatureInfo(eFeature)->getTurnDamage(), NO_PLAYER);2125#endif2126 }2127 }2128#if defined(MOD_API_PLOT_BASED_DAMAGE)2129 }2130#endif21312132 // Only increase our Fortification level if we've actually been told to Fortify2133 if(IsFortifiedThisTurn())2134 {2135 changeFortifyTurns(1);2136 }21372138 // Recon unit? If so, he sees what's around him2139 if(IsRecon())2140 {2141 setReconPlot(plot());2142 }21432144 // If we're not busy doing anything with the turn cycle, make the Unit's Flag bright again2145 if(GetActivityType() == ACTIVITY_AWAKE)2146 {2147 auto_ptr<ICvUnit1> pDllUnit(new CvDllUnit(this));2148 gDLL->GameplayUnitShouldDimFlag(pDllUnit.get(), /*bDim*/ false);2149 }21502151 // If we told our Unit to sleep last turn and it can now Fortify switch states2152 if(GetActivityType() == ACTIVITY_SLEEP)2153 {2154 if(isFortifyable())2155 {2156 CvUnit::dispatchingNetMessage(true);2157 PushMission(CvTypes::getMISSION_FORTIFY());2158 CvUnit::dispatchingNetMessage(false);2159 SetFortifiedThisTurn(true);2160 }2161 }21622163 doDelayedDeath();2164}
Calls
- CustomMods::isAPI_PLOT_BASED_DAMAGE()
- CustomMods::isBUGFIX_UNITS_AWAKE_IN_DANGER()
- CvDllUnit::CvDllUnit(CvUnit *)
- CvFeatureInfo::getTurnDamage() const
- CvGlobals::getDLLIFace()
- CvGlobals::getFeatureInfo(FeatureTypes)
- CvPlot::getFeatureType() const
- CvTypes::getMISSION_FORTIFY()
- CvUnit::changeDamage(int, PlayerTypes, int, float, const CvString *)
- CvUnit::changeFortifyTurns(int)
- CvUnit::dispatchingNetMessage(bool)
- CvUnit::doDelayedDeath()
- CvUnit::GetActivityType() const
- CvUnit::getFortifyTurns() const
- CvUnit::IsAutomated() const
- CvUnit::IsFortifiedThisTurn() const
- CvUnit::isFortifyable(bool) const
- CvUnit::isHuman() const
- CvUnit::IsHurt() const
- CvUnit::IsRecon() const
- CvUnit::plot() const
- CvUnit::PushMission(MissionTypes, int, int, int, bool, bool, MissionAITypes, CvPlot *, CvUnit *)
- CvUnit::SentryAlert(bool) const
- CvUnit::SetActivityType(ActivityTypes, bool)
- CvUnit::SetFortifiedThisTurn(bool)
- CvUnit::setReconPlot(CvPlot *)
- CvUnit::testPromotionReady()
ICvEngineUtility1::GameplayUnitShouldDimFlagstd::auto_ptr::auto_ptrstd::auto_ptr::get