Skip to content

Commit abd5b95

Browse files
committed
Juggernaut bots can alt-fire grenades
1 parent 36087ff commit abd5b95

4 files changed

Lines changed: 83 additions & 41 deletions

File tree

src/game/server/neo/bot/behavior/neo_bot_behavior.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "bot/behavior/nav_entities/neo_bot_nav_ent_move_to.h"
1616
#include "bot/behavior/nav_entities/neo_bot_nav_ent_wait.h"
1717
#include "bot/behavior/neo_bot_tactical_monitor.h"
18+
#include "weapons/weapon_balc.h"
1819

1920
ConVar neo_bot_path_lookahead_range( "neo_bot_path_lookahead_range", "300" );
2021
ConVar neo_bot_sniper_aim_error( "neo_bot_sniper_aim_error", "0.01", FCVAR_CHEAT );
@@ -830,10 +831,22 @@ void CNEOBotMainAction::FireWeaponAtEnemy( CNEOBot *me )
830831
{
831832
if (myWeapon->GetNeoWepBits() & NEO_WEP_BALC)
832833
{
834+
auto *pBalc = static_cast<CWeaponBALC *>(myWeapon);
833835
// Minimum viable firing BALC
834836
// TODO: Proper heat management for higher difficulty bots
835837
me->ReleaseWalkButton(); // NEO Jank: this actually cancels sprint
836-
me->PressFireButton(GetFireDurationByDifficulty(me));
838+
839+
// NEO JANK: To simplify alt fire input management
840+
// we allow the bot to bypass button-hold charge firing requirement
841+
if ( (me->GetTimeSinceWeaponFired() >= pBalc->GetChargeDuration())
842+
&& threatRange >= 300.0f )
843+
{
844+
pBalc->ShootGrenade(me);
845+
}
846+
else
847+
{
848+
me->PressFireButton(GetFireDurationByDifficulty(me));
849+
}
837850
return;
838851
}
839852
else if (myWeapon->m_iClip1 <= 0)

src/game/server/neo/bot/behavior/neo_bot_jgr_juggernaut.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#include "bot/neo_bot.h"
55
#include "bot/neo_bot_path_compute.h"
66
#include "bot/behavior/neo_bot_jgr_juggernaut.h"
7+
#include "bot/behavior/neo_bot_retreat_to_cover.h"
8+
#include "weapon_balc.h"
79

810
//---------------------------------------------------------------------------------------------
911
ActionResult< CNEOBot > CNEOBotJgrJuggernaut::OnStart( CNEOBot *me, Action< CNEOBot > *priorAction )
@@ -25,6 +27,20 @@ ActionResult< CNEOBot > CNEOBotJgrJuggernaut::OnStart( CNEOBot *me, Action< CNEO
2527
//---------------------------------------------------------------------------------------------
2628
ActionResult< CNEOBot > CNEOBotJgrJuggernaut::Update( CNEOBot *me, float interval )
2729
{
30+
CBaseCombatWeapon *pWeapon = me->GetActiveWeapon();
31+
if ( pWeapon )
32+
{
33+
CNEOBaseCombatWeapon *pNeoWep = dynamic_cast< CNEOBaseCombatWeapon * >( pWeapon );
34+
if ( pNeoWep && ( pNeoWep->GetNeoWepBits() & NEO_WEP_BALC ) )
35+
{
36+
CWeaponBALC *pBalc = static_cast< CWeaponBALC * >( pNeoWep );
37+
if ( pBalc->m_bOverheated )
38+
{
39+
return SuspendFor( new CNEOBotRetreatToCover(), "BALC overheated - retreating to cover!" );
40+
}
41+
}
42+
}
43+
2844
ActionResult< CNEOBot > result = UpdateCommon( me, interval );
2945
if ( result.IsRequestingChange() || result.IsDone() )
3046
return result;

src/game/shared/neo/weapons/weapon_balc.cpp

Lines changed: 51 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -137,59 +137,70 @@ void CWeaponBALC::PrimaryAttack(void)
137137
}
138138

139139
auto pPlayer = ToNEOPlayer(GetOwner());
140-
if (!pPlayer)
141-
{
142-
Assert(false);
143-
return;
144-
}
140+
ShootGrenade(pPlayer);
141+
}
142+
}
145143

