Fixed various NPC holster-related issues

This commit is contained in:
Blixibon 2021-10-14 02:16:38 -05:00
parent 3d5f73b8be
commit 1c6b0679f8
8 changed files with 59 additions and 13 deletions

View File

@ -7782,7 +7782,7 @@ int CAI_BaseNPC::HolsterWeapon( void )
if ( IsWeaponHolstered() )
return -1;
#ifdef COMPANION_HOLSTER_WORKAROUND
#ifdef MAPBASE
Activity activity = TranslateActivity( ACT_DISARM );
int iHolsterGesture = FindGestureLayer( activity );
if ( iHolsterGesture != -1 )
@ -7838,7 +7838,7 @@ int CAI_BaseNPC::UnholsterWeapon( void )
if ( !IsWeaponHolstered() )
return -1;
#ifdef COMPANION_HOLSTER_WORKAROUND
#ifdef MAPBASE
Activity activity = TranslateActivity( ACT_ARM );
int iHolsterGesture = FindGestureLayer( activity );
#else
@ -7867,13 +7867,12 @@ int CAI_BaseNPC::UnholsterWeapon( void )
{
SetActiveWeapon( GetWeapon(i) );
#ifdef COMPANION_HOLSTER_WORKAROUND
int iLayer = AddGesture( activity, true );
//iLayer = AddGesture( ACT_GESTURE_ARM, true );
#ifdef MAPBASE
int iLayer = AddGesture( TranslateActivity( ACT_ARM ), true );
#else
int iLayer = AddGesture( ACT_ARM, true );
//iLayer = AddGesture( ACT_GESTURE_ARM, true );
#endif
//iLayer = AddGesture( ACT_GESTURE_ARM, true );
if (iLayer != -1)
{
@ -8052,6 +8051,26 @@ bool CAI_BaseNPC::DoUnholster( void )
return false;
}
//-----------------------------------------------------------------------------
// Purpose: Returns true if the NPC should be unholstering their weapon
//-----------------------------------------------------------------------------
bool CAI_BaseNPC::ShouldUnholsterWeapon( void )
{
return GetState() == NPC_STATE_COMBAT;
}
//-----------------------------------------------------------------------------
// Purpose: Returns true if the NPC can unholster their weapon
//-----------------------------------------------------------------------------
bool CAI_BaseNPC::CanUnholsterWeapon( void )
{
// Don't unholster during special navigation
if ( GetNavType() == NAV_JUMP || GetNavType() == NAV_CLIMB )
return false;
return IsWeaponHolstered();
}
//------------------------------------------------------------------------------
// Purpose: Give the NPC in question the weapon specified
//------------------------------------------------------------------------------

View File

@ -1731,8 +1731,8 @@ public:
virtual bool DoHolster(void);
virtual bool DoUnholster(void);
virtual bool ShouldUnholsterWeapon() { return GetState() == NPC_STATE_COMBAT; }
virtual bool CanUnholsterWeapon() { return IsWeaponHolstered(); }
virtual bool ShouldUnholsterWeapon();
virtual bool CanUnholsterWeapon();
void InputGiveWeaponHolstered( inputdata_t &inputdata );
void InputChangeWeapon( inputdata_t &inputdata );

View File

@ -3899,6 +3899,15 @@ int CNPC_MetroPolice::SelectScheduleNoDirectEnemy()
return SCHED_METROPOLICE_SMASH_PROP;
}
#ifdef MAPBASE
// If you see your enemy and your weapon is holstered, you're probably about to arm yourself.
// Wait and don't just charge in
if ( IsWeaponHolstered() && HasCondition(COND_SEE_ENEMY) )
{
return SCHED_COMBAT_FACE;
}
#endif
return SCHED_METROPOLICE_CHASE_ENEMY;
}

View File

