Skip to content
Open
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: 29 additions & 4 deletions src/game/server/neo/bot/behavior/neo_bot_behavior.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "bot/behavior/nav_entities/neo_bot_nav_ent_move_to.h"
#include "bot/behavior/nav_entities/neo_bot_nav_ent_wait.h"
#include "bot/behavior/neo_bot_tactical_monitor.h"
#include "weapons/weapon_balc.h"

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 );
Expand Down Expand Up @@ -828,10 +829,7 @@ void CNEOBotMainAction::FireWeaponAtEnemy( CNEOBot *me )
{
if (myWeapon->GetNeoWepBits() & NEO_WEP_BALC)
{
// Minimum viable firing BALC
// TODO: Proper heat management for higher difficulty bots
me->ReleaseWalkButton(); // NEO Jank: this actually cancels sprint
me->PressFireButton(GetFireDurationByDifficulty(me));
FireBalcAtEnemy( me, myWeapon, threat, threatRange );
return;
}
else if (myWeapon->m_iClip1 <= 0)
Expand Down Expand Up @@ -903,6 +901,33 @@ void CNEOBotMainAction::FireWeaponAtEnemy( CNEOBot *me )
}


//---------------------------------------------------------------------------------------------
void CNEOBotMainAction::FireBalcAtEnemy( CNEOBot *me, CNEOBaseCombatWeapon *myWeapon, const CKnownEntity *threat, float threatRange )
{
Assert( myWeapon->GetNeoWepBits() & NEO_WEP_BALC );
auto *pBalc = static_cast<CWeaponBALC *>( myWeapon );
me->ReleaseWalkButton(); // NEO Jank: this actually cancels sprint

// NEO JANK: To simplify alt fire input management
// we allow the bot to bypass button-hold charge firing requirement
// with approximation of charge fire delay
if ( threatRange > 300.0f && ( me->GetTimeSinceWeaponFired() > pBalc->GetChargeDuration() * 1.2f ) )
{
// Check if threat is clearly exposed for a shot
const CNavArea *meArea = me->GetLastKnownArea();
const CNavArea *targetArea = TheNavMesh->GetNearestNavArea( threat->GetEntity()->GetAbsOrigin() );
if ( meArea && targetArea && meArea->IsCompletelyVisible( targetArea ) )
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a PVS visibility check so that bots are discouraged from launching grenades into areas that are either too elevated or there is occluding cover.

{
pBalc->ShootGrenade( me );
return;
}
}

// Fallback to using the primary fire mode
me->PressFireButton( GetFireDurationByDifficulty( me ) );
}


