Skip to content

Commit

Permalink
Allow ally human grunts have no weapons. Fix #401
Browse files Browse the repository at this point in the history
  • Loading branch information
FreeSlave committed Nov 7, 2023
1 parent 7b8f05c commit 606a731
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions dlls/gearbox/fgrunt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1361,7 +1361,7 @@ int CHFGrunt :: ISoundMask ( void)
//=========================================================
void CHFGrunt :: CheckAmmo ( void )
{
if ( m_cAmmoLoaded <= 0 )
if ( pev->weapons != 0 && m_cAmmoLoaded <= 0 )
{
SetConditions(bits_COND_NO_AMMO_LOADED);
}
Expand Down Expand Up @@ -1530,7 +1530,7 @@ BOOL CHFGrunt :: CheckMeleeAttack1 ( float flDot, float flDist )
//=========================================================
BOOL CHFGrunt :: CheckRangeAttack1 ( float flDot, float flDist )
{
if ( !HasConditions( bits_COND_ENEMY_OCCLUDED ) && flDist <= 2048 && flDot >= 0.5 && NoFriendlyFire() && ( GetBodygroup( 3 ) != 3 ) )
if ( !HasConditions( bits_COND_ENEMY_OCCLUDED ) && flDist <= 2048 && flDot >= 0.5 && NoFriendlyFire() && GetBodygroup( FG_GUN_GROUP ) != FG_GUN_NONE )
{
TraceResult tr;

Expand Down Expand Up @@ -1991,33 +1991,38 @@ void CHFGrunt :: Spawn()
{
m_iHead = RANDOM_LONG(FG_HEAD_SAW, FG_HEAD_SAW_BLACK);
}
else if (pev->weapons == 0)
{
m_iHead = FG_HEAD_MP;
}
else
m_iHead = FG_HEAD_MASK;
}
else if ( m_iHead >= FG_HEAD_COUNT )
m_iHead = FG_HEAD_MASK;

if ( pev->weapons <= 0 )
if (FBitSet( pev->weapons, FGRUNT_9MMAR ))
{
pev->weapons = FGRUNT_9MMAR;
SetBodygroup( FG_GUN_GROUP, FG_GUN_MP5 );
m_cClipSize = FGRUNT_CLIP_SIZE;
}
if (FBitSet( pev->weapons, FGRUNT_SHOTGUN ))
else if (FBitSet( pev->weapons, FGRUNT_SHOTGUN ))
{
SetBodygroup( FG_GUN_GROUP, FG_GUN_SHOTGUN );
SetBodygroup( FG_TORSO_GROUP, FG_TORSO_SHOTGUN );
m_cClipSize = 8;
}
if (FBitSet( pev->weapons, FGRUNT_9MMAR ))
{
SetBodygroup( FG_GUN_GROUP, FG_GUN_MP5 );
m_cClipSize = FGRUNT_CLIP_SIZE;
}
if (FBitSet( pev->weapons, FGRUNT_M249 ))
else if (FBitSet( pev->weapons, FGRUNT_M249 ))
{
SetBodygroup( FG_GUN_GROUP, FG_GUN_SAW );
SetBodygroup( FG_TORSO_GROUP, FG_TORSO_M249 );
m_cClipSize = FGRUNT_CLIP_SIZE;
}
else
{
SetBodygroup( FG_GUN_GROUP, FG_GUN_NONE );
m_cClipSize = 0;
}

SetBodygroup( FG_HEAD_GROUP, m_iHead );

Expand Down Expand Up @@ -2372,7 +2377,7 @@ Schedule_t* CHFGrunt :: GetScheduleOfType ( int Type )
break;
case SCHED_HGRUNT_ALLY_ELOF_FAIL:
{
return GetScheduleOfType( SCHED_RANGE_ATTACK1 );
return GetScheduleOfType( SCHED_TAKE_COVER_FROM_ENEMY );
}
break;
case SCHED_HGRUNT_ALLY_ESTABLISH_LINE_OF_FIRE:
Expand Down

0 comments on commit 606a731

Please sign in to comment.