@ -156,6 +156,11 @@ acttable_t CWeaponAR2::m_acttable[] =
{ ACT_GESTURE_RELOAD, ACT_GESTURE_RELOAD_SMG1, true },
// { ACT_RANGE_ATTACK2, ACT_RANGE_ATTACK_AR2_GRENADE, true },
#endif
#ifdef EXPANDED_HL2_WEAPON_ACTIVITIES
{ ACT_ARM, ACT_ARM_RIFLE, false },
{ ACT_DISARM, ACT_DISARM_RIFLE, false },
#endif
};
IMPLEMENT_ACTTABLE(CWeaponAR2);

View File

@ -697,6 +697,9 @@ acttable_t CWeaponCrossbow::m_acttable[] =
{ ACT_RANGE_AIM_LOW, ACT_RANGE_AIM_CROSSBOW_LOW, false },
{ ACT_RELOAD_LOW, ACT_RELOAD_CROSSBOW_LOW, false },
{ ACT_GESTURE_RELOAD, ACT_GESTURE_RELOAD_CROSSBOW, true },
{ ACT_ARM, ACT_ARM_RIFLE, false },
{ ACT_DISARM, ACT_DISARM_RIFLE, false },
#else
{ ACT_WALK_AIM, ACT_WALK_AIM_RIFLE, true },
{ ACT_WALK_CROUCH, ACT_WALK_CROUCH_RIFLE, true },

View File

@ -1415,6 +1415,11 @@ acttable_t CWeaponRPG::m_acttable[] =
{ ACT_RUN, ACT_RUN_RPG, true },
{ ACT_RUN_CROUCH, ACT_RUN_CROUCH_RPG, true },
{ ACT_COVER_LOW, ACT_COVER_LOW_RPG, true },
#ifdef EXPANDED_HL2_WEAPON_ACTIVITIES
{ ACT_ARM, ACT_ARM_RIFLE, false },
{ ACT_DISARM, ACT_DISARM_RIFLE, false },
#endif
};
IMPLEMENT_ACTTABLE(CWeaponRPG);

View File

@ -153,6 +153,11 @@ acttable_t CWeaponShotgun::m_acttable[] =
{ ACT_RANGE_ATTACK1_LOW, ACT_RANGE_ATTACK_SHOTGUN_LOW, true },
{ ACT_RELOAD_LOW, ACT_RELOAD_SHOTGUN_LOW, false },
{ ACT_GESTURE_RELOAD, ACT_GESTURE_RELOAD_SHOTGUN, false },
#ifdef EXPANDED_HL2_WEAPON_ACTIVITIES
{ ACT_ARM, ACT_ARM_RIFLE, false },
{ ACT_DISARM, ACT_DISARM_RIFLE, false },
#endif
};
IMPLEMENT_ACTTABLE(CWeaponShotgun);

View File

@ -93,11 +93,6 @@ acttable_t CWeaponSMG1::m_acttable[] =
{ ACT_WALK, ACT_WALK_RIFLE, true },
{ ACT_WALK_AIM, ACT_WALK_AIM_RIFLE, true },
#ifdef EXPANDED_HL2_WEAPON_ACTIVITIES
{ ACT_ARM, ACT_ARM_RIFLE, false },
{ ACT_DISARM, ACT_DISARM_RIFLE, false },
#endif
// Readiness activities (not aiming)
{ ACT_IDLE_RELAXED, ACT_IDLE_SMG1_RELAXED, false },//never aims
@ -139,6 +134,11 @@ acttable_t CWeaponSMG1::m_acttable[] =
{ ACT_RANGE_AIM_LOW, ACT_RANGE_AIM_SMG1_LOW, false },
{ ACT_RELOAD_LOW, ACT_RELOAD_SMG1_LOW, false },
{ ACT_GESTURE_RELOAD, ACT_GESTURE_RELOAD_SMG1, true },
#ifdef EXPANDED_HL2_WEAPON_ACTIVITIES
{ ACT_ARM, ACT_ARM_RIFLE, false },
{ ACT_DISARM, ACT_DISARM_RIFLE, false },
#endif
};
IMPLEMENT_ACTTABLE(CWeaponSMG1);