From 6b333dd9e928c9b10905d03cb92bd3708b38fb14 Mon Sep 17 00:00:00 2001 From: 1upD <1upderek@gmail.com> Date: Sat, 15 Jul 2023 23:25:08 -0400 Subject: [PATCH 1/2] weapon_ashlands_carbine --- .../game/client/hl2/c_weapon__stubs_hl2.cpp | 1 + sp/src/game/server/hl2/weapon_pistol.cpp | 160 ++++++++++++++++++ 2 files changed, 161 insertions(+) diff --git a/sp/src/game/client/hl2/c_weapon__stubs_hl2.cpp b/sp/src/game/client/hl2/c_weapon__stubs_hl2.cpp index 0671bbce4ef..6da44474bd4 100644 --- a/sp/src/game/client/hl2/c_weapon__stubs_hl2.cpp +++ b/sp/src/game/client/hl2/c_weapon__stubs_hl2.cpp @@ -59,6 +59,7 @@ STUB_WEAPON_CLASS( weapon_arbeit_clipboard, WeaponArbeitClipboard, C_WeaponCitiz STUB_WEAPON_CLASS( weapon_flechette_shotgun, WeaponFlechetteShotgun, C_BaseHLCombatWeapon ); STUB_WEAPON_CLASS( weapon_stasis_grenade, WeaponStasisGrenade, C_BaseHLCombatWeapon ); +STUB_WEAPON_CLASS( weapon_ashlands_carbine, WeaponAshlandsCarbine, C_BaseHLCombatWeapon) #endif diff --git a/sp/src/game/server/hl2/weapon_pistol.cpp b/sp/src/game/server/hl2/weapon_pistol.cpp index e3bf9a6cc0b..8679451fd84 100644 --- a/sp/src/game/server/hl2/weapon_pistol.cpp +++ b/sp/src/game/server/hl2/weapon_pistol.cpp @@ -366,6 +366,13 @@ void CWeaponPistol::Operator_HandleAnimEvent( animevent_t *pEvent, CBaseCombatCh { switch( pEvent->event ) { +#ifdef EZ2 + // In case derivatives of weapon_pistol use other firing events + case EVENT_WEAPON_SMG1: + case EVENT_WEAPON_SMG2: + case EVENT_WEAPON_AR1: + case EVENT_WEAPON_AR2: +#endif case EVENT_WEAPON_PISTOL_FIRE: { #ifdef EZ2 @@ -406,6 +413,11 @@ void CWeaponPistol::Operator_HandleAnimEvent( animevent_t *pEvent, CBaseCombatCh //----------------------------------------------------------------------------- void CWeaponPistol::FireNPCPrimaryAttack( CBaseCombatCharacter *pOperator, Vector &vecShootOrigin, Vector &vecShootDir ) { +#ifdef EZ2 + if (IsSilenced()) + CSoundEnt::InsertSound(SOUND_COMBAT | SOUND_CONTEXT_GUNFIRE, pOperator->GetAbsOrigin(), SOUNDENT_VOLUME_PISTOL / 3.0f, 0.2, pOperator, SOUNDENT_CHANNEL_WEAPON, pOperator->GetEnemy()); + else +#endif CSoundEnt::InsertSound( SOUND_COMBAT|SOUND_CONTEXT_GUNFIRE, pOperator->GetAbsOrigin(), SOUNDENT_VOLUME_PISTOL, 0.2, pOperator, SOUNDENT_CHANNEL_WEAPON, pOperator->GetEnemy() ); WeaponSound( SINGLE_NPC ); @@ -468,6 +480,12 @@ void CWeaponPistol::PrimaryAttack( void ) m_flLastAttackTime = gpGlobals->curtime; m_flSoonestPrimaryAttack = gpGlobals->curtime + PISTOL_FASTEST_REFIRE_TIME; + +#ifdef EZ2 + if (IsSilenced()) + CSoundEnt::InsertSound(SOUND_COMBAT, GetAbsOrigin(), SOUNDENT_VOLUME_PISTOL / 3.0f, 0.2, GetOwner()); + else +#endif CSoundEnt::InsertSound( SOUND_COMBAT, GetAbsOrigin(), SOUNDENT_VOLUME_PISTOL, 0.2, GetOwner() ); CBasePlayer *pOwner = ToBasePlayer( GetOwner() ); @@ -1476,4 +1494,146 @@ BEGIN_DATADESC( CWeaponPulsePistol ) DEFINE_FIELD( m_flLastChargeSoundTime, FIELD_TIME ), DEFINE_FIELD( m_hChargeSprite, FIELD_EHANDLE ) END_DATADESC() + + + +//----------------------------------------------------------------------------- +// CWeaponAshlandsCarbine, a silenced semi-automatic rifle from the Wasteland +//----------------------------------------------------------------------------- +class CWeaponAshlandsCarbine : public CWeaponPistol +{ +public: + DECLARE_CLASS(CWeaponAshlandsCarbine, CWeaponPistol); + DECLARE_SERVERCLASS(); + + void AddViewKick(void); + + bool IsSilenced() const { return true; } + + DECLARE_ACTTABLE(); + + virtual float GetFireRate(void) + { + return 0.083f;; + } +}; + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CWeaponAshlandsCarbine::AddViewKick(void) +{ + #define EASY_DAMPEN 1.5f + #define MAX_VERTICAL_KICK 20.0f + #define SLIDE_LIMIT 4.0f + + // Don't do machine gun style kick for controlled fire + if ( m_flAccuracyPenalty <= PISTOL_ACCURACY_SHOT_PENALTY_TIME * 2.0f) + { + BaseClass::AddViewKick(); + return; + } + + //Get the view kick + CBasePlayer* pPlayer = ToBasePlayer(GetOwner()); + + if (pPlayer == NULL) + return; + + DoMachineGunKick(pPlayer, EASY_DAMPEN, MAX_VERTICAL_KICK, m_fFireDuration, SLIDE_LIMIT); +} + +acttable_t CWeaponAshlandsCarbine::m_acttable[] = +{ + { ACT_RANGE_ATTACK1, ACT_RANGE_ATTACK_SMG1, true }, + { ACT_RELOAD, ACT_RELOAD_SMG1, true }, + { ACT_IDLE, ACT_IDLE_SMG1, true }, + { ACT_IDLE_ANGRY, ACT_IDLE_ANGRY_SMG1, true }, + + { ACT_WALK, ACT_WALK_RIFLE, true }, + { ACT_WALK_AIM, ACT_WALK_AIM_RIFLE, true }, + + // Readiness activities (not aiming) + { ACT_IDLE_RELAXED, ACT_IDLE_SMG1_RELAXED, false },//never aims + { ACT_IDLE_STIMULATED, ACT_IDLE_SMG1_STIMULATED, false }, + { ACT_IDLE_AGITATED, ACT_IDLE_ANGRY_SMG1, false },//always aims + + { ACT_WALK_RELAXED, ACT_WALK_RIFLE_RELAXED, false },//never aims + { ACT_WALK_STIMULATED, ACT_WALK_RIFLE_STIMULATED, false }, + { ACT_WALK_AGITATED, ACT_WALK_AIM_RIFLE, false },//always aims + + { ACT_RUN_RELAXED, ACT_RUN_RIFLE_RELAXED, false },//never aims + { ACT_RUN_STIMULATED, ACT_RUN_RIFLE_STIMULATED, false }, + { ACT_RUN_AGITATED, ACT_RUN_AIM_RIFLE, false },//always aims + + // Readiness activities (aiming) + { ACT_IDLE_AIM_RELAXED, ACT_IDLE_SMG1_RELAXED, false },//never aims + { ACT_IDLE_AIM_STIMULATED, ACT_IDLE_AIM_RIFLE_STIMULATED, false }, + { ACT_IDLE_AIM_AGITATED, ACT_IDLE_ANGRY_SMG1, false },//always aims + + { ACT_WALK_AIM_RELAXED, ACT_WALK_RIFLE_RELAXED, false },//never aims + { ACT_WALK_AIM_STIMULATED, ACT_WALK_AIM_RIFLE_STIMULATED, false }, + { ACT_WALK_AIM_AGITATED, ACT_WALK_AIM_RIFLE, false },//always aims + + { ACT_RUN_AIM_RELAXED, ACT_RUN_RIFLE_RELAXED, false },//never aims + { ACT_RUN_AIM_STIMULATED, ACT_RUN_AIM_RIFLE_STIMULATED, false }, + { ACT_RUN_AIM_AGITATED, ACT_RUN_AIM_RIFLE, false },//always aims + //End readiness activities + + { ACT_WALK_AIM, ACT_WALK_AIM_RIFLE, true }, + { ACT_WALK_CROUCH, ACT_WALK_CROUCH_RIFLE, true }, + { ACT_WALK_CROUCH_AIM, ACT_WALK_CROUCH_AIM_RIFLE, true }, + { ACT_RUN, ACT_RUN_RIFLE, true }, + { ACT_RUN_AIM, ACT_RUN_AIM_RIFLE, true }, + { ACT_RUN_CROUCH, ACT_RUN_CROUCH_RIFLE, true }, + { ACT_RUN_CROUCH_AIM, ACT_RUN_CROUCH_AIM_RIFLE, true }, + { ACT_GESTURE_RANGE_ATTACK1, ACT_GESTURE_RANGE_ATTACK_SMG1, true }, + { ACT_RANGE_ATTACK1_LOW, ACT_RANGE_ATTACK_SMG1_LOW, true }, + { ACT_COVER_LOW, ACT_COVER_SMG1_LOW, false }, + { 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 }, + +#if EXPANDED_HL2_WEAPON_ACTIVITIES + { ACT_ARM, ACT_ARM_RIFLE, false }, + { ACT_DISARM, ACT_DISARM_RIFLE, false }, +#endif + +#if EXPANDED_HL2_COVER_ACTIVITIES + { ACT_RANGE_AIM_MED, ACT_RANGE_AIM_SMG1_MED, false }, + { ACT_RANGE_ATTACK1_MED, ACT_RANGE_ATTACK_SMG1_MED, false }, + + { ACT_COVER_WALL_R, ACT_COVER_WALL_R_RIFLE, false }, + { ACT_COVER_WALL_L, ACT_COVER_WALL_L_RIFLE, false }, + { ACT_COVER_WALL_LOW_R, ACT_COVER_WALL_LOW_R_RIFLE, false }, + { ACT_COVER_WALL_LOW_L, ACT_COVER_WALL_LOW_L_RIFLE, false }, +#endif + +#ifdef MAPBASE + // HL2:DM activities (for third-person animations in SP) + { ACT_HL2MP_IDLE, ACT_HL2MP_IDLE_SMG1, false }, + { ACT_HL2MP_RUN, ACT_HL2MP_RUN_SMG1, false }, + { ACT_HL2MP_IDLE_CROUCH, ACT_HL2MP_IDLE_CROUCH_SMG1, false }, + { ACT_HL2MP_WALK_CROUCH, ACT_HL2MP_WALK_CROUCH_SMG1, false }, + { ACT_HL2MP_GESTURE_RANGE_ATTACK, ACT_HL2MP_GESTURE_RANGE_ATTACK_SMG1, false }, + { ACT_HL2MP_GESTURE_RELOAD, ACT_HL2MP_GESTURE_RELOAD_SMG1, false }, + { ACT_HL2MP_JUMP, ACT_HL2MP_JUMP_SMG1, false }, +#if EXPANDED_HL2DM_ACTIVITIES + { ACT_HL2MP_WALK, ACT_HL2MP_WALK_SMG1, false }, + { ACT_HL2MP_GESTURE_RANGE_ATTACK2, ACT_HL2MP_GESTURE_RANGE_ATTACK2_SMG1, false }, +#endif +#endif +}; + +IMPLEMENT_ACTTABLE(CWeaponAshlandsCarbine); + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +IMPLEMENT_SERVERCLASS_ST(CWeaponAshlandsCarbine, DT_WeaponAshlandsCarbine) +END_SEND_TABLE() + +LINK_ENTITY_TO_CLASS(weapon_ashlands_carbine, CWeaponAshlandsCarbine); +PRECACHE_WEAPON_REGISTER(weapon_ashlands_carbine); + #endif From fe3387e2e81a69e7ffb46782a03ba7cf8cd24b6e Mon Sep 17 00:00:00 2001 From: 1upD <1upderek@gmail.com> Date: Sun, 16 Jul 2023 16:21:26 -0400 Subject: [PATCH 2/2] Use SMG1 recoil values for ashlands rifle --- sp/src/game/server/hl2/weapon_pistol.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/sp/src/game/server/hl2/weapon_pistol.cpp b/sp/src/game/server/hl2/weapon_pistol.cpp index 8679451fd84..d7c9010be8e 100644 --- a/sp/src/game/server/hl2/weapon_pistol.cpp +++ b/sp/src/game/server/hl2/weapon_pistol.cpp @@ -1523,16 +1523,9 @@ class CWeaponAshlandsCarbine : public CWeaponPistol //----------------------------------------------------------------------------- void CWeaponAshlandsCarbine::AddViewKick(void) { - #define EASY_DAMPEN 1.5f - #define MAX_VERTICAL_KICK 20.0f - #define SLIDE_LIMIT 4.0f - - // Don't do machine gun style kick for controlled fire - if ( m_flAccuracyPenalty <= PISTOL_ACCURACY_SHOT_PENALTY_TIME * 2.0f) - { - BaseClass::AddViewKick(); - return; - } + #define EASY_DAMPEN 2.5f + #define MAX_VERTICAL_KICK 11.0f + #define SLIDE_LIMIT 2.0f //Get the view kick CBasePlayer* pPlayer = ToBasePlayer(GetOwner());