From 411a0aa567043fc0715414d0d8ea362107bc5bd3 Mon Sep 17 00:00:00 2001 From: 1upD <1upderek@gmail.com> Date: Mon, 23 Jan 2023 21:14:39 -0500 Subject: [PATCH 1/3] Vortigaunt Plasma SMG2 --- .../game/client/hl2/c_weapon__stubs_hl2.cpp | 1 + .../server/hl2/npc_vortigaunt_episodic.cpp | 2 +- sp/src/game/server/mod/weapon_smg2.cpp | 46 +++++++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) 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..37ee15efc4d 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_plasma_smg2, CWeaponSMG2Plasma, C_HLSelectFireMachineGun ); #endif diff --git a/sp/src/game/server/hl2/npc_vortigaunt_episodic.cpp b/sp/src/game/server/hl2/npc_vortigaunt_episodic.cpp index 65d23587153..18f7633574d 100644 --- a/sp/src/game/server/hl2/npc_vortigaunt_episodic.cpp +++ b/sp/src/game/server/hl2/npc_vortigaunt_episodic.cpp @@ -4278,7 +4278,7 @@ void CVortigauntChargeToken::SeekTouch( CBaseEntity *pOther ) if ( pNPC != NULL ) { // Is this NPC friendly or hostile? - Disposition_t disposition = GetOwnerEntity()->MyNPCPointer()->IRelationType( pNPC ); + Disposition_t disposition = GetOwnerEntity()->MyCombatCharacterPointer()->IRelationType( pNPC ); // Charge the suit's armor if (disposition > D_FR ) diff --git a/sp/src/game/server/mod/weapon_smg2.cpp b/sp/src/game/server/mod/weapon_smg2.cpp index a45ef997a44..08868a709f9 100644 --- a/sp/src/game/server/mod/weapon_smg2.cpp +++ b/sp/src/game/server/mod/weapon_smg2.cpp @@ -19,6 +19,7 @@ #include "rumble_shared.h" #include "gamestats.h" #include "particle_parse.h" // BREADMAN - particle muzzle +#include "npc_vortigaunt_episodic.h" // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" @@ -148,6 +149,28 @@ acttable_t CWeaponSMG2::m_acttable[] = IMPLEMENT_ACTTABLE(CWeaponSMG2); + +class CWeaponPlamsa : public CHLSelectFireMachineGun +{ +public: + virtual void FireBullets( const FireBulletsInfo_t &info ); + virtual void FireNPCPrimaryAttack( CBaseCombatCharacter *pOperator, Vector &vecShootOrigin, Vector &vecShootDir ); +}; + +class CWeaponSMG2Plasma : public CWeaponSMG2 +{ +public: + DECLARE_CLASS( CWeaponSMG2Plasma, CWeaponSMG2 ); + + DECLARE_SERVERCLASS(); +}; + +IMPLEMENT_SERVERCLASS_ST( CWeaponSMG2Plasma, DT_WeaponSMG2Plasma ) +END_SEND_TABLE() + +LINK_ENTITY_TO_CLASS( weapon_plasma_smg2, CWeaponSMG2Plasma ); +PRECACHE_WEAPON_REGISTER( weapon_plasma_smg2 ); + //========================================================= CWeaponSMG2::CWeaponSMG2( ) { @@ -161,6 +184,7 @@ CWeaponSMG2::CWeaponSMG2( ) m_bAltFiresUnderwater = false; } + //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- @@ -550,4 +574,26 @@ const WeaponProficiencyInfo_t *CWeaponSMG2::GetProficiencyValues() COMPILE_TIME_ASSERT( ARRAYSIZE( proficiencyTable ) == WEAPON_PROFICIENCY_PERFECT + 1 ); return proficiencyTable; +} + +void CWeaponPlamsa::FireBullets( const FireBulletsInfo_t & info ) +{ + CVortigauntChargeToken * pToken = CVortigauntChargeToken::CreateChargeToken( info.m_vecSrc, GetOwner(), GetOwner()->GetEnemy() ); + pToken->SetAbsVelocity( info.m_vecDirShooting * 512.0f ); + pToken->SetNextThink( gpGlobals->curtime + 1.0f ); +} + +void CWeaponPlamsa::FireNPCPrimaryAttack( CBaseCombatCharacter * pOperator, Vector & vecShootOrigin, Vector & vecShootDir ) +{ + // FIXME: use the returned number of bullets to account for >10hz firerate + WeaponSoundRealtime( SINGLE_NPC ); + + CSoundEnt::InsertSound( SOUND_COMBAT|SOUND_CONTEXT_GUNFIRE, pOperator->GetAbsOrigin(), SOUNDENT_VOLUME_MACHINEGUN, 0.2, pOperator, SOUNDENT_CHANNEL_WEAPON, pOperator->GetEnemy() ); + + FireBulletsInfo_t info( 1, vecShootOrigin, vecShootDir, pOperator->GetAttackSpread( this ), MAX_TRACE_LENGTH, m_iPrimaryAmmoType, true ); + + FireBullets( info ); + pOperator->DoMuzzleFlash(); // Changing the shots doesn't help - just blows us up ! + + m_iClip1 = m_iClip1 - 1; } \ No newline at end of file From b158aa1c74f58665cd7b64866a1447c323412728 Mon Sep 17 00:00:00 2001 From: 1upD <1upderek@gmail.com> Date: Mon, 23 Jan 2023 21:44:25 -0500 Subject: [PATCH 2/3] Fix class structure for new weapon --- sp/src/game/client/hl2/c_weapon__stubs_hl2.cpp | 2 +- sp/src/game/server/mod/weapon_smg2.cpp | 14 +++++--------- 2 files changed, 6 insertions(+), 10 deletions(-) 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 37ee15efc4d..8d606485bf2 100644 --- a/sp/src/game/client/hl2/c_weapon__stubs_hl2.cpp +++ b/sp/src/game/client/hl2/c_weapon__stubs_hl2.cpp @@ -59,7 +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_plasma_smg2, CWeaponSMG2Plasma, C_HLSelectFireMachineGun ); +STUB_WEAPON_CLASS( weapon_plasma_smg2, WeaponSMG2Plasma, C_HLSelectFireMachineGun ); #endif diff --git a/sp/src/game/server/mod/weapon_smg2.cpp b/sp/src/game/server/mod/weapon_smg2.cpp index 08868a709f9..ac5a0a6357f 100644 --- a/sp/src/game/server/mod/weapon_smg2.cpp +++ b/sp/src/game/server/mod/weapon_smg2.cpp @@ -150,19 +150,15 @@ acttable_t CWeaponSMG2::m_acttable[] = IMPLEMENT_ACTTABLE(CWeaponSMG2); -class CWeaponPlamsa : public CHLSelectFireMachineGun -{ -public: - virtual void FireBullets( const FireBulletsInfo_t &info ); - virtual void FireNPCPrimaryAttack( CBaseCombatCharacter *pOperator, Vector &vecShootOrigin, Vector &vecShootDir ); -}; - class CWeaponSMG2Plasma : public CWeaponSMG2 { public: DECLARE_CLASS( CWeaponSMG2Plasma, CWeaponSMG2 ); DECLARE_SERVERCLASS(); + + virtual void FireBullets( const FireBulletsInfo_t &info ); + virtual void FireNPCPrimaryAttack( CBaseCombatCharacter *pOperator, Vector &vecShootOrigin, Vector &vecShootDir ); }; IMPLEMENT_SERVERCLASS_ST( CWeaponSMG2Plasma, DT_WeaponSMG2Plasma ) @@ -576,14 +572,14 @@ const WeaponProficiencyInfo_t *CWeaponSMG2::GetProficiencyValues() return proficiencyTable; } -void CWeaponPlamsa::FireBullets( const FireBulletsInfo_t & info ) +void CWeaponSMG2Plasma::FireBullets( const FireBulletsInfo_t & info ) { CVortigauntChargeToken * pToken = CVortigauntChargeToken::CreateChargeToken( info.m_vecSrc, GetOwner(), GetOwner()->GetEnemy() ); pToken->SetAbsVelocity( info.m_vecDirShooting * 512.0f ); pToken->SetNextThink( gpGlobals->curtime + 1.0f ); } -void CWeaponPlamsa::FireNPCPrimaryAttack( CBaseCombatCharacter * pOperator, Vector & vecShootOrigin, Vector & vecShootDir ) +void CWeaponSMG2Plasma::FireNPCPrimaryAttack( CBaseCombatCharacter * pOperator, Vector & vecShootOrigin, Vector & vecShootDir ) { // FIXME: use the returned number of bullets to account for >10hz firerate WeaponSoundRealtime( SINGLE_NPC ); From d4e785af614590949bd0f635224454d2de5bc0c4 Mon Sep 17 00:00:00 2001 From: 1upD <1upderek@gmail.com> Date: Thu, 26 Jan 2023 23:49:01 -0500 Subject: [PATCH 3/3] Fix up plasma firing --- sp/src/game/server/mod/weapon_smg2.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sp/src/game/server/mod/weapon_smg2.cpp b/sp/src/game/server/mod/weapon_smg2.cpp index ac5a0a6357f..f0dd3f659af 100644 --- a/sp/src/game/server/mod/weapon_smg2.cpp +++ b/sp/src/game/server/mod/weapon_smg2.cpp @@ -71,9 +71,9 @@ class CWeaponSMG2 : public CHLSelectFireMachineGun const WeaponProficiencyInfo_t *GetProficiencyValues(); - void FireNPCPrimaryAttack( CBaseCombatCharacter *pOperator, Vector &vecShootOrigin, Vector &vecShootDir ); - void Operator_ForceNPCFire( CBaseCombatCharacter *pOperator, bool bSecondary ); - void Operator_HandleAnimEvent( animevent_t *pEvent, CBaseCombatCharacter *pOperator ); + virtual void FireNPCPrimaryAttack( CBaseCombatCharacter *pOperator, Vector &vecShootOrigin, Vector &vecShootDir ); + virtual void Operator_ForceNPCFire( CBaseCombatCharacter *pOperator, bool bSecondary ); + virtual void Operator_HandleAnimEvent( animevent_t *pEvent, CBaseCombatCharacter *pOperator ); DECLARE_ACTTABLE(); @@ -588,7 +588,7 @@ void CWeaponSMG2Plasma::FireNPCPrimaryAttack( CBaseCombatCharacter * pOperator, FireBulletsInfo_t info( 1, vecShootOrigin, vecShootDir, pOperator->GetAttackSpread( this ), MAX_TRACE_LENGTH, m_iPrimaryAmmoType, true ); - FireBullets( info ); + CWeaponSMG2Plasma::FireBullets( info ); pOperator->DoMuzzleFlash(); // Changing the shots doesn't help - just blows us up ! m_iClip1 = m_iClip1 - 1;