CvUnit::canRangeStrike() const
- Defined in
- CvUnit.cpp, line 21633
- Class
- CvUnit
- Hook name
CivHooks::CvUnit_canRangeStrike
Hooks
static bool BeforeCvUnit_canRangeStrike(const CvUnit* self, bool& result);static void AfterCvUnit_canRangeStrike(const CvUnit* self, bool& result);static bool ReplaceCvUnit_canRangeStrike(bool (*original)(const CvUnit*), const CvUnit* self);CivRegisterBefore<CivHooks::CvUnit_canRangeStrike>(host, &BeforeCvUnit_canRangeStrike);CivRegisterAfter<CivHooks::CvUnit_canRangeStrike>(host, &AfterCvUnit_canRangeStrike);CivRegisterReplace<CivHooks::CvUnit_canRangeStrike>(host, &ReplaceCvUnit_canRangeStrike);
Code
21633bool CvUnit::canRangeStrike() const21634{21635 VALIDATE_OBJECT21636 if(isEmbarked())21637 {21638 return false;21639 }2164021641 if(GetRange() <= 0)21642 {21643 return false;21644 }2164521646 if(GetBaseRangedCombatStrength() <= 0)21647 {21648 return false;21649 }2165021651 if(isMustSetUpToRangedAttack())21652 {21653 if(!isSetUpForRangedAttack())21654 {21655 return false;21656 }21657 }2165821659 if(isOutOfAttacks())21660 {21661 return false;21662 }2166321664#if defined(MOD_BUGFIX_CITY_STACKING)21665 // Can't attack out of Cities if there are more units of the same domain type than the stacking limit permits21666#if defined(MOD_GLOBAL_STACKING_RULES)21667 if(MOD_BUGFIX_CITY_STACKING && plot()->isCity() && plot()->getNumFriendlyUnitsOfType(this, true) > plot()->getUnitLimit())21668#else21669 if(MOD_BUGFIX_CITY_STACKING && plot()->isCity() && plot()->getNumFriendlyUnitsOfType(this, true) > GC.getPLOT_UNIT_LIMIT())21670#endif21671 {21672 return false;21673 }21674#endif2167521676 return true;21677}
Calls
- CustomMods::isBUGFIX_CITY_STACKING()
- CvPlot::getNumFriendlyUnitsOfType(const CvUnit *, bool) const
- CvPlot::getUnitLimit() const
- CvPlot::isCity() const
- CvUnit::GetBaseRangedCombatStrength() const
- CvUnit::GetRange() const
- CvUnit::isEmbarked() const
- CvUnit::isMustSetUpToRangedAttack() const
- CvUnit::isOutOfAttacks() const
- CvUnit::isSetUpForRangedAttack() const
- CvUnit::plot() const