Wake a healing unit if an enemy is visible

whoward69

DLL Minion
Joined
May 30, 2011
Messages
8,727
Location
Near Portsmouth, UK
Code snippet to make healing units behave as sentry/alert units rather than fortifying units (ie they will wake up if they see an enemy, rather than sitting there taking more damage!)

In CvUnit.cpp

Code:
bool bHealCheck = (eActivityType == ACTIVITY_HEAL) && (!isHuman() || IsAutomated() || !IsHurt());
[COLOR="Red"]// Healing units will also awaken if they can see an enemy unit
bHealCheck = bHealCheck || ((eActivityType == ACTIVITY_HEAL) && SentryAlert());[/COLOR]
bool bSentryCheck = (eActivityType == ACTIVITY_SENTRY) && SentryAlert();
 
There are also four cases where a unit will sleep through and indirect attack (bombing, long range archery, etc) in CvUnitCombat.cpp when the unit should be woken up - thanks to hulkster for highlighting this issue

Search for

Code:
pk?Defender->SetAutomateType\(NO_AUTOMATE\)

and after each line add

Code:
pDefender->SetAutomateType(NO_AUTOMATE);
[COLOR="Red"]// Wake units that are under active attack (probably being bombed, indirect naval fire, or sneaky long-range archers)
pDefender->SetActivityType(ACTIVITY_AWAKE);[/COLOR]

Note that one of the pointers is pkDefender
 
Back
Top Bottom