Skip to content
Merged
Show file tree
Hide file tree
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
33 changes: 30 additions & 3 deletions src/game/server/neo/bot/behavior/neo_bot_behavior.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ ConVar neo_bot_path_lookahead_range( "neo_bot_path_lookahead_range", "300" );
ConVar neo_bot_sniper_aim_error( "neo_bot_sniper_aim_error", "0.01", FCVAR_CHEAT );
ConVar neo_bot_sniper_aim_steady_rate( "neo_bot_sniper_aim_steady_rate", "10", FCVAR_CHEAT );
ConVar neo_bot_debug_sniper( "neo_bot_debug_sniper", "0", FCVAR_CHEAT );
ConVar neo_bot_fire_weapon_min_time( "neo_bot_fire_weapon_min_time", "1", FCVAR_CHEAT );
ConVar neo_bot_fire_at_breakable_weapon_min_time( "neo_bot_fire_at_breakable_weapon_min_time", "0.4", FCVAR_CHEAT, "Minimum time to fire at breakables", true, 0.0f, true, 60.0f );

ConVar neo_bot_notice_backstab_chance( "neo_bot_notice_backstab_chance", "25", FCVAR_CHEAT );
Expand Down Expand Up @@ -680,6 +679,9 @@ void CNEOBotMainAction::FireWeaponAtEnemy( CNEOBot *me )
vShootablePos = threat->GetEntity()->GetAbsOrigin();
if ( !me->IsLineOfFireClear( vShootablePos, lofFlags ) )
{
// reduce firing at walls after our target ducks behind cover
// also reduces firing through friendlies if they cross our line of fire
me->ReleaseFireButton();
return;
}
}
Expand Down Expand Up @@ -761,7 +763,14 @@ void CNEOBotMainAction::FireWeaponAtEnemy( CNEOBot *me )

if ( me->IsCombatWeapon( myWeapon ) )
{
if (myWeapon->m_iClip1 <= 0)
if (myWeapon->GetNeoWepBits() & NEO_WEP_BALC)
{
// Minimum viable firing BALC
// TODO: Proper heat management for higher difficulty bots
me->PressFireButton(GetFireDurationByDifficulty(me));
return;
}
else if (myWeapon->m_iClip1 <= 0)
{
me->EnableCloak(3.0f);
me->PressCrouchButton(0.3f);
Expand Down Expand Up @@ -795,7 +804,7 @@ void CNEOBotMainAction::FireWeaponAtEnemy( CNEOBot *me )
if ( me->IsContinuousFireWeapon( myWeapon ) )
{
// spray for a bit
me->PressFireButton( neo_bot_fire_weapon_min_time.GetFloat() );
me->PressFireButton( GetFireDurationByDifficulty( me ) );
}
else
{
Expand Down Expand Up @@ -839,6 +848,24 @@ void CNEOBotMainAction::FireWeaponAtEnemy( CNEOBot *me )
}


//---------------------------------------------------------------------------------------------
/**
* Returns fire duration based on difficulty where harder bots waste less ammo spraying
*/
float CNEOBotMainAction::GetFireDurationByDifficulty(CNEOBot* me) const
{
switch (me->GetDifficulty())
{
case CNEOBot::EASY: return 0.5f;
case CNEOBot::NORMAL: return 0.4f;
case CNEOBot::HARD: return 0.3f;
case CNEOBot::EXPERT: return 0.2f;
}

return 0.4f;
}


//---------------------------------------------------------------------------------------------
/**
* If we're outnumbered, retreat and wait for backup - unless we're ubered!
Expand Down
1 change: 1 addition & 0 deletions src/game/server/neo/bot/behavior/neo_bot_behavior.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class CNEOBotMainAction : public Action< CNEOBot >, public CNEOBotContextualQuer
bool m_isWaitingForFullReload;

void FireWeaponAtEnemy( CNEOBot *me );
float GetFireDurationByDifficulty( CNEOBot *me ) const;

CHandle< CBaseEntity > m_lastTouch;
float m_lastTouchTime;
Expand Down