Weld and guard behaviour fix

This commit is contained in:
RGreenlees 2024-03-25 20:46:54 +00:00 committed by pierow
parent 1cd837b372
commit c6344df589
3 changed files with 32 additions and 10 deletions

View file

@ -4641,9 +4641,6 @@ void MoveToWithoutNav(AvHAIPlayer* pBot, const Vector Destination)
bool bumpLeft = !UTIL_QuickHullTrace(pBot->Edict, stTrcLft, endTrcLft, head_hull);
bool bumpRight = !UTIL_QuickHullTrace(pBot->Edict, stTrcRt, endTrcRt, head_hull);
//UTIL_DrawLine(INDEXENT(1), stTrcLft, endTrcLft, 255, 0, 0);
//UTIL_DrawLine(INDEXENT(1), stTrcRt, endTrcRt, 0, 0, 255);
pBot->desiredMovementDir = vForward;
if (bumpRight && !bumpLeft)
@ -8644,12 +8641,23 @@ void NAV_ProgressMovementTask(AvHAIPlayer* pBot)
{
if (IsPlayerInUseRange(pBot->Edict, MoveTask->TaskTarget))
{
Vector BBMin = MoveTask->TaskTarget->v.absmin + Vector(5.0f, 5.0f, 5.0f);
Vector BBMax = MoveTask->TaskTarget->v.absmax - Vector(5.0f, 5.0f, 5.0f);
Vector AimLocation;
vScaleBB(BBMin, BBMax, 0.75f);
if (MoveTask->TaskTarget->v.size.Length2D() < 100.0f)
{
AimLocation = UTIL_GetCentreOfEntity(MoveTask->TaskTarget);
}
else
{
Vector BBMin = MoveTask->TaskTarget->v.absmin + Vector(5.0f, 5.0f, 5.0f);
Vector BBMax = MoveTask->TaskTarget->v.absmax - Vector(5.0f, 5.0f, 5.0f);
BotLookAt(pBot, vClosestPointOnBB(pBot->Edict->v.origin, BBMin, BBMax));
vScaleBB(BBMin, BBMax, 0.75f);
AimLocation = vClosestPointOnBB(pBot->CurrentEyePosition, BBMin, BBMax);
}
BotLookAt(pBot, AimLocation);
pBot->DesiredCombatWeapon = WEAPON_MARINE_WELDER;
if (GetPlayerCurrentWeapon(pBot->Player) != WEAPON_MARINE_WELDER)
@ -8665,6 +8673,10 @@ void NAV_ProgressMovementTask(AvHAIPlayer* pBot)
}
}
MoveTo(pBot, MoveTask->TaskLocation, MOVESTYLE_NORMAL);
}

View file

@ -3293,12 +3293,13 @@ void AIPlayerSetMarineSweeperPrimaryTask(AvHAIPlayer* pBot, AvHAIPlayerTask* Tas
if (AITAC_GetNumDeployablesNearLocation(CommChairLocation, &StructureFilter) < 2)
{
if (Task->TaskType != TASK_GUARD || vDist2DSq(Task->TaskLocation, CommChairLocation) > UTIL_MetresToGoldSrcUnits(10.0f))
if (Task->TaskType != TASK_GUARD || vDist2DSq(Task->TaskLocation, CommChairLocation) > sqrf(UTIL_MetresToGoldSrcUnits(10.0f)))
{
Task->TaskType = TASK_GUARD;
Task->TaskLocation = UTIL_GetRandomPointOnNavmeshInRadius(pBot->BotNavInfo.NavProfile, CommChairLocation, UTIL_MetresToGoldSrcUnits(10.0f));
Task->bTaskIsUrgent = false;
Task->TaskLength = frandrange(20.0f, 30.0f);
Task->TaskStartedTime = 0.0f;
}
return;
}
@ -3333,6 +3334,7 @@ void AIPlayerSetMarineSweeperPrimaryTask(AvHAIPlayer* pBot, AvHAIPlayerTask* Tas
Task->TaskLocation = UTIL_GetRandomPointOnNavmeshInRadius(pBot->BotNavInfo.NavProfile, RandomPG.Location, UTIL_MetresToGoldSrcUnits(5.0f));
Task->bTaskIsUrgent = false;
Task->TaskLength = frandrange(20.0f, 30.0f);
Task->TaskStartedTime = 0.0f;
}
return;
}
@ -6319,6 +6321,8 @@ void AIPlayerSetAlienAssaultPrimaryTask(AvHAIPlayer* pBot, AvHAIPlayerTask* Task
Task->TaskType = TASK_GUARD;
Task->TaskLocation = HiveToGuard->FloorLocation;
Task->TaskTarget = HiveToGuard->HiveEdict;
Task->TaskStartedTime = 0.0f;
Task->TaskLength = 60.0f;
return;
}
else if (HiveToSecure)

View file

@ -529,6 +529,11 @@ bool AITASK_IsGuardTaskStillValid(AvHAIPlayer* pBot, AvHAIPlayerTask* Task)
return false;
}
if (Task->TaskLength > 0.0f && Task->TaskStartedTime > 0.0f)
{
return (gpGlobals->time - Task->TaskStartedTime < Task->TaskLength);
}
return true;
}
@ -1579,8 +1584,9 @@ void MarineProgressBuildTask(AvHAIPlayer* pBot, AvHAIPlayerTask* Task)
void BotProgressGuardTask(AvHAIPlayer* pBot, AvHAIPlayerTask* Task)
{
if (vDist2DSq(pBot->Edict->v.origin, Task->TaskLocation) > sqrf(UTIL_MetresToGoldSrcUnits(5.0f)))
if (vDist2DSq(pBot->Edict->v.origin, Task->TaskLocation) > sqrf(UTIL_MetresToGoldSrcUnits(10.0f)))
{
Task->TaskStartedTime = 0.0f;
if (IsPlayerLerk(pBot->Edict))
{
if (AITAC_ShouldBotBeCautious(pBot))
@ -2483,7 +2489,7 @@ void BotProgressWeldTask(AvHAIPlayer* pBot, AvHAIPlayerTask* Task)
vScaleBB(BBMin, BBMax, 0.75f);
AimLocation = vClosestPointOnBB(pBot->Edict->v.origin, BBMin, BBMax);
AimLocation = vClosestPointOnBB(pBot->CurrentEyePosition, BBMin, BBMax);
}
}