From 0265be247d06e395c9b776ae564bedfa2c9cb390 Mon Sep 17 00:00:00 2001 From: RGreenlees Date: Mon, 13 May 2024 09:36:17 +0100 Subject: [PATCH] Resource capping tweak and comm reminders * Marines will now get close initially to a resource node they want to cap, before guarding it. This fixes the issue in Hera where bots would wait for the RT in cargo to drop but never actually open the door so the commander could drop it * Disabled AI commander reissuing orders to players as a reminder. It was annoying for humans, and pointless for bots since they should always obey it right away anyway --- main/source/mod/AvHAICommander.cpp | 3 +++ main/source/mod/AvHAINavigation.cpp | 10 ++++------ main/source/mod/AvHAITask.cpp | 10 ++++++++++ 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/main/source/mod/AvHAICommander.cpp b/main/source/mod/AvHAICommander.cpp index 65629fa7..bfa87b0a 100644 --- a/main/source/mod/AvHAICommander.cpp +++ b/main/source/mod/AvHAICommander.cpp @@ -379,6 +379,9 @@ bool AICOMM_IsOrderStillValid(AvHAIPlayer* pBot, ai_commander_order* Order) bool AICOMM_DoesPlayerOrderNeedReminder(AvHAIPlayer* pBot, ai_commander_order* Order) { + // For now, disable reminders as it is annoying for humans and pointless for bots who should obey it always anyway + return false; + float NewDist = vDist2DSq(Order->Assignee->v.origin, Order->OrderLocation); float OldDist = Order->LastPlayerDistance; Order->LastPlayerDistance = NewDist; diff --git a/main/source/mod/AvHAINavigation.cpp b/main/source/mod/AvHAINavigation.cpp index 314bf3df..3a10812e 100644 --- a/main/source/mod/AvHAINavigation.cpp +++ b/main/source/mod/AvHAINavigation.cpp @@ -3106,7 +3106,7 @@ edict_t* UTIL_GetDoorBlockingPathPoint(const Vector FromLocation, const Vector T if (MovementFlag == SAMPLE_POLYFLAGS_LADDER || MovementFlag == SAMPLE_POLYFLAGS_WALLCLIMB) { - Vector TargetLoc = Vector(FromLoc.x, FromLoc.y, ToLocation.z); + Vector TargetLoc = (ToLocation.z > FromLocation.z) ? Vector(FromLoc.x, FromLoc.y, ToLoc.z) : Vector(ToLoc.x, ToLoc.y, FromLoc.z); if (!FNullEnt(SearchDoor)) { @@ -3134,11 +3134,9 @@ edict_t* UTIL_GetDoorBlockingPathPoint(const Vector FromLocation, const Vector T } } - Vector TargetLoc2 = Vector(ToLoc.x, ToLoc.y, ToLocation.z); - if (!FNullEnt(SearchDoor)) { - if (vlineIntersectsAABB(FromLoc, TargetLoc2, SearchDoor->v.absmin, SearchDoor->v.absmax)) + if (vlineIntersectsAABB(TargetLoc, ToLoc, SearchDoor->v.absmin, SearchDoor->v.absmax)) { return SearchDoor; } @@ -3147,7 +3145,7 @@ edict_t* UTIL_GetDoorBlockingPathPoint(const Vector FromLocation, const Vector T { for (auto it = NavDoors.begin(); it != NavDoors.end(); it++) { - if (vlineIntersectsAABB(FromLoc, TargetLoc2, it->DoorEdict->v.absmin, it->DoorEdict->v.absmax)) + if (vlineIntersectsAABB(TargetLoc, ToLoc, it->DoorEdict->v.absmin, it->DoorEdict->v.absmax)) { return it->DoorEdict; } @@ -3155,7 +3153,7 @@ edict_t* UTIL_GetDoorBlockingPathPoint(const Vector FromLocation, const Vector T for (auto it = NavWeldableObstacles.begin(); it != NavWeldableObstacles.end(); it++) { - if (vlineIntersectsAABB(FromLoc, TargetLoc2, it->WeldableEdict->v.absmin, it->WeldableEdict->v.absmax)) + if (vlineIntersectsAABB(TargetLoc, ToLoc, it->WeldableEdict->v.absmin, it->WeldableEdict->v.absmax)) { return it->WeldableEdict; } diff --git a/main/source/mod/AvHAITask.cpp b/main/source/mod/AvHAITask.cpp index 2a200767..9eb6d717 100644 --- a/main/source/mod/AvHAITask.cpp +++ b/main/source/mod/AvHAITask.cpp @@ -2978,9 +2978,19 @@ void MarineProgressCapResNodeTask(AvHAIPlayer* pBot, AvHAIPlayerTask* Task) // Empty res node with nothing to do but wait, stick around for 30 seconds and then move on if the commander doesn't drop an RT to build if (Task->TaskLength == 0.0f) { + const AvHAIResourceNode* ResNode = AITAC_GetNearestResourceNodeToLocation(Task->TaskLocation); + + // If we're not at our destination yet, go there + if (vDist2DSq(pBot->Edict->v.origin, ResNode->Location) > sqrf(UTIL_MetresToGoldSrcUnits(1.0f))) + { + MoveTo(pBot, ResNode->Location, MOVESTYLE_NORMAL); + return; + } + Task->TaskStartedTime = gpGlobals->time; Task->TaskLength = 30.0f; } + BotGuardLocation(pBot, Task->TaskLocation); }