146-
if ((gpGlobals->curtime - m_flLastAttackTime) > 0.5f)
147-
{
148-
m_nNumShotsFired = 0;
149-
}
150-
else
151-
{
152-
++m_nNumShotsFired;
153-
}
154-
m_flLastAttackTime = gpGlobals->curtime;
144+
void CWeaponBALC::ShootGrenade(CNEO_Player *pPlayer)
145+
{
146+
if (!pPlayer)
147+
{
148+
Assert(false);
149+
return;
150+
}
155151

156-
SendWeaponAnim(GetPrimaryAttackActivity());
157-
SetWeaponIdleTime(gpGlobals->curtime + 2.0);
158-
pPlayer->DoAnimationEvent(PLAYERANIMEVENT_ATTACK_PRIMARY);
152+
if ((gpGlobals->curtime - m_flLastAttackTime) > 0.5f)
153+
{
154+
m_nNumShotsFired = 0;
155+
}
156+
else
157+
{
158+
++m_nNumShotsFired;
159+
}
160+
m_flLastAttackTime = gpGlobals->curtime;
159161

160-
WeaponSound(BURST);
162+
SendWeaponAnim(GetPrimaryAttackActivity());
163+
SetWeaponIdleTime(gpGlobals->curtime + 2.0);
164+
pPlayer->DoAnimationEvent(PLAYERANIMEVENT_ATTACK_PRIMARY);
165+
166+
WeaponSound(BURST);
161167

162168
#ifdef GAME_DLL
163-
const Vector vecSrc = pPlayer->Weapon_ShootPosition();
164-
Vector vecThrow;
169+
const Vector vecSrc = pPlayer->Weapon_ShootPosition();
170+
Vector vecThrow;
165171

166-
AngleVectors(pPlayer->EyeAngles() + pPlayer->GetPunchAngle(), &vecThrow);
167-
VectorScale(vecThrow, 2000.0f, vecThrow);
172+
AngleVectors(pPlayer->EyeAngles() + pPlayer->GetPunchAngle(), &vecThrow);
173+
VectorScale(vecThrow, 2000.0f, vecThrow);
168174

169-
QAngle angles;
170-
VectorAngles(vecThrow, angles);
171-
CGrenadeAR2 *pGrenade = assert_cast<CGrenadeAR2*>(Create("grenade_ar2", vecSrc, angles, pPlayer));
172-
pGrenade->SetAbsVelocity(vecThrow);
175+
QAngle angles;
176+
VectorAngles(vecThrow, angles);
177+
CGrenadeAR2 *pGrenade = assert_cast<CGrenadeAR2 *>(Create("grenade_ar2", vecSrc, angles, pPlayer));
178+
pGrenade->SetAbsVelocity(vecThrow);
173179

174-
pGrenade->SetLocalAngularVelocity(RandomAngle(-400, 400));
175-
pGrenade->SetMoveType(MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_BOUNCE);
176-
pGrenade->SetThrower(GetOwner());
177-
pGrenade->SetDamage(BALC_CHARGE_SHOT_DAMAGE);
180+
pGrenade->SetLocalAngularVelocity(RandomAngle(-400, 400));
181+
pGrenade->SetMoveType(MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_BOUNCE);
182+
pGrenade->SetThrower(GetOwner());
183+
pGrenade->SetDamage(BALC_CHARGE_SHOT_DAMAGE);
178184

179-
CSoundEnt::InsertSound(SOUND_COMBAT, GetAbsOrigin(), 1000, 0.2, GetOwner(), SOUNDENT_CHANNEL_WEAPON);
185+
CSoundEnt::InsertSound(SOUND_COMBAT, GetAbsOrigin(), 1000, 0.2, GetOwner(), SOUNDENT_CHANNEL_WEAPON);
186+
pPlayer->OnMyWeaponFired(this); // to update GetTimeSinceWeaponFired
180187
#endif
181-
const int iAmmoCost = int((GetDefaultClip1() + 10) / BALC_CHARGE_SHOT_MAX);
182-
m_iPrimaryAmmoCount = Max(0, m_iPrimaryAmmoCount - iAmmoCost);
188+
const int iAmmoCost = int((GetDefaultClip1() + 10) / BALC_CHARGE_SHOT_MAX);
189+
m_iPrimaryAmmoCount = Max(0, m_iPrimaryAmmoCount - iAmmoCost);
183190

184-
m_flNextPrimaryAttack = m_flNextPrimaryAttack + BALC_CHARGE_SHOT_RATE;
191+
m_flNextPrimaryAttack = gpGlobals->curtime + BALC_CHARGE_SHOT_RATE;
185192

186-
m_bCharging = false;
187-
m_bCharged = false;
193+
m_bCharging = false;
194+
m_bCharged = false;
188195

189-
//View kick
190-
pPlayer->ViewPunchReset();
191-
AddViewKick();
192-
}
196+
// View kick
197+
pPlayer->ViewPunchReset();
198+
AddViewKick();
199+
}
200+
201+
float CWeaponBALC::GetChargeDuration() const
202+
{
203+
return BALC_CHARGE_DURATION;
193204
}
194205

195206
void CWeaponBALC::SecondaryAttack(void)

src/game/shared/neo/weapons/weapon_balc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ class CWeaponBALC : public CNEOBaseCombatWeapon
4141
virtual NEO_WEP_BITS_UNDERLYING_TYPE GetNeoWepBits(void) const override { return NEO_WEP_BALC | NEO_WEP_FIREARM; }
4242
virtual int GetNeoWepXPCost(const int neoClass) const override { return 20; }
4343
virtual void ItemPostFrame() override;
44+
void ShootGrenade(CNEO_Player *pPlayer);
45+
float GetChargeDuration() const;
4446

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

0 commit comments

Comments
 (0)