Added backup activities to players

This commit is contained in:
Blixibon 2021-11-15 01:00:56 -06:00
parent 2d5e6f4adb
commit b9a46bc4e0
2 changed files with 14 additions and 34 deletions

View File

@ -2727,8 +2727,7 @@ bool CBaseCombatCharacter::Weapon_CanUse( CBaseCombatWeapon *pWeapon )
#ifdef MAPBASE #ifdef MAPBASE
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: Uses an activity from a different weapon when the activity we were originally looking for does not exist on this character. // Purpose: Uses an activity from a different weapon when the activity we were originally looking for does not exist on this character.
// Created to give NPCs the ability to use weapons they are not otherwise allowed to use. // This gives NPCs and players the ability to use weapons they are otherwise unable to use.
// Right now, everyone falls back to the SMG act table.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
Activity CBaseCombatCharacter::Weapon_BackupActivity( Activity activity, bool weaponTranslationWasRequired, CBaseCombatWeapon *pSpecificWeapon ) Activity CBaseCombatCharacter::Weapon_BackupActivity( Activity activity, bool weaponTranslationWasRequired, CBaseCombatWeapon *pSpecificWeapon )
{ {
@ -2740,8 +2739,9 @@ Activity CBaseCombatCharacter::Weapon_BackupActivity( Activity activity, bool we
if (!pWeapon->SupportsBackupActivity(activity)) if (!pWeapon->SupportsBackupActivity(activity))
return activity; return activity;
// Sometimes, the NPC is supposed to use the default activity. Return that if the weapon translation was "not required" and we have an original activity. // Sometimes, a NPC is supposed to use the default activity. Return that if the weapon translation was "not required" and we have an original activity.
if (!weaponTranslationWasRequired && GetModelPtr()->HaveSequenceForActivity(activity)) // Don't do this with players.
if (!weaponTranslationWasRequired && GetModelPtr()->HaveSequenceForActivity(activity) && !IsPlayer())
{ {
return activity; return activity;
} }
@ -2754,7 +2754,7 @@ Activity CBaseCombatCharacter::Weapon_BackupActivity( Activity activity, bool we
{ {
if ( activity == pTable->baseAct ) if ( activity == pTable->baseAct )
{ {
// Don't pick SMG animations we don't actually have an animation for. // Don't pick backup activities we don't actually have an animation for.
if (GetModelPtr() ? !GetModelPtr()->HaveSequenceForActivity(pTable->weaponAct) : false) if (GetModelPtr() ? !GetModelPtr()->HaveSequenceForActivity(pTable->weaponAct) : false)
{ {
return activity; return activity;

View File

@ -7817,39 +7817,19 @@ void CBasePlayer::Weapon_Equip( CBaseCombatWeapon *pWeapon )
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
Activity CBasePlayer::Weapon_TranslateActivity( Activity baseAct, bool *pRequired ) Activity CBasePlayer::Weapon_TranslateActivity( Activity baseAct, bool *pRequired )
{ {
#ifdef HL2_DLL Activity weaponTranslation = BaseClass::Weapon_TranslateActivity( baseAct, pRequired );
// HAAAAAAAAAAAAAACKS!
if (GetActiveWeapon()) if ( GetModelPtr() && !GetModelPtr()->HaveSequenceForActivity(weaponTranslation) )
{ {
int translated = baseAct; // This is used so players can fall back to backup activities in the same way NPCs in Mapbase can
int iActOffset = (baseAct - ACT_HL2MP_IDLE); Activity backupActivity = Weapon_BackupActivity(baseAct, pRequired);
if ( baseAct != backupActivity && GetModelPtr()->HaveSequenceForActivity(backupActivity) )
return backupActivity;
string_t iszClassname = GetActiveWeapon()->m_iClassname; return baseAct;
if (iszClassname == gm_isz_class_Pistol || iszClassname == gm_isz_class_357)
translated = (ACT_HL2MP_IDLE_PISTOL + iActOffset);
else if (iszClassname == gm_isz_class_SMG1)
translated = (ACT_HL2MP_IDLE_SMG1 + iActOffset);
else if (iszClassname == gm_isz_class_AR2)
translated = (ACT_HL2MP_IDLE_AR2 + iActOffset);
else if (iszClassname == gm_isz_class_Shotgun)
translated = (ACT_HL2MP_IDLE_SHOTGUN + iActOffset);
else if (iszClassname == gm_isz_class_RPG)
translated = (ACT_HL2MP_IDLE_RPG + iActOffset);
else if (iszClassname == gm_isz_class_Grenade)
translated = (ACT_HL2MP_IDLE_GRENADE + iActOffset);
else if (iszClassname == gm_isz_class_Physcannon)
translated = (ACT_HL2MP_IDLE_PHYSGUN + iActOffset);
else if (iszClassname == gm_isz_class_Crossbow)
translated = (ACT_HL2MP_IDLE_CROSSBOW + iActOffset);
else if (iszClassname == gm_isz_class_Crowbar || iszClassname == gm_isz_class_Stunstick)
translated = (ACT_HL2MP_IDLE_MELEE + iActOffset);
if (translated != baseAct)
return (Activity)translated;
} }
#endif
return BaseClass::Weapon_TranslateActivity( baseAct, pRequired ); return weaponTranslation;
} }
#endif #endif