Skip to content

Commit 050ee4d

Browse files
committed
Code review feedback pass
1 parent 79dbc93 commit 050ee4d

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

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

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ bool IsUndroppablePrimary( CBaseCombatWeapon *pPrimary )
2929
}
3030

3131
const NEO_WEP_BITS_UNDERLYING_TYPE wepBits = pNeoWep->GetNeoWepBits();
32-
return ( wepBits & ( NEO_WEP_BALC | NEO_WEP_SMAC ) ) != 0;
32+
return ( wepBits & NEO_WEP_BALC ) != 0;
3333
}
3434

3535
//---------------------------------------------------------------------------------------------
@@ -104,14 +104,16 @@ CBaseEntity *FindNearestPrimaryWeapon( CNEOBot *me, bool bAllowDropGhost, CNEOIg
104104
CBaseCombatWeapon *pPrimary = me->Weapon_GetSlot( 0 );
105105
if ( pPrimary )
106106
{
107-
if ( IsUndroppablePrimary( pPrimary ) )
107+
CNEOBaseCombatWeapon *pNeoPrimary = ToNEOWeapon( pPrimary );
108+
if ( pNeoPrimary && ( pNeoPrimary->GetNeoWepBits() & NEO_WEP_BALC ) )
108109
{
109110
// can't switch these weapons
110111
return nullptr;
111112
}
113+
112114
if ( !bAllowDropGhost )
113115
{
114-
if ( FStrEq( pPrimary->GetClassname(), "weapon_ghost" ) )
116+
if ( pNeoPrimary->GetNeoWepBits() & NEO_WEP_GHOST )
115117
{
116118
// Hold onto the ghost unless we are allowed to by the situation
117119
return nullptr;
@@ -157,13 +159,8 @@ CBaseEntity *FindNearestPrimaryWeapon( CNEOBot *me, bool bAllowDropGhost, CNEOIg
157159
CBaseCombatWeapon *pWeapon = pEntity->MyCombatWeaponPointer();
158160
if ( pWeapon && !pWeapon->GetOwner() && pWeapon->HasAnyAmmo() && pWeapon->GetSlot() == 0 )
159161
{
160-
if ( FStrEq( pWeapon->GetClassname(), "weapon_ghost" ) )
161-
{
162-
continue;
163-
}
164-
165162
CNEOBaseCombatWeapon *pNeoWeapon = ToNEOWeapon( pWeapon );
166-
if ( !pNeoWeapon )
163+
if ( !pNeoWeapon || ( pNeoWeapon->GetNeoWepBits() & NEO_WEP_GHOST ) )
167164
{
168165
continue;
169166
}
@@ -252,7 +249,7 @@ ActionResult< CNEOBot > CNEOBotSeekWeapon::OnStart( CNEOBot *me, Action< CNEOBot
252249
CBaseCombatWeapon *pPrimary = me->Weapon_GetSlot( 0 );
253250
if ( IsUndroppablePrimary( pPrimary ) )
254251
{
255-
// Don't scavenge if we have a weapon like the balc or smac
252+
// Don't scavenge if we have a weapon like the balc
256253
return Done("Equipped with an un-droppable weapon, will not seek");
257254
}
258255

@@ -266,7 +263,8 @@ ActionResult< CNEOBot > CNEOBotSeekWeapon::OnStart( CNEOBot *me, Action< CNEOBot
266263
return Done("No valid replacement primary found");
267264
}
268265

269-
if ( pPrimary && FStrEq( pPrimary->GetClassname(), "weapon_ghost" ) )
266+
CNEOBaseCombatWeapon *pNeoPrimary = ToNEOWeapon( pPrimary );
267+
if ( pNeoPrimary && ( pNeoPrimary->GetNeoWepBits() & NEO_WEP_GHOST ) )
270268
{
271269
// Try to drop once, but sometimes the environment causes a bounce back
272270
me->DropPrimaryWeapon();
@@ -305,7 +303,7 @@ ActionResult< CNEOBot > CNEOBotSeekWeapon::Update( CNEOBot *me, float interval )
305303

306304
// Verify the path actually reaches the weapon
307305
const float flMaxEndpointDistSqr = 150.0f * 150.0f;
308-
if ( ( m_path.GetEndPosition() - m_hTargetWeapon->GetAbsOrigin() ).LengthSqr() > flMaxEndpointDistSqr )
306+
if ( m_path.GetEndPosition().DistToSqr( m_hTargetWeapon->GetAbsOrigin() ) > flMaxEndpointDistSqr )
309307
{
310308
if ( m_pIgnoredWeapons && !m_pIgnoredWeapons->Has( m_hTargetWeapon ) )
311309
{
@@ -338,7 +336,8 @@ ActionResult< CNEOBot > CNEOBotSeekWeapon::Update( CNEOBot *me, float interval )
338336
{
339337
// We are seeking a better weapon, check if we are close enough to drop ours
340338
const float flDropDistSqr = 100.0f * 100.0f;
341-
if ( ( me->GetAbsOrigin() - m_hTargetWeapon->GetAbsOrigin() ).LengthSqr() <= flDropDistSqr || FStrEq( pPrimary->GetClassname(), "weapon_ghost" ) )
339+
if ( me->GetAbsOrigin().DistToSqr( m_hTargetWeapon->GetAbsOrigin() ) <= flDropDistSqr ||
340+
( pMyNeoWep && ( pMyNeoWep->GetNeoWepBits() & NEO_WEP_GHOST ) ) )
342341
{
343342
me->DropPrimaryWeapon();
344343
}

0 commit comments

Comments
 (0)