Workers only stop on visible danger

whoward69

DLL Minion
Joined
May 30, 2011
Messages
8,699
Location
Near Portsmouth, UK
I've just played one of the most enjoyable 100+ starting turns of a game ever. Despite marauding barbarians, my workers only stopped what they were doing twice.

Code snippet to only stop workers doing what they are doing if the worker can actually see the danger and not just sniff them on the wind!

In CvUnitsMission.cpp

Code:
bool bAbortMission = (!bEscortedBuilder && !hUnit->IsIgnoringDangerWakeup() && !hUnit->IsCombatUnit());
// Stop only if the worker can actually see the enemy
bAbortMission = (bAbortMission && hUnit->SentryAlert());
// or stop if there is any hint of an enemy
// bAbortMission = (bAbortMission && GET_PLAYER(hUnit->getOwner()).GetPlotDanger(*(hUnit->plot())) > 0);

if(bAbortMission)
// if(!bEscortedBuilder && !hUnit->IsIgnoringDangerWakeup() && !hUnit->IsCombatUnit() && GET_PLAYER(hUnit->getOwner()).GetPlotDanger(*(hUnit->plot())) > 0)
 
In theory yes, but unless a fast attack unit, like a horseman, happens to stumble upon them (after all they may be fast but can only still only see two tiles), it's unlikely to happen. The AI is now pretty good at escorting workers (especially the CSes), and escorted units ignored the wake up call anyway. Also, waking a unit that can "sense danger" "from the plains behind the forested hills three tiles away" should really be considered a cheat ;)

But if you want the AI to work the old way, just add in a GET_PLAYER(hUnit->getOwner()).IsHuman() condition to choose between the two statements
 
Top Bottom