Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 45 additions & 21 deletions src/game/server/neo/bot/behavior/neo_bot_behavior.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -675,9 +675,15 @@ QueryResultType CNEOBotMainAction::ShouldWalk(const CNEOBot *me, const QueryResu
}
}

// Walk if reloading or firing
// Walk if firing or aiming on target
CNEOBaseCombatWeapon *myWeapon = static_cast<CNEOBaseCombatWeapon*>(me->GetActiveWeapon());
if (myWeapon && (myWeapon->m_bInReload || me->m_bOnTarget || me->IsFiring()))
if (myWeapon && (me->m_bOnTarget || me->IsFiring()))
{
return ANSWER_YES;
}

// Walk until reload actually starts so sprint does not block the reload initiation
if (myWeapon && myWeapon->Clip1() <= 0 && !myWeapon->m_bInReload)
{
return ANSWER_YES;
}
Expand All @@ -693,7 +699,18 @@ QueryResultType CNEOBotMainAction::ShouldWalk(const CNEOBot *me, const QueryResu
QueryResultType CNEOBotMainAction::ShouldAim(const CNEOBot *me, const bool bWepHasClip) const
{
auto *pNeoWep = static_cast<CNEOBaseCombatWeapon *>(me->GetActiveWeapon());
if (!bWepHasClip || !pNeoWep)

if (!pNeoWep)
{
return ANSWER_NO;
}

if (!bWepHasClip)
{
return ANSWER_NO;
}

if (pNeoWep->m_bInReload)
{
return ANSWER_NO;
}
Expand Down Expand Up @@ -749,6 +766,10 @@ void CNEOBotMainAction::FireWeaponAtEnemy( CNEOBot *me )
{
if ( myWeapon->Clip1() < myWeapon->GetMaxClip1() )
{
if ( !myWeapon->m_bInReload )
{
me->ReloadIfLowClip(true);
}
return;
}

Expand Down Expand Up @@ -857,6 +878,27 @@ void CNEOBotMainAction::FireWeaponAtEnemy( CNEOBot *me )
me->EquipBestWeaponForThreat(threat, false);
}

if ( myWeapon && me->IsCombatWeapon( myWeapon )
&& !( myWeapon->GetNeoWepBits() & NEO_WEP_BALC )
&& myWeapon->m_iClip1 <= 0 )
{
if (myWeapon->m_bInReload)
{
// passthrough: don't introduce decision jitter
}
else if (IsImmediateThreat(me->GetEntity(), threat) && !m_isWaitingForFullReload)
{
// intention is to swap to secondary if available
me->EquipBestWeaponForThreat(threat, bNotPrimary);
}
else
{
me->ReloadIfLowClip(true);
m_isWaitingForFullReload = true;
}
return;
}

float threatRange = ( threat->GetEntity()->GetAbsOrigin() - me->GetAbsOrigin() ).Length();

// actual head aiming is handled elsewhere, just check if we're on target
Expand Down Expand Up @@ -888,24 +930,6 @@ void CNEOBotMainAction::FireWeaponAtEnemy( CNEOBot *me )
FireBalcAtEnemy( me, myWeapon, threat, threatRange );
return;
}
else if (myWeapon->m_iClip1 <= 0)
{
if (m_isWaitingForFullReload)
{
// passthrough: don't introduce decision jitter
}
else if (IsImmediateThreat(me->GetEntity(), threat) && !m_isWaitingForFullReload)
{
// intention is to swap to secondary if available
me->EquipBestWeaponForThreat(threat, bNotPrimary);
}
else
{
me->ReloadIfLowClip(true);
m_isWaitingForFullReload = true;
}
return;
}

// Even if my weapon is unsuppressed, better than nothing
me->EnableCloak(3.0f);
Expand Down