Skip to content

Commit

Permalink
Tweak to commander prioritisation
Browse files Browse the repository at this point in the history
* Commander now prioritises different actions based on whether they're important or not
* Commander will not overwrite an action if it's urgent
  • Loading branch information
RGreenlees committed Aug 31, 2023
1 parent a8f802e commit 2625bac
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions evobot/src/bot_commander.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -944,8 +944,15 @@ bool COMM_IsWaitingOnBuildLink(bot_t* CommanderBot)

commander_action* COMM_GetNextAction(bot_t* CommanderBot)
{
if (CommanderBot->SupportAction.bIsActionUrgent) { return &CommanderBot->SupportAction; }

if (CommanderBot->BuildAction.bIsActionUrgent) { return &CommanderBot->BuildAction; }

if (CommanderBot->ResearchAction.bIsActionUrgent) { return &CommanderBot->ResearchAction; }

if (CommanderBot->RecycleAction.bIsActionUrgent) { return &CommanderBot->RecycleAction; }


if (CommanderBot->RecycleAction.ActionType != ACTION_NONE) { return &CommanderBot->RecycleAction; }

if (CommanderBot->ResearchAction.ActionType != ACTION_NONE) { return &CommanderBot->ResearchAction; }
Expand All @@ -954,6 +961,7 @@ commander_action* COMM_GetNextAction(bot_t* CommanderBot)

if (CommanderBot->BuildAction.ActionType != ACTION_NONE) { return &CommanderBot->BuildAction; }


return nullptr;
}

Expand Down Expand Up @@ -2611,6 +2619,8 @@ void COMM_SetNextSecureHiveAction(bot_t* CommanderBot, const hive_definition* Hi

void COMM_SetNextResearchAction(commander_action* Action)
{
if (Action->ActionType != ACTION_NONE && Action->bIsActionUrgent) { return; }

if (UTIL_ArmouryResearchIsAvailable(RESEARCH_ARMOURY_GRENADES))
{
if (Action->ActionType == ACTION_RESEARCH && Action->ResearchId == RESEARCH_ARMOURY_GRENADES) { return; }
Expand Down Expand Up @@ -3044,6 +3054,8 @@ void COMM_SetElectrifyStructureAction(edict_t* Structure, commander_action* Acti

void COMM_SetNextSupportAction(bot_t* CommanderBot, commander_action* Action)
{
if (Action->ActionType != ACTION_NONE && Action->bIsActionUrgent) { return; }

edict_t* Armoury = UTIL_GetNearestStructureOfTypeInLocation(STRUCTURE_MARINE_ANYARMOURY, UTIL_GetCommChairLocation(), UTIL_MetresToGoldSrcUnits(15.0f), true, false);

if (FNullEnt(Armoury))
Expand Down Expand Up @@ -3223,6 +3235,8 @@ void COMM_SetNextSupportAction(bot_t* CommanderBot, commander_action* Action)

void COMM_SetNextRecycleAction(bot_t* CommanderBot, commander_action* Action)
{
if (Action->ActionType != ACTION_NONE && Action->bIsActionUrgent) { return; }

edict_t* RedundantStructure = UTIL_GetRedundantMarineStructureOfType(STRUCTURE_MARINE_PHASEGATE);

if (!FNullEnt(RedundantStructure))
Expand Down Expand Up @@ -3262,6 +3276,8 @@ void COMM_SetNextRecycleAction(bot_t* CommanderBot, commander_action* Action)

void COMM_SetNextBuildAction(bot_t* CommanderBot, commander_action* Action)
{
if (Action->ActionType != ACTION_NONE && Action->bIsActionUrgent) { return; }

edict_t* CommChair = UTIL_GetCommChair();

if (FNullEnt(CommChair)) { return; }
Expand Down

0 comments on commit 2625bac

Please sign in to comment.