From 822119e42aa014cbb089b2824a7f2a78d2937bc1 Mon Sep 17 00:00:00 2001 From: Agiel Date: Tue, 31 Mar 2026 00:20:25 +0200 Subject: [PATCH 1/2] Fix shotguns not reading number of pellets from scripts. --- src/game/client/CMakeLists.txt | 3 +- .../client/hl2mp/clientmode_hl2mpnormal.cpp | 2 +- src/game/client/neo/ui/neo_hud_ammo.cpp | 2 +- src/game/server/CMakeLists.txt | 2 + src/game/server/neo/neo_player.cpp | 2 +- src/game/shared/basecombatweapon_shared.cpp | 12 -- src/game/shared/hl2mp/hl2mp_weapon_parse.cpp | 67 +---------- src/game/shared/hl2mp/hl2mp_weapon_parse.h | 12 -- src/game/shared/neo/neo_gamerules.cpp | 2 +- src/game/shared/neo/neo_player_shared.cpp | 2 +- .../shared/neo/neo_predicted_viewmodel.cpp | 6 +- .../shared/neo/weapons/neo_weapon_parse.cpp | 106 ++++++++++++++++++ .../shared/neo/weapons/neo_weapon_parse.h | 52 +++++++++ src/game/shared/neo/weapons/weapon_aa13.cpp | 3 +- .../weapons/weapon_neobasecombatweapon.cpp | 34 +++++- .../neo/weapons/weapon_neobasecombatweapon.h | 5 + src/game/shared/neo/weapons/weapon_supa7.cpp | 2 +- src/game/shared/weapon_parse.cpp | 31 ----- src/game/shared/weapon_parse.h | 12 -- 19 files changed, 211 insertions(+), 146 deletions(-) create mode 100644 src/game/shared/neo/weapons/neo_weapon_parse.cpp create mode 100644 src/game/shared/neo/weapons/neo_weapon_parse.h diff --git a/src/game/client/CMakeLists.txt b/src/game/client/CMakeLists.txt index da90412331..364cd40ff1 100644 --- a/src/game/client/CMakeLists.txt +++ b/src/game/client/CMakeLists.txt @@ -1662,6 +1662,8 @@ target_sources_grouped( TARGET client NAME "Source Files\\Shared\\Weapons" FILES + ${CMAKE_SOURCE_DIR}/game/shared/neo/weapons/neo_weapon_parse.cpp + ${CMAKE_SOURCE_DIR}/game/shared/neo/weapons/neo_weapon_parse.h ${CMAKE_SOURCE_DIR}/game/shared/neo/weapons/weapon_aa13.cpp ${CMAKE_SOURCE_DIR}/game/shared/neo/weapons/weapon_aa13.h ${CMAKE_SOURCE_DIR}/game/shared/neo/weapons/weapon_balc.cpp @@ -1816,4 +1818,3 @@ target_sources_grouped( ${CMAKE_SOURCE_DIR}/game/client/NextBot/C_NextBot.cpp ${CMAKE_SOURCE_DIR}/game/client/NextBot/C_NextBot.h ) - diff --git a/src/game/client/hl2mp/clientmode_hl2mpnormal.cpp b/src/game/client/hl2mp/clientmode_hl2mpnormal.cpp index 7c132e10ac..c756774d03 100644 --- a/src/game/client/hl2mp/clientmode_hl2mpnormal.cpp +++ b/src/game/client/hl2mp/clientmode_hl2mpnormal.cpp @@ -261,7 +261,7 @@ float ClientModeHL2MPNormal::GetViewModelFOV() m_bViewAim = true; } - const CHL2MPSWeaponInfo* pWepInfo = &pWeapon->GetHL2MPWpnData(); + const CNEOWeaponInfo* pWepInfo = &pWeapon->GetNEOWpnData(); Assert(pWepInfo); const float endAimingChange = m_flStartAimingChange + NEO_ZOOM_SPEED; diff --git a/src/game/client/neo/ui/neo_hud_ammo.cpp b/src/game/client/neo/ui/neo_hud_ammo.cpp index 9e4f25c536..1cf15c90de 100644 --- a/src/game/client/neo/ui/neo_hud_ammo.cpp +++ b/src/game/client/neo/ui/neo_hud_ammo.cpp @@ -164,7 +164,7 @@ void CNEOHud_Ammo::DrawAmmo() const { char fireModeText[2]{ '\0' }; - ammoChar = activeWep->GetWpnData().szBulletCharacter; + ammoChar = activeWep->GetNEOWpnData().szBulletCharacter; magSizeMax = activeWep->GetMaxClip1(); magSizeCurrent = activeWep->Clip1(); diff --git a/src/game/server/CMakeLists.txt b/src/game/server/CMakeLists.txt index 16dfcf289f..917f71ff0f 100644 --- a/src/game/server/CMakeLists.txt +++ b/src/game/server/CMakeLists.txt @@ -1515,6 +1515,8 @@ target_sources_grouped( TARGET server NAME "NEO\\Weapons" FILES + ${CMAKE_SOURCE_DIR}/game/shared/neo/weapons/neo_weapon_parse.cpp + ${CMAKE_SOURCE_DIR}/game/shared/neo/weapons/neo_weapon_parse.h ${CMAKE_SOURCE_DIR}/game/shared/neo/weapons/weapon_aa13.cpp ${CMAKE_SOURCE_DIR}/game/shared/neo/weapons/weapon_aa13.h ${CMAKE_SOURCE_DIR}/game/shared/neo/weapons/weapon_balc.cpp diff --git a/src/game/server/neo/neo_player.cpp b/src/game/server/neo/neo_player.cpp index d75a80409c..8babd96d9d 100644 --- a/src/game/server/neo/neo_player.cpp +++ b/src/game/server/neo/neo_player.cpp @@ -2414,7 +2414,7 @@ void CNEO_Player::Weapon_DropAllOnDeath( const CTakeDamageInfo &info ) void CNEO_Player::Weapon_DropOnDeath(CNEOBaseCombatWeapon* pNeoWeapon, Vector damageForce) { - if (!pNeoWeapon->GetWpnData().m_bDropOnDeath) + if (!pNeoWeapon->GetNEOWpnData().m_bDropOnDeath) { // Can't drop this weapon on death, remove it UTIL_Remove(pNeoWeapon); return; diff --git a/src/game/shared/basecombatweapon_shared.cpp b/src/game/shared/basecombatweapon_shared.cpp index 3007a15d62..e72e024be8 100644 --- a/src/game/shared/basecombatweapon_shared.cpp +++ b/src/game/shared/basecombatweapon_shared.cpp @@ -336,19 +336,7 @@ const FileWeaponInfo_t &CBaseCombatWeapon::GetWpnData( void ) const //----------------------------------------------------------------------------- const char *CBaseCombatWeapon::GetViewModel( int /*viewmodelindex = 0 -- this is ignored in the base class here*/ ) const { -#ifdef NEO - auto owner = GetOwner(); - - if (!owner) - { - return GetWpnData().szViewModel; - } - - return owner->GetTeamNumber() == TEAM_JINRAI ? - GetWpnData().szViewModel : GetWpnData().szViewModel2; -#else return GetWpnData().szViewModel; -#endif } //----------------------------------------------------------------------------- diff --git a/src/game/shared/hl2mp/hl2mp_weapon_parse.cpp b/src/game/shared/hl2mp/hl2mp_weapon_parse.cpp index 8aa52825f7..55d1ea3461 100644 --- a/src/game/shared/hl2mp/hl2mp_weapon_parse.cpp +++ b/src/game/shared/hl2mp/hl2mp_weapon_parse.cpp @@ -9,21 +9,16 @@ #include "hl2mp_weapon_parse.h" #include "ammodef.h" +#ifndef NEO FileWeaponInfo_t* CreateWeaponInfo() { return new CHL2MPSWeaponInfo; } - - +#endif CHL2MPSWeaponInfo::CHL2MPSWeaponInfo() { m_iPlayerDamage = 0; - -#ifdef NEO - m_vecVMPosOffset = m_vecVMAimPosOffset = vec3_origin; - m_angVMAngOffset = m_angVMAimAngOffset = vec3_angle; -#endif } @@ -31,63 +26,5 @@ void CHL2MPSWeaponInfo::Parse( KeyValues *pKeyValuesData, const char *szWeaponNa { BaseClass::Parse( pKeyValuesData, szWeaponName ); -#ifndef NEO m_iPlayerDamage = pKeyValuesData->GetInt( "damage", 0 ); -#endif - -#ifdef NEO - m_iPlayerDamage = pKeyValuesData->GetInt("Damage", 0); - if (m_iPlayerDamage == 0) - { - m_iPlayerDamage = pKeyValuesData->GetInt("damage", 0); - } - - KeyValues *pViewModel = pKeyValuesData->FindKey("ViewModelOffset"); - if (pViewModel) - { - m_flVMFov = pKeyValuesData->GetFloat("VMFov", 60); - - m_vecVMPosOffset.x = pViewModel->GetFloat("forward", 0); - m_vecVMPosOffset.y = pViewModel->GetFloat("right", 0); - m_vecVMPosOffset.z = pViewModel->GetFloat("up", 0); - - m_angVMAngOffset[PITCH] = pViewModel->GetFloat("pitch", 0); - m_angVMAngOffset[YAW] = pViewModel->GetFloat("yaw", 0); - m_angVMAngOffset[ROLL] = pViewModel->GetFloat("roll", 0); - } - - // NEO TODO (Rain): add optional ironsight offsets - // in addition to "traditional" NT aim - - // AimOffset = Ironsight ADS offset (Disabled) - // ZoomOffset = Traditional ADS offset -#if 0 - KeyValues *pAimOffset = pKeyValuesData->FindKey("AimOffset"); -#else - KeyValues* pAimOffset = pKeyValuesData->FindKey("ZoomOffset"); -#endif - if (pAimOffset) - { - m_flVMAimFov = pAimOffset->GetFloat("fov", 55); - - m_vecVMAimPosOffset.x = pAimOffset->GetFloat("forward", 0); - m_vecVMAimPosOffset.y = pAimOffset->GetFloat("right", 0); - m_vecVMAimPosOffset.z = pAimOffset->GetFloat("up", 0); - - m_angVMAimAngOffset[PITCH] = pAimOffset->GetFloat("pitch", 0); - m_angVMAimAngOffset[YAW] = pAimOffset->GetFloat("yaw", 0); - m_angVMAimAngOffset[ROLL] = pAimOffset->GetFloat("roll", 0); - } - - // Get CycleTime AKA Fire-rate - m_flCycleTime = pKeyValuesData->GetFloat("CycleTime", 0.0f); -#ifdef _DEBUG - const char *printName = pKeyValuesData->GetString("printname"); - if (!V_strstr(printName, "#HL2") && !V_strstr(printName, "Grenade")) - { - Assert(m_flCycleTime != 0.0f); - } -#endif -#endif } - diff --git a/src/game/shared/hl2mp/hl2mp_weapon_parse.h b/src/game/shared/hl2mp/hl2mp_weapon_parse.h index d02a6eeb66..2ec16dd628 100644 --- a/src/game/shared/hl2mp/hl2mp_weapon_parse.h +++ b/src/game/shared/hl2mp/hl2mp_weapon_parse.h @@ -29,18 +29,6 @@ class CHL2MPSWeaponInfo : public FileWeaponInfo_t public: int m_iPlayerDamage; - -#ifdef NEO - float m_flVMFov = 0.0f; - Vector m_vecVMPosOffset; - QAngle m_angVMAngOffset; - - float m_flVMAimFov = 0.0f; - Vector m_vecVMAimPosOffset; - QAngle m_angVMAimAngOffset; - - float m_flCycleTime = 0.0f; -#endif }; diff --git a/src/game/shared/neo/neo_gamerules.cpp b/src/game/shared/neo/neo_gamerules.cpp index b891d26b2c..7435a657dd 100644 --- a/src/game/shared/neo/neo_gamerules.cpp +++ b/src/game/shared/neo/neo_gamerules.cpp @@ -4324,7 +4324,7 @@ void CNEORules::DeathNotice(CBasePlayer* pVictim, const CTakeDamageInfo& info) } else if (neoWep) { - event->SetString("deathIcon", neoWep->GetWpnData().szDeathIcon); + event->SetString("deathIcon", neoWep->GetNEOWpnData().szDeathIcon); } else { diff --git a/src/game/shared/neo/neo_player_shared.cpp b/src/game/shared/neo/neo_player_shared.cpp index f5fe86697e..ca92299f49 100644 --- a/src/game/shared/neo/neo_player_shared.cpp +++ b/src/game/shared/neo/neo_player_shared.cpp @@ -222,7 +222,7 @@ void KillerLineStr(char* killByLine, const int killByLineMax, { static constexpr float FOV_AIM_OFFSET_FALLBACK = 30.0f; auto *neoWep = dynamic_cast(wep); - return (neoWep) ? neoWep->GetWpnData().iAimFOV : fovDef - FOV_AIM_OFFSET_FALLBACK; + return (neoWep) ? neoWep->GetNEOWpnData().iAimFOV : fovDef - FOV_AIM_OFFSET_FALLBACK; } #ifdef CLIENT_DLL diff --git a/src/game/shared/neo/neo_predicted_viewmodel.cpp b/src/game/shared/neo/neo_predicted_viewmodel.cpp index a2c293bd65..06e7ed4cf8 100644 --- a/src/game/shared/neo/neo_predicted_viewmodel.cpp +++ b/src/game/shared/neo/neo_predicted_viewmodel.cpp @@ -3,7 +3,7 @@ #include "in_buttons.h" #include "neo_gamerules.h" -#include "weapon_hl2mpbase.h" +#include "weapon_neobasecombatweapon.h" #ifdef CLIENT_DLL #include "c_neo_player.h" @@ -480,14 +480,14 @@ void CNEOPredictedViewModel::CalcViewModelView(CBasePlayer *pOwner, } // Is there a nicer way to do this? - auto weapon = static_cast(GetOwningWeapon()); + auto weapon = static_cast(GetOwningWeapon()); if (!weapon) { return; } - CHL2MPSWeaponInfo data = weapon->GetHL2MPWpnData(); + CNEOWeaponInfo data = weapon->GetNEOWpnData(); Vector vForward, vRight, vUp, newPos, vOffset; QAngle newAng, angOffset; diff --git a/src/game/shared/neo/weapons/neo_weapon_parse.cpp b/src/game/shared/neo/weapons/neo_weapon_parse.cpp new file mode 100644 index 0000000000..0f0657e174 --- /dev/null +++ b/src/game/shared/neo/weapons/neo_weapon_parse.cpp @@ -0,0 +1,106 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//=============================================================================// + +#include +#include "neo_weapon_parse.h" + + +FileWeaponInfo_t* CreateWeaponInfo() +{ + return new CNEOWeaponInfo; +} + + +CNEOWeaponInfo::CNEOWeaponInfo() +{ + m_vecVMPosOffset = m_vecVMAimPosOffset = vec3_origin; + m_angVMAngOffset = m_angVMAimAngOffset = vec3_angle; + + vecVmOffset = vec3_origin; + szBulletCharacter[0] = 0; + szDeathIcon[0] = 0; + iAimFOV = 0; + m_flPenetration = 0.f; + m_bDropOnDeath = true; +} + + +void CNEOWeaponInfo::Parse( KeyValues *pKeyValuesData, const char *szWeaponName ) +{ + BaseClass::Parse( pKeyValuesData, szWeaponName ); + + m_iPlayerDamage = pKeyValuesData->GetInt( "Damage", 42 ); // Douglas Adams 1952 - 2001 + m_iBullets = pKeyValuesData->GetInt( "Bullets", 1 ); + m_flCycleTime = pKeyValuesData->GetFloat( "CycleTime", 0.15 ); +#ifdef _DEBUG + const char *printName = pKeyValuesData->GetString("printname"); + if (!V_strstr(printName, "#HL2") && !V_strstr(printName, "Grenade")) + { + Assert(m_flCycleTime != 0.0f); + } +#endif + + const char *pAnimEx = pKeyValuesData->GetString( "PlayerAnimationExtension", "mp5" ); + Q_strncpy( m_szAnimExtension, pAnimEx, sizeof( m_szAnimExtension ) ); + + KeyValues *pViewModel = pKeyValuesData->FindKey("ViewModelOffset"); + if (pViewModel) + { + m_flVMFov = pKeyValuesData->GetFloat("VMFov", 60); + + m_vecVMPosOffset.x = pViewModel->GetFloat("forward", 0); + m_vecVMPosOffset.y = pViewModel->GetFloat("right", 0); + m_vecVMPosOffset.z = pViewModel->GetFloat("up", 0); + + m_angVMAngOffset[PITCH] = pViewModel->GetFloat("pitch", 0); + m_angVMAngOffset[YAW] = pViewModel->GetFloat("yaw", 0); + m_angVMAngOffset[ROLL] = pViewModel->GetFloat("roll", 0); + } + + // NEO TODO (Rain): add optional ironsight offsets + // in addition to "traditional" NT aim + + // AimOffset = Ironsight ADS offset (Disabled) + // ZoomOffset = Traditional ADS offset +#if 0 + KeyValues *pAimOffset = pKeyValuesData->FindKey("AimOffset"); +#else + KeyValues* pAimOffset = pKeyValuesData->FindKey("ZoomOffset"); +#endif + if (pAimOffset) + { + m_flVMAimFov = pAimOffset->GetFloat("fov", 55); + + m_vecVMAimPosOffset.x = pAimOffset->GetFloat("forward", 0); + m_vecVMAimPosOffset.y = pAimOffset->GetFloat("right", 0); + m_vecVMAimPosOffset.z = pAimOffset->GetFloat("up", 0); + + m_angVMAimAngOffset[PITCH] = pAimOffset->GetFloat("pitch", 0); + m_angVMAimAngOffset[YAW] = pAimOffset->GetFloat("yaw", 0); + m_angVMAimAngOffset[ROLL] = pAimOffset->GetFloat("roll", 0); + } + + const char *notFoundStr = "notfound"; + Q_strncpy(szViewModel2, pKeyValuesData->GetString("team2viewmodel", notFoundStr), MAX_WEAPON_STRING); + // If there was no NSF viewmodel specified, fall back to Source's default "viewmodel" to ensure we have something sensible available. + // This might happen when attempting to equip a non-NT weapon. + if (Q_strcmp(szViewModel2, notFoundStr) == 0) + { + Q_strncpy(szViewModel2, pKeyValuesData->GetString("viewmodel"), MAX_WEAPON_STRING); + } + + const float VMOffsetForward = pKeyValuesData->GetFloat("VMOffsetForward"); + const float VMOffsetRight = pKeyValuesData->GetFloat("VMOffsetRight"); + const float VMOffsetUp = pKeyValuesData->GetFloat("VMOffsetUp"); + vecVmOffset = Vector(VMOffsetForward, VMOffsetRight, VMOffsetUp); + Q_strncpy( szBulletCharacter, pKeyValuesData->GetString("BulletCharacter", "a"), MAX_BULLET_CHARACTER); + Q_strncpy( szDeathIcon, pKeyValuesData->GetString("iDeathIcon", ""), MAX_BULLET_CHARACTER); + iAimFOV = pKeyValuesData->GetInt("AimFov", 45); + m_flPenetration = pKeyValuesData->GetFloat("Penetration", 0); + m_bDropOnDeath = pKeyValuesData->GetBool("DropOnDeath", true); +} + + diff --git a/src/game/shared/neo/weapons/neo_weapon_parse.h b/src/game/shared/neo/weapons/neo_weapon_parse.h new file mode 100644 index 0000000000..48ba4f6ece --- /dev/null +++ b/src/game/shared/neo/weapons/neo_weapon_parse.h @@ -0,0 +1,52 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//=============================================================================// + +#ifndef NEO_WEAPON_PARSE_H +#define NEO_WEAPON_PARSE_H +#ifdef _WIN32 +#pragma once +#endif + +#include "hl2mp_weapon_parse.h" + +//-------------------------------------------------------------------------------------------------------- +class CNEOWeaponInfo : public CHL2MPSWeaponInfo +{ +public: + DECLARE_CLASS_GAMEROOT( CNEOWeaponInfo, CHL2MPSWeaponInfo ); + + CNEOWeaponInfo(); + + virtual void Parse( ::KeyValues *pKeyValuesData, const char *szWeaponName ); + + // TODO: NT;RE hasn't been using this, idk if they're hardcoded somewhere else + char m_szAnimExtension[16]; // string used to generate player animations with this weapon + + // int m_iDamage; + int m_iBullets; + float m_flCycleTime = 0.0f; + + char szViewModel2[MAX_WEAPON_STRING]; // Team 2 (NSF) wep vm + + char szBulletCharacter[MAX_BULLET_CHARACTER];// character used to display ammunition in current clip + float m_flVMFov = 0.0f; + Vector m_vecVMPosOffset; + QAngle m_angVMAngOffset; + + float m_flVMAimFov = 0.0f; + Vector m_vecVMAimPosOffset; + QAngle m_angVMAimAngOffset; + + Vector vecVmOffset; + + char szDeathIcon[MAX_BULLET_CHARACTER]; + int iAimFOV; + float m_flPenetration; + bool m_bDropOnDeath; +}; + + +#endif // NEO_WEAPON_PARSE_H diff --git a/src/game/shared/neo/weapons/weapon_aa13.cpp b/src/game/shared/neo/weapons/weapon_aa13.cpp index 0f2adfffae..ac2a018e78 100644 --- a/src/game/shared/neo/weapons/weapon_aa13.cpp +++ b/src/game/shared/neo/weapons/weapon_aa13.cpp @@ -104,7 +104,8 @@ void CWeaponAA13::PrimaryAttack(void) Vector vecAiming = pPlayer->GetAutoaimVector(AUTOAIM_10DEGREES); Vector vecSpread = GetBulletSpread(); - FireBulletsInfo_t info(5, vecSrc, vecAiming, vecSpread, MAX_TRACE_LENGTH, m_iPrimaryAmmoType); + int numBullets = GetNEOWpnData().m_iBullets; + FireBulletsInfo_t info(numBullets, vecSrc, vecAiming, vecSpread, MAX_TRACE_LENGTH, m_iPrimaryAmmoType); info.m_pAttacker = pPlayer; info.m_iTracerFreq = 0; diff --git a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp index d2b4b22187..15bbc60a33 100644 --- a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp +++ b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp @@ -229,11 +229,39 @@ CNEOBaseCombatWeapon::CNEOBaseCombatWeapon( void ) m_bTriggerReset = true; } +const CNEOWeaponInfo &CNEOBaseCombatWeapon::GetNEOWpnData() const +{ + const FileWeaponInfo_t *pWeaponInfo = &GetWpnData(); + const CNEOWeaponInfo *pNEOInfo; + +#ifdef _DEBUG + pNEOInfo = dynamic_cast< const CNEOWeaponInfo* >( pWeaponInfo ); + Assert( pNEOInfo ); +#else + pNEOInfo = static_cast< const CNEOWeaponInfo* >( pWeaponInfo ); +#endif + + return *pNEOInfo; +} + void CNEOBaseCombatWeapon::Precache() { BaseClass::Precache(); } +const char *CNEOBaseCombatWeapon::GetViewModel( int ) const +{ + auto owner = GetOwner(); + + if (!owner) + { + return GetWpnData().szViewModel; + } + + return owner->GetTeamNumber() == TEAM_JINRAI ? + GetWpnData().szViewModel : GetNEOWpnData().szViewModel2; +} + void CNEOBaseCombatWeapon::Spawn() { // If this fires, either the enum bit mask has overflowed, @@ -490,7 +518,7 @@ bool CNEOBaseCombatWeapon::Deploy(void) } else { - pOwner->SetFOV(pOwner, GetWpnData().iAimFOV, 0.1); + pOwner->SetFOV(pOwner, GetNEOWpnData().iAimFOV, 0.1); } } else @@ -505,12 +533,12 @@ bool CNEOBaseCombatWeapon::Deploy(void) float CNEOBaseCombatWeapon::GetFireRate() { - return GetHL2MPWpnData().m_flCycleTime; + return GetNEOWpnData().m_flCycleTime; } float CNEOBaseCombatWeapon::GetPenetration() const { - return GetWpnData().m_flPenetration; + return GetNEOWpnData().m_flPenetration; } bool CNEOBaseCombatWeapon::Holster(CBaseCombatWeapon* pSwitchingTo) diff --git a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h index d00e539f9d..ae2beddbfc 100644 --- a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h +++ b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h @@ -22,6 +22,7 @@ #endif #include "weapon_bits.h" +#include "neo_weapon_parse.h" // These are the .res file id numbers for // NEO weapon loadout choices used by the @@ -140,6 +141,10 @@ class CNEOBaseCombatWeapon : public CBaseHL2MPCombatWeapon virtual bool CanBeSelected(void) override; + CNEOWeaponInfo const &GetNEOWpnData() const; + + virtual const char *GetViewModel( int viewmodelindex = 0 ) const override; + virtual NEO_WEP_BITS_UNDERLYING_TYPE GetNeoWepBits(void) const { Assert(false); return NEO_WEP_INVALID; } // Should never call this base class; implement in children. virtual int GetNeoWepXPCost(const int neoClass) const { Assert(false); return 0; } // Should never call this base class; implement in children. diff --git a/src/game/shared/neo/weapons/weapon_supa7.cpp b/src/game/shared/neo/weapons/weapon_supa7.cpp index b762c0789c..cb61154b4f 100644 --- a/src/game/shared/neo/weapons/weapon_supa7.cpp +++ b/src/game/shared/neo/weapons/weapon_supa7.cpp @@ -317,7 +317,7 @@ void CWeaponSupa7::PrimaryAttack(void) return; } - int numBullets = 7; + int numBullets = GetNEOWpnData().m_iBullets; Vector bulletSpread = GetBulletSpread(); int ammoType = m_iPrimaryAmmoType; Vector vecSrc = pPlayer->Weapon_ShootPosition(); diff --git a/src/game/shared/weapon_parse.cpp b/src/game/shared/weapon_parse.cpp index d3ee5828fd..2a8cbf7439 100644 --- a/src/game/shared/weapon_parse.cpp +++ b/src/game/shared/weapon_parse.cpp @@ -346,15 +346,6 @@ FileWeaponInfo_t::FileWeaponInfo_t() bShowUsageHint = false; m_bAllowFlipping = true; m_bBuiltRightHanded = true; - -#ifdef NEO - vecVmOffset = vec3_origin; - szBulletCharacter[0] = 0; - szDeathIcon[0] = 0; - iAimFOV = 0; - m_flPenetration = 0.f; - m_bDropOnDeath = true; -#endif } #ifdef CLIENT_DLL @@ -373,16 +364,6 @@ void FileWeaponInfo_t::Parse( KeyValues *pKeyValuesData, const char *szWeaponNam // View model Q_strncpy(szViewModel, pKeyValuesData->GetString("viewmodel"), MAX_WEAPON_STRING); -#ifdef NEO - const char *notFoundStr = "notfound"; - Q_strncpy(szViewModel2, pKeyValuesData->GetString("team2viewmodel", notFoundStr), MAX_WEAPON_STRING); - // If there was no NSF viewmodel specified, fall back to Source's default "viewmodel" to ensure we have something sensible available. - // This might happen when attempting to equip a non-NT weapon. - if (Q_strcmp(szViewModel2, notFoundStr) == 0) - { - Q_strncpy(szViewModel2, pKeyValuesData->GetString("viewmodel"), MAX_WEAPON_STRING); - } -#endif // World model Q_strncpy( szWorldModel, pKeyValuesData->GetString( "playermodel" ), MAX_WEAPON_STRING ); @@ -425,18 +406,6 @@ void FileWeaponInfo_t::Parse( KeyValues *pKeyValuesData, const char *szWeaponNam } } -#ifdef NEO - const float VMOffsetForward = pKeyValuesData->GetFloat("VMOffsetForward"); - const float VMOffsetRight = pKeyValuesData->GetFloat("VMOffsetRight"); - const float VMOffsetUp = pKeyValuesData->GetFloat("VMOffsetUp"); - vecVmOffset = Vector(VMOffsetForward, VMOffsetRight, VMOffsetUp); - Q_strncpy( szBulletCharacter, pKeyValuesData->GetString("BulletCharacter", "a"), MAX_BULLET_CHARACTER); - Q_strncpy( szDeathIcon, pKeyValuesData->GetString("iDeathIcon", ""), MAX_BULLET_CHARACTER); - iAimFOV = pKeyValuesData->GetInt("AimFov", 45); - m_flPenetration = pKeyValuesData->GetFloat("Penetration", 0); - m_bDropOnDeath = pKeyValuesData->GetBool("DropOnDeath", true); -#endif - bShowUsageHint = ( pKeyValuesData->GetInt( "showusagehint", 0 ) != 0 ) ? true : false; bAutoSwitchTo = ( pKeyValuesData->GetInt( "autoswitchto", 1 ) != 0 ) ? true : false; bAutoSwitchFrom = ( pKeyValuesData->GetInt( "autoswitchfrom", 1 ) != 0 ) ? true : false; diff --git a/src/game/shared/weapon_parse.h b/src/game/shared/weapon_parse.h index 51584285ac..3d99e76e07 100644 --- a/src/game/shared/weapon_parse.h +++ b/src/game/shared/weapon_parse.h @@ -84,9 +84,6 @@ class FileWeaponInfo_t char szPrintName[MAX_WEAPON_STRING]; // Name for showing in HUD, etc. char szViewModel[MAX_WEAPON_STRING]; // View model of this weapon -#ifdef NEO - char szViewModel2[MAX_WEAPON_STRING]; // Team 2 (NSF) wep vm -#endif char szWorldModel[MAX_WEAPON_STRING]; // Model of this weapon seen carried by the player char szAnimationPrefix[MAX_WEAPON_PREFIX]; // Prefix of the animations that should be used by the player carrying this weapon int iSlot; // inventory slot. @@ -103,15 +100,6 @@ class FileWeaponInfo_t char szAmmo1[MAX_WEAPON_AMMO_NAME]; // "primary" ammo type char szAmmo2[MAX_WEAPON_AMMO_NAME]; // "secondary" ammo type -#ifdef NEO - Vector vecVmOffset; - char szBulletCharacter[MAX_BULLET_CHARACTER];// character used to display ammunition in current clip - char szDeathIcon[MAX_BULLET_CHARACTER]; - int iAimFOV; - float m_flPenetration; - bool m_bDropOnDeath; -#endif - // Sound blocks char aShootSounds[NUM_SHOOT_SOUND_TYPES][MAX_WEAPON_STRING]; From 0d39506e72aec24b76c20bc803b3b66eef933791 Mon Sep 17 00:00:00 2001 From: Agiel Date: Tue, 31 Mar 2026 22:23:00 +0200 Subject: [PATCH 2/2] Cleanup --- .../shared/neo/weapons/neo_weapon_parse.cpp | 57 ++++++++----------- .../shared/neo/weapons/neo_weapon_parse.h | 24 +++----- 2 files changed, 31 insertions(+), 50 deletions(-) diff --git a/src/game/shared/neo/weapons/neo_weapon_parse.cpp b/src/game/shared/neo/weapons/neo_weapon_parse.cpp index 0f0657e174..5a7dbd3214 100644 --- a/src/game/shared/neo/weapons/neo_weapon_parse.cpp +++ b/src/game/shared/neo/weapons/neo_weapon_parse.cpp @@ -16,15 +16,18 @@ FileWeaponInfo_t* CreateWeaponInfo() CNEOWeaponInfo::CNEOWeaponInfo() { - m_vecVMPosOffset = m_vecVMAimPosOffset = vec3_origin; - m_angVMAngOffset = m_angVMAimAngOffset = vec3_angle; - - vecVmOffset = vec3_origin; + m_iBullets = 0; + m_flCycleTime = 0.f; + szViewModel2[0] = 0; szBulletCharacter[0] = 0; szDeathIcon[0] = 0; - iAimFOV = 0; m_flPenetration = 0.f; m_bDropOnDeath = true; + iAimFOV = 0; + + m_flVMFov = m_flVMAimFov = 0.f; + m_vecVMPosOffset = m_vecVMAimPosOffset = vec3_origin; + m_angVMAngOffset = m_angVMAimAngOffset = vec3_angle; } @@ -32,19 +35,24 @@ void CNEOWeaponInfo::Parse( KeyValues *pKeyValuesData, const char *szWeaponName { BaseClass::Parse( pKeyValuesData, szWeaponName ); - m_iPlayerDamage = pKeyValuesData->GetInt( "Damage", 42 ); // Douglas Adams 1952 - 2001 - m_iBullets = pKeyValuesData->GetInt( "Bullets", 1 ); - m_flCycleTime = pKeyValuesData->GetFloat( "CycleTime", 0.15 ); -#ifdef _DEBUG - const char *printName = pKeyValuesData->GetString("printname"); - if (!V_strstr(printName, "#HL2") && !V_strstr(printName, "Grenade")) + m_iPlayerDamage = pKeyValuesData->GetInt( "Damage", 42 ); // Douglas Adams 1952 - 2001 + m_iBullets = pKeyValuesData->GetInt( "Bullets", 1 ); + m_flCycleTime = pKeyValuesData->GetFloat( "CycleTime", 0.15 ); + + const char *notFoundStr = "notfound"; + Q_strncpy(szViewModel2, pKeyValuesData->GetString("team2viewmodel", notFoundStr), MAX_WEAPON_STRING); + // If there was no NSF viewmodel specified, fall back to Source's default "viewmodel" to ensure we have something sensible available. + // This might happen when attempting to equip a non-NT weapon. + if (Q_strcmp(szViewModel2, notFoundStr) == 0) { - Assert(m_flCycleTime != 0.0f); + Q_strncpy(szViewModel2, pKeyValuesData->GetString("viewmodel"), MAX_WEAPON_STRING); } -#endif - const char *pAnimEx = pKeyValuesData->GetString( "PlayerAnimationExtension", "mp5" ); - Q_strncpy( m_szAnimExtension, pAnimEx, sizeof( m_szAnimExtension ) ); + Q_strncpy( szBulletCharacter, pKeyValuesData->GetString("BulletCharacter", "a"), MAX_BULLET_CHARACTER); + Q_strncpy( szDeathIcon, pKeyValuesData->GetString("iDeathIcon", ""), MAX_BULLET_CHARACTER); + m_flPenetration = pKeyValuesData->GetFloat("Penetration", 0); + m_bDropOnDeath = pKeyValuesData->GetBool("DropOnDeath", true); + iAimFOV = pKeyValuesData->GetInt("AimFov", 45); KeyValues *pViewModel = pKeyValuesData->FindKey("ViewModelOffset"); if (pViewModel) @@ -82,25 +90,6 @@ void CNEOWeaponInfo::Parse( KeyValues *pKeyValuesData, const char *szWeaponName m_angVMAimAngOffset[YAW] = pAimOffset->GetFloat("yaw", 0); m_angVMAimAngOffset[ROLL] = pAimOffset->GetFloat("roll", 0); } - - const char *notFoundStr = "notfound"; - Q_strncpy(szViewModel2, pKeyValuesData->GetString("team2viewmodel", notFoundStr), MAX_WEAPON_STRING); - // If there was no NSF viewmodel specified, fall back to Source's default "viewmodel" to ensure we have something sensible available. - // This might happen when attempting to equip a non-NT weapon. - if (Q_strcmp(szViewModel2, notFoundStr) == 0) - { - Q_strncpy(szViewModel2, pKeyValuesData->GetString("viewmodel"), MAX_WEAPON_STRING); - } - - const float VMOffsetForward = pKeyValuesData->GetFloat("VMOffsetForward"); - const float VMOffsetRight = pKeyValuesData->GetFloat("VMOffsetRight"); - const float VMOffsetUp = pKeyValuesData->GetFloat("VMOffsetUp"); - vecVmOffset = Vector(VMOffsetForward, VMOffsetRight, VMOffsetUp); - Q_strncpy( szBulletCharacter, pKeyValuesData->GetString("BulletCharacter", "a"), MAX_BULLET_CHARACTER); - Q_strncpy( szDeathIcon, pKeyValuesData->GetString("iDeathIcon", ""), MAX_BULLET_CHARACTER); - iAimFOV = pKeyValuesData->GetInt("AimFov", 45); - m_flPenetration = pKeyValuesData->GetFloat("Penetration", 0); - m_bDropOnDeath = pKeyValuesData->GetBool("DropOnDeath", true); } diff --git a/src/game/shared/neo/weapons/neo_weapon_parse.h b/src/game/shared/neo/weapons/neo_weapon_parse.h index 48ba4f6ece..c36e610af5 100644 --- a/src/game/shared/neo/weapons/neo_weapon_parse.h +++ b/src/game/shared/neo/weapons/neo_weapon_parse.h @@ -22,30 +22,22 @@ class CNEOWeaponInfo : public CHL2MPSWeaponInfo virtual void Parse( ::KeyValues *pKeyValuesData, const char *szWeaponName ); - // TODO: NT;RE hasn't been using this, idk if they're hardcoded somewhere else - char m_szAnimExtension[16]; // string used to generate player animations with this weapon - - // int m_iDamage; int m_iBullets; - float m_flCycleTime = 0.0f; - + float m_flCycleTime; char szViewModel2[MAX_WEAPON_STRING]; // Team 2 (NSF) wep vm - char szBulletCharacter[MAX_BULLET_CHARACTER];// character used to display ammunition in current clip - float m_flVMFov = 0.0f; + char szDeathIcon[MAX_BULLET_CHARACTER]; + float m_flPenetration; + bool m_bDropOnDeath; + int iAimFOV; + + float m_flVMFov; Vector m_vecVMPosOffset; QAngle m_angVMAngOffset; - float m_flVMAimFov = 0.0f; + float m_flVMAimFov; Vector m_vecVMAimPosOffset; QAngle m_angVMAimAngOffset; - - Vector vecVmOffset; - - char szDeathIcon[MAX_BULLET_CHARACTER]; - int iAimFOV; - float m_flPenetration; - bool m_bDropOnDeath; };