//---------------------------------------------------------------------------------------------
/**
* Returns fire duration based on difficulty where harder bots waste less ammo spraying
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 );
void FireBalcAtEnemy( CNEOBot *me, CNEOBaseCombatWeapon *myWeapon, const CKnownEntity *threat, float threatRange );
float GetFireDurationByDifficulty( CNEOBot *me ) const;

CHandle< CBaseEntity > m_lastTouch;
Expand Down
16 changes: 16 additions & 0 deletions src/game/server/neo/bot/behavior/neo_bot_jgr_juggernaut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include "bot/neo_bot.h"
#include "bot/neo_bot_path_compute.h"
#include "bot/behavior/neo_bot_jgr_juggernaut.h"
#include "bot/behavior/neo_bot_retreat_to_cover.h"
#include "weapon_balc.h"

//---------------------------------------------------------------------------------------------
ActionResult< CNEOBot > CNEOBotJgrJuggernaut::OnStart( CNEOBot *me, Action< CNEOBot > *priorAction )
Expand All @@ -25,6 +27,20 @@ ActionResult< CNEOBot > CNEOBotJgrJuggernaut::OnStart( CNEOBot *me, Action< CNEO
//---------------------------------------------------------------------------------------------
ActionResult< CNEOBot > CNEOBotJgrJuggernaut::Update( CNEOBot *me, float interval )
{
CBaseCombatWeapon *pWeapon = me->GetActiveWeapon();
if ( pWeapon )
{
CNEOBaseCombatWeapon *pNeoWep = dynamic_cast< CNEOBaseCombatWeapon * >( pWeapon );
if ( pNeoWep && ( pNeoWep->GetNeoWepBits() & NEO_WEP_BALC ) )
{
CWeaponBALC *pBalc = static_cast< CWeaponBALC * >( pNeoWep );
if ( pBalc->m_bOverheated )
{
return SuspendFor( new CNEOBotRetreatToCover(), "BALC overheated - retreating to cover!" );
}
}
}

ActionResult< CNEOBot > result = UpdateCommon( me, interval );
if ( result.IsRequestingChange() || result.IsDone() )
return result;
Expand Down
88 changes: 51 additions & 37 deletions src/game/shared/neo/weapons/weapon_balc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,61 +137,75 @@ void CWeaponBALC::PrimaryAttack(void)
}

auto pPlayer = ToNEOPlayer(GetOwner());
if (!pPlayer)
{
Assert(false);
return;
}
ShootGrenade(pPlayer);
}
}

if ((gpGlobals->curtime - m_flLastAttackTime) > 0.5f)
{
m_nNumShotsFired = 0;
}
else
{
++m_nNumShotsFired;
}
m_flLastAttackTime = gpGlobals->curtime;
void CWeaponBALC::ShootGrenade(CNEO_Player *pPlayer)
{
if (!pPlayer)
{
Assert(false);
return;
}

SendWeaponAnim(GetPrimaryAttackActivity());
SetWeaponIdleTime(gpGlobals->curtime + 2.0);
pPlayer->DoAnimationEvent(PLAYERANIMEVENT_ATTACK_PRIMARY);
if ((gpGlobals->curtime - m_flLastAttackTime) > 0.5f)
{
m_nNumShotsFired = 0;
}
else
{
++m_nNumShotsFired;
}
m_flLastAttackTime = gpGlobals->curtime;

WeaponSound(BURST);
SendWeaponAnim(GetPrimaryAttackActivity());
SetWeaponIdleTime(gpGlobals->curtime + 2.0);
pPlayer->DoAnimationEvent(PLAYERANIMEVENT_ATTACK_PRIMARY);

WeaponSound(BURST);

#ifdef GAME_DLL
const Vector vecSrc = pPlayer->Weapon_ShootPosition();
Vector vecThrow;
const Vector vecSrc = pPlayer->Weapon_ShootPosition();
Vector vecThrow;

AngleVectors(pPlayer->EyeAngles() + pPlayer->GetPunchAngle(), &vecThrow);
VectorScale(vecThrow, 2000.0f, vecThrow);
AngleVectors(pPlayer->EyeAngles() + pPlayer->GetPunchAngle(), &vecThrow);
VectorScale(vecThrow, 2000.0f, vecThrow);

QAngle angles;
VectorAngles(vecThrow, angles);
CGrenadeAR2 *pGrenade = assert_cast<CGrenadeAR2*>(Create("grenade_ar2", vecSrc, angles, pPlayer));
pGrenade->SetAbsVelocity(vecThrow);
QAngle angles;
VectorAngles(vecThrow, angles);
CGrenadeAR2 *pGrenade = assert_cast<CGrenadeAR2 *>(Create("grenade_ar2", vecSrc, angles, pPlayer));
pGrenade->SetAbsVelocity(vecThrow);

pGrenade->SetLocalAngularVelocity(RandomAngle(-400, 400));
pGrenade->SetMoveType(MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_BOUNCE);
pGrenade->SetThrower(GetOwner());
pGrenade->SetDamage(BALC_CHARGE_SHOT_DAMAGE);
pGrenade->SetLocalAngularVelocity(RandomAngle(-400, 400));
pGrenade->SetMoveType(MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_BOUNCE);
pGrenade->SetThrower(GetOwner());
pGrenade->SetDamage(BALC_CHARGE_SHOT_DAMAGE);

CSoundEnt::InsertSound(SOUND_COMBAT, GetAbsOrigin(), 1000, 0.2, GetOwner(), SOUNDENT_CHANNEL_WEAPON);
CSoundEnt::InsertSound(SOUND_COMBAT, GetAbsOrigin(), 1000, 0.2, GetOwner(), SOUNDENT_CHANNEL_WEAPON);
pPlayer->OnMyWeaponFired(this); // to update GetTimeSinceWeaponFired
#endif
const int iAmmoCost = int((GetDefaultClip1() + 10) / BALC_CHARGE_SHOT_MAX);
m_iPrimaryAmmoCount = Max(0, m_iPrimaryAmmoCount - iAmmoCost);
const int iAmmoCost = int((GetDefaultClip1() + 10) / BALC_CHARGE_SHOT_MAX);
m_iPrimaryAmmoCount = Max(0, m_iPrimaryAmmoCount - iAmmoCost);

m_flNextPrimaryAttack = m_flNextPrimaryAttack + BALC_CHARGE_SHOT_RATE;
m_flNextPrimaryAttack = gpGlobals->curtime + BALC_CHARGE_SHOT_RATE;

m_bCharging = false;
m_bCharged = false;
m_bCharging = false;
m_bCharged = false;

//View kick
// View kick
if (!pPlayer->IsBot())
{
pPlayer->ViewPunchReset();
AddViewKick();
}
}

float CWeaponBALC::GetChargeDuration() const
{
return BALC_CHARGE_DURATION;
}

void CWeaponBALC::SecondaryAttack(void)
{
if (gpGlobals->curtime < m_flSoonestAttack)
Expand Down
2 changes: 2 additions & 0 deletions src/game/shared/neo/weapons/weapon_balc.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class CWeaponBALC : public CNEOBaseCombatWeapon
virtual NEO_WEP_BITS_UNDERLYING_TYPE GetNeoWepBits(void) const override { return NEO_WEP_BALC | NEO_WEP_FIREARM; }
virtual int GetNeoWepXPCost(const int neoClass) const override { return 20; }
virtual void ItemPostFrame() override;
void ShootGrenade(CNEO_Player *pPlayer);
float GetChargeDuration() const;

virtual float GetSpeedScale(void) const OVERRIDE { return 1.0f; }

Expand Down
Loading