Task priority and path merging

* Potentially fixed issue causing invalid paths
* Fixed issue where gorges wouldn't heal anyone while focused on capping res node or building defensive structures
This commit is contained in:
RGreenlees 2024-05-13 13:14:49 +01:00 committed by pierow
parent ff3b4afb1c
commit d17cb601eb
3 changed files with 26 additions and 23 deletions

View file

@ -2695,8 +2695,6 @@ void CheckAndHandleDoorObstruction(AvHAIPlayer* pBot)
{ {
if (Trigger->TriggerType == DOOR_BUTTON) if (Trigger->TriggerType == DOOR_BUTTON)
{ {
Vector UseLocation = UTIL_GetButtonFloorLocation(pBot->Edict->v.origin, Trigger->Edict);
NAV_SetUseMovementTask(pBot, Trigger->Edict, Trigger); NAV_SetUseMovementTask(pBot, Trigger->Edict, Trigger);
} }
else if (Trigger->TriggerType == DOOR_TRIGGER) else if (Trigger->TriggerType == DOOR_TRIGGER)
@ -6429,7 +6427,7 @@ bool NAV_MergeAndUpdatePath(AvHAIPlayer* pBot, std::vector<bot_path_node>& NewPa
return false; return false;
} }
if (!vEquals(OldPathEnd->FromLocation, NewPathStart->FromLocation, 16.0f) || !vEquals(OldPathEnd->Location, NewPathStart->Location, 16.0f)) if (OldPathEnd->flag != NewPathStart->flag || !vEquals(OldPathEnd->FromLocation, NewPathStart->FromLocation, 16.0f) || !vEquals(OldPathEnd->Location, NewPathStart->Location, 16.0f))
{ {
return false; return false;
} }

View file

@ -4433,30 +4433,29 @@ void AIPlayerNSAlienThink(AvHAIPlayer* pBot)
{ {
if (AlienCombatThink(pBot)) { return; } if (AlienCombatThink(pBot)) { return; }
} }
if (AIPlayerMustFinishCurrentTask(pBot, &pBot->PrimaryBotTask)) bool bPlayerMustFinishPrimaryTask = AIPlayerMustFinishCurrentTask(pBot, &pBot->PrimaryBotTask);
if (!bPlayerMustFinishPrimaryTask)
{ {
BotProgressTask(pBot, &pBot->PrimaryBotTask); UpdateAIAlienPlayerNSRole(pBot);
return;
}
UpdateAIAlienPlayerNSRole(pBot); AvHAIHiveDefinition* HiveToBuild = nullptr;
AvHAIHiveDefinition* HiveToBuild = nullptr; if (AITAC_ShouldBotBuildHive(pBot, &HiveToBuild))
if (AITAC_ShouldBotBuildHive(pBot, &HiveToBuild))
{
if (pBot->PrimaryBotTask.TaskType != TASK_BUILD || pBot->PrimaryBotTask.StructureType != STRUCTURE_ALIEN_HIVE)
{ {
pBot->PrimaryBotTask.TaskType = TASK_BUILD; if (pBot->PrimaryBotTask.TaskType != TASK_BUILD || pBot->PrimaryBotTask.StructureType != STRUCTURE_ALIEN_HIVE)
pBot->PrimaryBotTask.StructureType = STRUCTURE_ALIEN_HIVE; {
char msg[128]; pBot->PrimaryBotTask.TaskType = TASK_BUILD;
sprintf(msg, "I'm going to drop the hive at %s", HiveToBuild->HiveName); pBot->PrimaryBotTask.StructureType = STRUCTURE_ALIEN_HIVE;
BotSay(pBot, true, 1.0f, msg); char msg[128];
sprintf(msg, "I'm going to drop the hive at %s", HiveToBuild->HiveName);
BotSay(pBot, true, 1.0f, msg);
}
BotAlienBuildHive(pBot, &pBot->PrimaryBotTask, HiveToBuild);
return;
} }
BotAlienBuildHive(pBot, &pBot->PrimaryBotTask, HiveToBuild); }
return;
}
if (gpGlobals->time >= pBot->BotNextTaskEvaluationTime) if (gpGlobals->time >= pBot->BotNextTaskEvaluationTime)
{ {
@ -4464,7 +4463,10 @@ void AIPlayerNSAlienThink(AvHAIPlayer* pBot)
AITASK_BotUpdateAndClearTasks(pBot); AITASK_BotUpdateAndClearTasks(pBot);
AIPlayerSetPrimaryAlienTask(pBot, &pBot->PrimaryBotTask); if (!bPlayerMustFinishPrimaryTask)
{
AIPlayerSetPrimaryAlienTask(pBot, &pBot->PrimaryBotTask);
}
AIPlayerSetSecondaryAlienTask(pBot, &pBot->SecondaryBotTask); AIPlayerSetSecondaryAlienTask(pBot, &pBot->SecondaryBotTask);
AIPlayerSetWantsAndNeedsAlienTask(pBot, &pBot->WantsAndNeedsTask); AIPlayerSetWantsAndNeedsAlienTask(pBot, &pBot->WantsAndNeedsTask);
} }

View file

@ -4779,6 +4779,9 @@ bool AITAC_ShouldBotBuildHive(AvHAIPlayer* pBot, AvHAIHiveDefinition** EligibleH
{ {
AvHAIPlayer* OtherBot = (*it); AvHAIPlayer* OtherBot = (*it);
// Another bot already plans to do it
if (OtherBot->PrimaryBotTask.TaskType == TASK_BUILD && OtherBot->PrimaryBotTask.StructureType == STRUCTURE_ALIEN_HIVE) { return false; }
// If the other bot has enough resources to drop a hive, and they're a less expensive life form than us, let them do it. // If the other bot has enough resources to drop a hive, and they're a less expensive life form than us, let them do it.
if (OtherBot->Player->GetResources() >= BALANCE_VAR(kHiveCost) * 0.8f && OtherBot->Player->GetUser3() < pBot->Player->GetUser3()) { return false; } if (OtherBot->Player->GetResources() >= BALANCE_VAR(kHiveCost) * 0.8f && OtherBot->Player->GetUser3() < pBot->Player->GetUser3()) { return false; }
} }