From a87fab253c488daab5936903650b23ce407931de Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sat, 7 Nov 2026 18:50:00 -0700 Subject: [PATCH 01/55] Parse the ReloadPhases weapon-script block A weapon script may list, per viewmodel reload sequence, the reload phases it credits (drop, seat, bolt), when each counts and when each sound piece plays. Weapons without the block parse no tables, which keeps them on the existing reload. --- .../shared/neo/weapons/neo_weapon_parse.cpp | 66 +++++++++++++++++++ .../shared/neo/weapons/neo_weapon_parse.h | 54 +++++++++++++++ 2 files changed, 120 insertions(+) diff --git a/src/game/shared/neo/weapons/neo_weapon_parse.cpp b/src/game/shared/neo/weapons/neo_weapon_parse.cpp index bafe4597b6..71c9469276 100644 --- a/src/game/shared/neo/weapons/neo_weapon_parse.cpp +++ b/src/game/shared/neo/weapons/neo_weapon_parse.cpp @@ -24,6 +24,7 @@ CNEOWeaponInfo::CNEOWeaponInfo() m_flPenetration = 0.f; m_bDropOnDeath = true; iAimFOV = 0; + m_iNumReloadTables = 0; m_flVMFov = m_flVMAimFov = 0.f; m_vecVMPosOffset = m_vecVMAimPosOffset = vec3_origin; @@ -31,6 +32,70 @@ CNEOWeaponInfo::CNEOWeaponInfo() } +static ReloadPhase_t ReloadPhaseFromName(const char *pszName) +{ + static constexpr const char *PHASE_NAMES[RELOAD_PHASE_COUNT] = { "", "drop", "seat", "bolt" }; + for (int i = RELOAD_PHASE_DROPPED; i < RELOAD_PHASE_COUNT; ++i) + { + if (V_stricmp(pszName, PHASE_NAMES[i]) == 0) + { + return static_cast(i); + } + } + return RELOAD_PHASE_NONE; +} + +// "ReloadPhases" { "" { "" { "credit" "s" "sound" "name" "at" "s" } ... } ... } +void CNEOWeaponInfo::ParseReloadPhases(KeyValues *pBlock) +{ + m_iNumReloadTables = 0; + if (!pBlock) + { + return; + } + + for (KeyValues *pSeq = pBlock->GetFirstTrueSubKey(); pSeq && m_iNumReloadTables < RELOAD_PHASE_TABLES_MAX; pSeq = pSeq->GetNextTrueSubKey()) + { + ReloadPhaseTable_t &table = m_reloadTables[m_iNumReloadTables++]; + V_strncpy(table.szSequence, pSeq->GetName(), sizeof(table.szSequence)); + table.iNumRows = 0; + + for (KeyValues *pRow = pSeq->GetFirstTrueSubKey(); pRow && table.iNumRows < RELOAD_PHASE_ROWS_MAX; pRow = pRow->GetNextTrueSubKey()) + { + const ReloadPhase_t phase = ReloadPhaseFromName(pRow->GetName()); + if (phase == RELOAD_PHASE_NONE) + { + Warning("%s: unknown reload phase \"%s\" in \"%s\"\n", szClassName, pRow->GetName(), table.szSequence); + continue; + } + + ReloadPhaseRow_t &row = table.rows[table.iNumRows++]; + row.phase = phase; + row.flCredit = pRow->GetFloat("credit"); + static constexpr const char *SOUND_KEYS[RELOAD_SOUNDS_PER_ROW][2] = { + { "sound", "at" }, { "sound2", "at2" }, { "sound3", "at3" } + }; + for (int j = 0; j < RELOAD_SOUNDS_PER_ROW; ++j) + { + row.sounds[j].flAt = pRow->GetFloat(SOUND_KEYS[j][1]); + V_strncpy(row.sounds[j].szName, pRow->GetString(SOUND_KEYS[j][0]), sizeof(row.sounds[j].szName)); + } + } + } +} + +int CNEOWeaponInfo::FindReloadTable(const char *pszSequence) const +{ + for (int i = 0; i < m_iNumReloadTables; ++i) + { + if (V_stricmp(m_reloadTables[i].szSequence, pszSequence) == 0) + { + return i; + } + } + return -1; +} + void CNEOWeaponInfo::Parse( KeyValues *pKeyValuesData, const char *szWeaponName ) { BaseClass::Parse( pKeyValuesData, szWeaponName ); @@ -39,6 +104,7 @@ void CNEOWeaponInfo::Parse( KeyValues *pKeyValuesData, const char *szWeaponName m_iBullets = pKeyValuesData->GetInt( "Bullets", 1 ); m_flCycleTime = pKeyValuesData->GetFloat( "CycleTime", 0.15 ); m_flReloadReadyBeforeEnd = pKeyValuesData->GetFloat( "ReloadReadyBeforeEnd", 0.0f ); + ParseReloadPhases(pKeyValuesData->FindKey("ReloadPhases")); const char *notFoundStr = "notfound"; Q_strncpy(szViewModel2, pKeyValuesData->GetString("team2viewmodel", notFoundStr), MAX_WEAPON_STRING); diff --git a/src/game/shared/neo/weapons/neo_weapon_parse.h b/src/game/shared/neo/weapons/neo_weapon_parse.h index 040dc00649..87a12bf85a 100644 --- a/src/game/shared/neo/weapons/neo_weapon_parse.h +++ b/src/game/shared/neo/weapons/neo_weapon_parse.h @@ -12,6 +12,53 @@ #include "hl2mp_weapon_parse.h" +// A reload is a linear sequence of phases; a reload sequence credits each phase at a point of its animation +enum ReloadPhase_t +{ + RELOAD_PHASE_NONE = 0, // no reload in progress, or none pending + RELOAD_PHASE_DROPPED, // the old magazine is out + RELOAD_PHASE_SEATED, // the fresh magazine is in + RELOAD_PHASE_BOLTED, // the bolt or charging handle chambered a round + + RELOAD_PHASE_COUNT +}; + +// bits to network a phase +static constexpr int RELOAD_PHASE_BITS = 2; +static_assert((1 << RELOAD_PHASE_BITS) >= RELOAD_PHASE_COUNT, "RELOAD_PHASE_BITS cannot hold every phase"); +static constexpr int RELOAD_PHASE_TABLES_MAX = 12; +// bits to network a table index, signed so that -1 (no table) fits +static constexpr int RELOAD_PHASE_TABLE_BITS = 5; +static_assert((1 << (RELOAD_PHASE_TABLE_BITS - 1)) >= RELOAD_PHASE_TABLES_MAX, "RELOAD_PHASE_TABLE_BITS cannot hold every table index"); +static constexpr int RELOAD_PHASE_ROWS_MAX = RELOAD_PHASE_COUNT - 1; +static constexpr int RELOAD_SOUND_NAME_MAX = 64; +static constexpr int RELOAD_SEQUENCE_NAME_MAX = 32; +// a phase may need more than one sound piece, such as a magazine seat and its slap +static constexpr int RELOAD_SOUNDS_PER_ROW = 3; + +// A sound piece of a phase +struct ReloadSoundPiece_t +{ + float flAt; // when the piece's first transient plays, seconds from the sequence start + char szName[RELOAD_SOUND_NAME_MAX]; +}; + +// One phase of a reload sequence: when it is credited, and the sound pieces that go with it +struct ReloadPhaseRow_t +{ + ReloadPhase_t phase; + float flCredit; // seconds from the sequence start + ReloadSoundPiece_t sounds[RELOAD_SOUNDS_PER_ROW]; +}; + +// The phases one reload sequence carries, in order +struct ReloadPhaseTable_t +{ + char szSequence[RELOAD_SEQUENCE_NAME_MAX]; + int iNumRows; + ReloadPhaseRow_t rows[RELOAD_PHASE_ROWS_MAX]; +}; + //-------------------------------------------------------------------------------------------------------- class CNEOWeaponInfo : public CHL2MPSWeaponInfo { @@ -25,6 +72,10 @@ class CNEOWeaponInfo : public CHL2MPSWeaponInfo int m_iBullets; float m_flCycleTime; float m_flReloadReadyBeforeEnd; + int m_iNumReloadTables; // 0: the weapon reloads without phases + ReloadPhaseTable_t m_reloadTables[RELOAD_PHASE_TABLES_MAX]; + + int FindReloadTable(const char *pszSequence) const; char szViewModel2[MAX_WEAPON_STRING]; // Team 2 (NSF) wep vm char szBulletCharacter[MAX_BULLET_CHARACTER];// character used to display ammunition in current clip char szDeathIcon[MAX_BULLET_CHARACTER]; @@ -39,6 +90,9 @@ class CNEOWeaponInfo : public CHL2MPSWeaponInfo float m_flVMAimFov; Vector m_vecVMAimPosOffset; QAngle m_angVMAimAngOffset; + +private: + void ParseReloadPhases(::KeyValues *pBlock); }; From c8a4eb83c872724afd9c19b958d18bcb7bbdce33 Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sat, 7 Nov 2026 18:50:42 -0700 Subject: [PATCH 02/55] Resume a reload after the magazine drop Behind sv_neo_reload_experimental (default 0), a weapon whose script has a ReloadPhases block credits the drop of its old magazine during the reload. A switch after the drop keeps that phase, and the next draw plays the weapon's draw-resume sequence, which seats the fresh magazine and pulls the bolt. A switch before the drop cancels the reload as before. The reload itself, its sound and its ready-time load are unchanged. Weapons without the block, and every weapon with the flag off, run the existing code. --- .../weapons/weapon_neobasecombatweapon.cpp | 231 ++++++++++++++++++ .../neo/weapons/weapon_neobasecombatweapon.h | 22 ++ 2 files changed, 253 insertions(+) diff --git a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp index 979d70f8a7..bf36975d3d 100644 --- a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp +++ b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp @@ -42,6 +42,11 @@ BEGIN_NETWORK_TABLE( CNEOBaseCombatWeapon, DT_NEOBaseCombatWeapon ) RecvPropInt(RECVINFO(m_nNumShotsFired)), RecvPropBool(RECVINFO(m_bTriggerReset)), RecvPropTime(RECVINFO(m_flReloadReadyTime)), + RecvPropBool(RECVINFO(m_bReloadExperimentalEnabled)), + RecvPropInt(RECVINFO(m_nReloadPhase)), + RecvPropInt(RECVINFO(m_nReloadTable)), + RecvPropTime(RECVINFO(m_flReloadStart)), + RecvPropInt(RECVINFO(m_nReloadSoundsDone)), RecvPropInt(RECVINFO(m_spawnflags)), #else SendPropTime(SENDINFO(m_flSoonestAttack)), @@ -50,6 +55,11 @@ BEGIN_NETWORK_TABLE( CNEOBaseCombatWeapon, DT_NEOBaseCombatWeapon ) SendPropInt(SENDINFO(m_nNumShotsFired)), SendPropBool(SENDINFO(m_bTriggerReset)), SendPropTime(SENDINFO(m_flReloadReadyTime)), + SendPropBool(SENDINFO(m_bReloadExperimentalEnabled)), + SendPropInt(SENDINFO(m_nReloadPhase), RELOAD_PHASE_BITS, SPROP_UNSIGNED), + SendPropInt(SENDINFO(m_nReloadTable), RELOAD_PHASE_TABLE_BITS), + SendPropTime(SENDINFO(m_flReloadStart)), + SendPropInt(SENDINFO(m_nReloadSoundsDone), RELOAD_PHASE_ROWS_MAX * RELOAD_SOUNDS_PER_ROW, SPROP_UNSIGNED), SendPropInt(SENDINFO(m_spawnflags)), SendPropExclude("DT_BaseAnimating", "m_nSequence"), #endif @@ -63,6 +73,11 @@ BEGIN_PREDICTION_DATA(CNEOBaseCombatWeapon) DEFINE_PRED_FIELD(m_nNumShotsFired, FIELD_INTEGER, FTYPEDESC_INSENDTABLE), DEFINE_PRED_FIELD(m_bTriggerReset, FIELD_BOOLEAN, FTYPEDESC_INSENDTABLE), DEFINE_PRED_FIELD(m_flReloadReadyTime, FIELD_FLOAT, FTYPEDESC_INSENDTABLE), + DEFINE_PRED_FIELD(m_bReloadExperimentalEnabled, FIELD_BOOLEAN, FTYPEDESC_INSENDTABLE), + DEFINE_PRED_FIELD(m_nReloadPhase, FIELD_INTEGER, FTYPEDESC_INSENDTABLE), + DEFINE_PRED_FIELD(m_nReloadTable, FIELD_INTEGER, FTYPEDESC_INSENDTABLE), + DEFINE_PRED_FIELD(m_flReloadStart, FIELD_FLOAT, FTYPEDESC_INSENDTABLE), + DEFINE_PRED_FIELD(m_nReloadSoundsDone, FIELD_INTEGER, FTYPEDESC_INSENDTABLE), END_PREDICTION_DATA() #endif @@ -76,11 +91,18 @@ BEGIN_DATADESC( CNEOBaseCombatWeapon ) DEFINE_FIELD(m_nNumShotsFired, FIELD_INTEGER), DEFINE_FIELD(m_bTriggerReset, FIELD_BOOLEAN), DEFINE_FIELD(m_flReloadReadyTime, FIELD_TIME), + DEFINE_FIELD(m_bReloadExperimentalEnabled, FIELD_BOOLEAN), + DEFINE_FIELD(m_nReloadPhase, FIELD_INTEGER), + DEFINE_FIELD(m_nReloadTable, FIELD_INTEGER), + DEFINE_FIELD(m_flReloadStart, FIELD_TIME), + DEFINE_FIELD(m_nReloadSoundsDone, FIELD_INTEGER), END_DATADESC() #endif ConVar sv_neo_accuracy_penalty_scale("sv_neo_accuracy_penalty_scale", "1.0", FCVAR_REPLICATED, "Scales the accuracy penalty per shot.", true, 0.0f, true, 2.0f); ConVar sv_neo_dynamic_viewkick("sv_neo_dynamic_viewkick", "0", FCVAR_REPLICATED, "Enables view kick scaling based on current inaccuracy.", true, 0.0f, true, 1.0f); +ConVar sv_neo_reload_experimental("sv_neo_reload_experimental", "0", FCVAR_REPLICATED, + "Server reload-phase setting; set before a game starts; mid-game changes are unsupported."); const char *GetWeaponByLoadoutId(int id) { @@ -232,7 +254,12 @@ static const WeaponHandlingInfo_t handlingTable[] = { CNEOBaseCombatWeapon::CNEOBaseCombatWeapon( void ) { + m_bReloadExperimentalEnabled = sv_neo_reload_experimental.GetBool(); m_bTriggerReset = true; + m_nReloadPhase = RELOAD_PHASE_NONE; + m_nReloadTable = -1; + m_flReloadStart = 0.0f; + m_nReloadSoundsDone = 0; } const CNEOWeaponInfo &CNEOBaseCombatWeapon::GetNEOWpnData() const @@ -418,6 +445,9 @@ void CNEOBaseCombatWeapon::Equip(CBaseCombatCharacter* pOwner) } +// The shipped reload sequence +static constexpr const char *VM_SEQ_RELOAD = "reload"; + bool CNEOBaseCombatWeapon::Reload( void ) { const bool bEmptyReload = UsesClipsForAmmo1() && m_iClip1 <= 0 && @@ -441,6 +471,11 @@ bool CNEOBaseCombatWeapon::Reload( void ) // the animation and the wait to fire still run to the end m_flReloadReadyTime = Max(gpGlobals->curtime, m_flNextPrimaryAttack - GetNEOWpnData().m_flReloadReadyBeforeEnd); + if (IsReloadPhaseSystemEnabled()) + { + StartReloadPhases(GetNEOWpnData().FindReloadTable(VM_SEQ_RELOAD)); + } + return true; #if(0) @@ -471,6 +506,169 @@ bool CNEOBaseCombatWeapon::Reload( void ) #endif } +// Each reload sound piece's file starts this long before its first transient +static constexpr float RELOAD_SOUND_LEAD = 0.02f; + +// The viewmodel sequence that resumes a reload interrupted after the phase credited last; nullptr: none +// (resume sequences carry no activity, so they are picked by name) +static const char *ResumeSequenceName(int iPhaseDone) +{ + switch (iPhaseDone) + { + case RELOAD_PHASE_DROPPED: + // the magazine is out: the draw itself brings the fresh one up + return "draw_resume_drop_dry"; + default: + return nullptr; + } +} + +bool CNEOBaseCombatWeapon::IsReloadPhaseSystemEnabled() const +{ + return m_bReloadExperimentalEnabled && GetNEOWpnData().m_iNumReloadTables > 0; +} + +// Credit the phases of a reload sequence that starts now (-1: a sequence without a table credits nothing) +void CNEOBaseCombatWeapon::StartReloadPhases(int iTable) +{ + m_nReloadTable = iTable; + m_flReloadStart = gpGlobals->curtime; + m_nReloadSoundsDone = 0; +} + +void CNEOBaseCombatWeapon::EndReloadPhases() +{ + m_nReloadTable = -1; + m_nReloadPhase = RELOAD_PHASE_NONE; +} + +// Credit every phase of the playing reload sequence whose time has come, and play its sound pieces +void CNEOBaseCombatWeapon::RunReloadPhases() +{ + if (!m_bInReload || m_nReloadTable < 0) + { + return; + } + + const ReloadPhaseTable_t &table = GetNEOWpnData().m_reloadTables[m_nReloadTable]; + const float flElapsed = gpGlobals->curtime - m_flReloadStart; + + // Sound pieces play on their own times, before or after their phase's credit + for (int i = 0; i < table.iNumRows; ++i) + { + for (int j = 0; j < RELOAD_SOUNDS_PER_ROW; ++j) + { + const ReloadSoundPiece_t &piece = table.rows[i].sounds[j]; + const int iBit = 1 << (i * RELOAD_SOUNDS_PER_ROW + j); + if (piece.szName[0] && !(m_nReloadSoundsDone & iBit) && flElapsed >= piece.flAt - RELOAD_SOUND_LEAD) + { + m_nReloadSoundsDone |= iBit; + EmitReloadSoundPiece(piece.szName); + } + } + } + + for (int i = 0; i < table.iNumRows; ++i) + { + const ReloadPhaseRow_t &row = table.rows[i]; + if (row.phase <= m_nReloadPhase) + { + continue; + } + + if (flElapsed < row.flCredit) + { + break; + } + + CreditReloadPhase(row.phase); + } +} + +void CNEOBaseCombatWeapon::CreditReloadPhase(ReloadPhase_t phase) +{ + switch (phase) + { + case RELOAD_PHASE_DROPPED: + // the old magazine and its rounds are gone, as when the reload loads at its ready time + m_iClip1 = 0; + break; + case RELOAD_PHASE_SEATED: + m_iClip1 = Min(GetMaxClip1(), m_iPrimaryAmmoCount.Get()); + m_iPrimaryAmmoCount -= m_iClip1; + break; + default: + break; + } + + m_nReloadPhase = phase; +} + +// Resume, in the draw, a reload interrupted by a switch; a model without the resume sequence reloads afresh +void CNEOBaseCombatWeapon::ResumeReload() +{ + const char *pszName = ResumeSequenceName(m_nReloadPhase); + const int iTable = pszName ? GetNEOWpnData().FindReloadTable(pszName) : -1; + const int iSequence = (iTable >= 0) ? LookupReloadSequence(pszName) : -1; + if (iSequence < 0) + { + m_nReloadPhase = RELOAD_PHASE_NONE; + return; + } + + SetSequence(iSequence); + SendViewModelAnim(iSequence); + + // the draw is part of the motion: the full reload gesture fits the resume + ToHL2MPPlayer(GetOwner())->DoAnimationEvent(PLAYERANIMEVENT_RELOAD); + + const float flEnd = gpGlobals->curtime + ReloadViewModel()->SequenceDuration(iSequence); + GetOwner()->SetNextAttack(flEnd); + m_flNextPrimaryAttack = m_flNextSecondaryAttack = flEnd; + SetWeaponIdleTime(flEnd); + + // the seat credit loads the magazine + m_flReloadReadyTime = 0.0f; + StartReloadPhases(iTable); + m_bInReload = true; +} + +// Reload sequences are looked up on the owner's viewmodel: on the client the weapon entity carries the world model, +// so a lookup there would fail and the client would predict a different sequence than the server plays +CBaseViewModel *CNEOBaseCombatWeapon::ReloadViewModel() const +{ + CBasePlayer *pOwner = ToBasePlayer(GetOwner()); + return pOwner ? pOwner->GetViewModel(m_nViewModelIndex) : nullptr; +} + +int CNEOBaseCombatWeapon::LookupReloadSequence(const char *pszName) const +{ + CBaseViewModel *pVM = ReloadViewModel(); + return pVM ? pVM->LookupSequence(pszName) : -1; +} + +// Play a reload sound piece from the owner, as WeaponSound does: predicted for the owner, from the server for the rest +void CNEOBaseCombatWeapon::EmitReloadSoundPiece(const char *pszSound) +{ + CBaseCombatCharacter *pOwner = GetOwner(); + if (!pOwner) + { + return; + } + + CSoundParameters params; + if (!GetParametersForSound(pszSound, params, NULL)) + { + return; + } + + CPASAttenuationFilter filter(pOwner, params.soundlevel); + if (IsPredicted() && CBaseEntity::GetPredictionPlayer()) + { + filter.UsePredictionRules(); + } + EmitSound(filter, pOwner->entindex(), pszSound); +} //----------------------------------------------------------------------------- // Purpose: Reload has finished. @@ -484,6 +682,12 @@ void CNEOBaseCombatWeapon::FinishReload(void) } m_flReloadReadyTime = 0.0f; + // the magazine is in: nothing is left to credit or resume + if (IsReloadPhaseSystemEnabled()) + { + EndReloadPhases(); + } + CBaseCombatCharacter* pOwner = GetOwner(); if (pOwner) @@ -540,6 +744,12 @@ bool CNEOBaseCombatWeapon::Deploy(void) SendViewModelAnim(iDrawEmpty); } + // A reload interrupted by a switch goes on in the draw + if (IsReloadPhaseSystemEnabled() && m_nReloadPhase != RELOAD_PHASE_NONE) + { + ResumeReload(); + } + #ifdef DEBUG CNEO_Player* pOwner = NULL; if (GetOwner()) @@ -600,6 +810,16 @@ float CNEOBaseCombatWeapon::GetPenetration() const bool CNEOBaseCombatWeapon::Holster(CBaseCombatWeapon* pSwitchingTo) { + // Only a phase that a sequence resumes from outlasts the switch + if (IsReloadPhaseSystemEnabled()) + { + if (!ResumeSequenceName(m_nReloadPhase)) + { + m_nReloadPhase = RELOAD_PHASE_NONE; + } + m_nReloadTable = -1; + } + return BaseClass::Holster(pSwitchingTo); } @@ -611,6 +831,12 @@ void CNEOBaseCombatWeapon::CheckReload(void) } BaseClass::CheckReload(); + + // a reload that ran to its end leaves nothing to resume + if (IsReloadPhaseSystemEnabled() && !m_bInReload && m_nReloadTable >= 0) + { + EndReloadPhases(); + } } float CNEOBaseCombatWeapon::GetAccuracyPenaltyDecay() @@ -655,6 +881,11 @@ void CNEOBaseCombatWeapon::ItemBusyFrame(void) BaseClass::ItemBusyFrame(); UpdateInaccuracy(); + if (IsReloadPhaseSystemEnabled()) + { + RunReloadPhases(); + } + // The owner stays busy until the reload animation ends, but the magazine loads at the reload's ready time if (m_bInReload && m_flReloadReadyTime > 0.0f && gpGlobals->curtime >= m_flReloadReadyTime) { diff --git a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h index a772edda17..433b63150e 100644 --- a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h +++ b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h @@ -282,6 +282,7 @@ class CNEOBaseCombatWeapon : public CBaseHL2MPCombatWeapon virtual float GetMaxAccuracyPenalty() const { return 1.0; } virtual float GetAccuracyPenaltyDecay(); virtual float GetFastestDryRefireTime() const { Assert(false); return 0; } // Should never call this base class; implement in children. + bool IsReloadPhaseSystemEnabled() const; protected: CNetworkVar(float, m_flSoonestAttack); @@ -294,10 +295,31 @@ class CNEOBaseCombatWeapon : public CBaseHL2MPCombatWeapon // When the reload in progress loads the magazine, 0 once it is loaded CNetworkVar(float, m_flReloadReadyTime); + // The server's pre-game reload setting, snapshotted for prediction + CNetworkVar(bool, m_bReloadExperimentalEnabled); + + // Reload phases (weapons whose script has a ReloadPhases block): the last phase credited, kept across a switch + CNetworkVar(int, m_nReloadPhase); + // the phase table of the sequence playing, -1 none + CNetworkVar(int, m_nReloadTable); + // when the reload sequence started; phase credits are offsets from it + CNetworkVar(float, m_flReloadStart); + // the sound pieces of the playing sequence already started, one bit per piece + CNetworkVar(int, m_nReloadSoundsDone); + private: CNEOBaseCombatWeapon(const CNEOBaseCombatWeapon &other); bool HasEmptyIdle(); + void StartReloadPhases(int iTable); + void EndReloadPhases(); + void RunReloadPhases(); + void CreditReloadPhase(ReloadPhase_t phase); + void ResumeReload(); + void EmitReloadSoundPiece(const char *pszSound); + CBaseViewModel *ReloadViewModel() const; + int LookupReloadSequence(const char *pszName) const; + }; #endif // WEAPON_NEO_BASECOMBATWEAPON_SHARED_H From e79cdec26c92c40c0b7095760a6d3cf635fa829d Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sat, 7 Nov 2026 18:51:24 -0700 Subject: [PATCH 03/55] Give the ZR68C a drop-resume reload The ZR68C reload credits the magazine drop at 0.700 s. The draw_resume_drop_dry sequence seats at 1.433 s and bolts at 2.367 s, with the seat, slap and bolt sound pieces at their transients. --- game/neo/scripts/game_sounds_weapons.txt | 29 ++++++++++++++++++++++++ game/neo/scripts/weapon_zr68c.txt | 15 ++++++++++++ 2 files changed, 44 insertions(+) diff --git a/game/neo/scripts/game_sounds_weapons.txt b/game/neo/scripts/game_sounds_weapons.txt index ad9ac75c4f..24d8e65ced 100644 --- a/game/neo/scripts/game_sounds_weapons.txt +++ b/game/neo/scripts/game_sounds_weapons.txt @@ -759,6 +759,35 @@ "wave" "weapons/zr68/zr68_reload.wav" } +// ZR68 reload in per-phase pieces (sv_neo_reload_experimental): each file starts just before its first transient + +"weapon_zr68.reload_seat" +{ + "channel" "CHAN_ITEM" + "soundlevel" "SNDLVL_NORM" + "volume" "1.0" + "pitch" "PITCH_NORM" + "wave" ")weapons/zr68/zr68_reload_seat.wav" +} + +"weapon_zr68.reload_slap" +{ + "channel" "CHAN_ITEM" + "soundlevel" "SNDLVL_NORM" + "volume" "1.0" + "pitch" "PITCH_NORM" + "wave" ")weapons/zr68/zr68_reload_slap.wav" +} + +"weapon_zr68.reload_bolt" +{ + "channel" "CHAN_ITEM" + "soundlevel" "SNDLVL_NORM" + "volume" "1.0" + "pitch" "PITCH_NORM" + "wave" ")weapons/zr68/zr68_reload_bolt.wav" +} + //------------------- "weapon_zr68.npc_reload" diff --git a/game/neo/scripts/weapon_zr68c.txt b/game/neo/scripts/weapon_zr68c.txt index 38f426b6d0..a5fef48d68 100644 --- a/game/neo/scripts/weapon_zr68c.txt +++ b/game/neo/scripts/weapon_zr68c.txt @@ -16,6 +16,21 @@ WeaponData "Penetration" "28.0" "CycleTime" "0.090909" // time between shots "ReloadReadyBeforeEnd" "0.483" // the reload is done at the last reload click, this long before its animation ends + + // Reload phases (sv_neo_reload_experimental): per viewmodel sequence, when each phase counts ("credit") + // and when each sound piece's first transient plays ("at"), in seconds from the sequence start + "ReloadPhases" + { + "reload" + { + "drop" { "credit" "0.700" } + } + "draw_resume_drop_dry" + { + "seat" { "credit" "1.433" "sound" "weapon_zr68.reload_seat" "at" "1.394" "sound2" "weapon_zr68.reload_slap" "at2" "1.829" } + "bolt" { "credit" "2.367" "sound" "weapon_zr68.reload_bolt" "at" "2.129" } + } + } "TPMuzzleFlashScale" "0.5" From 3d979390976db44dac333b24e4fc76279adeadcd Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sat, 7 Nov 2026 18:52:06 -0700 Subject: [PATCH 04/55] Keep the clip until a switch interrupts the reload The drop credit no longer empties the clip: an uninterrupted reload shows the clip as master's does, which bots read to tell an empty weapon. The old magazine is lost only when the draw resumes the reload. The seat sets the ready time, so FinishReload loads as on master and the end-of-reload hook goes away. A switch or a drop now stops the sound pieces, as the player stops the single reload sound. A dropped weapon, also on death, cancels its reload, so the next owner does not resume it. The resume no longer sends drawempty in the same deploy. --- src/game/server/neo/neo_player.cpp | 2 + .../weapons/weapon_neobasecombatweapon.cpp | 100 +++++++++++------- .../neo/weapons/weapon_neobasecombatweapon.h | 7 +- 3 files changed, 69 insertions(+), 40 deletions(-) diff --git a/src/game/server/neo/neo_player.cpp b/src/game/server/neo/neo_player.cpp index e09dfbe8b9..0a66c4922f 100644 --- a/src/game/server/neo/neo_player.cpp +++ b/src/game/server/neo/neo_player.cpp @@ -2485,6 +2485,7 @@ void CNEO_Player::Weapon_DropOnDeath(CNEOBaseCombatWeapon* pNeoWeapon, Vector da pNeoWeapon->AddEffects(EF_BONEMERGE); } + pNeoWeapon->StopReloadOnDrop(); Vector playerVelocity = vec3_origin; GetVelocity(&playerVelocity, nullptr); pNeoWeapon->Drop(playerVelocity); @@ -2953,6 +2954,7 @@ void CNEO_Player::Weapon_Drop( CBaseCombatWeapon *pWeapon, return; // Return early to not drop weapon } + neoWeapon->StopReloadOnDrop(); pWeapon->m_bInReload = false; pWeapon->StopWeaponSound(RELOAD_NPC); diff --git a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp index bf36975d3d..62e60edc25 100644 --- a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp +++ b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp @@ -473,6 +473,7 @@ bool CNEOBaseCombatWeapon::Reload( void ) if (IsReloadPhaseSystemEnabled()) { + m_nReloadPhase = RELOAD_PHASE_NONE; StartReloadPhases(GetNEOWpnData().FindReloadTable(VM_SEQ_RELOAD)); } @@ -536,12 +537,6 @@ void CNEOBaseCombatWeapon::StartReloadPhases(int iTable) m_nReloadSoundsDone = 0; } -void CNEOBaseCombatWeapon::EndReloadPhases() -{ - m_nReloadTable = -1; - m_nReloadPhase = RELOAD_PHASE_NONE; -} - // Credit every phase of the playing reload sequence whose time has come, and play its sound pieces void CNEOBaseCombatWeapon::RunReloadPhases() { @@ -587,25 +582,20 @@ void CNEOBaseCombatWeapon::RunReloadPhases() void CNEOBaseCombatWeapon::CreditReloadPhase(ReloadPhase_t phase) { - switch (phase) + // The drop takes no rounds: they are lost only if a switch interrupts the reload after it (ResumeReload), + // so an uninterrupted reload shows the clip as master's does + if (phase == RELOAD_PHASE_SEATED) { - case RELOAD_PHASE_DROPPED: - // the old magazine and its rounds are gone, as when the reload loads at its ready time - m_iClip1 = 0; - break; - case RELOAD_PHASE_SEATED: - m_iClip1 = Min(GetMaxClip1(), m_iPrimaryAmmoCount.Get()); - m_iPrimaryAmmoCount -= m_iClip1; - break; - default: - break; + // the magazine loads now, as at a reload's ready time (ItemBusyFrame) + m_flReloadReadyTime = gpGlobals->curtime; } m_nReloadPhase = phase; } -// Resume, in the draw, a reload interrupted by a switch; a model without the resume sequence reloads afresh -void CNEOBaseCombatWeapon::ResumeReload() +// Resume, in the draw, a reload interrupted by a switch. A model without the resume sequence keeps the old magazine, +// as when master cancels a reload; returns whether the reload resumed +bool CNEOBaseCombatWeapon::ResumeReload() { const char *pszName = ResumeSequenceName(m_nReloadPhase); const int iTable = pszName ? GetNEOWpnData().FindReloadTable(pszName) : -1; @@ -613,9 +603,12 @@ void CNEOBaseCombatWeapon::ResumeReload() if (iSequence < 0) { m_nReloadPhase = RELOAD_PHASE_NONE; - return; + return false; } + // the old magazine and its rounds are gone, as when a reload loads at its ready time + m_iClip1 = 0; + SetSequence(iSequence); SendViewModelAnim(iSequence); @@ -631,10 +624,12 @@ void CNEOBaseCombatWeapon::ResumeReload() m_flReloadReadyTime = 0.0f; StartReloadPhases(iTable); m_bInReload = true; + return true; } -// Reload sequences are looked up on the owner's viewmodel: on the client the weapon entity carries the world model, -// so a lookup there would fail and the client would predict a different sequence than the server plays +// Reload sequences are looked up on the owner's viewmodel, the entity that plays them. The weapon entity's model is not +// always that viewmodel on the client: CalcOverrideModelIndex gives it the world model whenever the local player does +// not draw its viewmodel CBaseViewModel *CNEOBaseCombatWeapon::ReloadViewModel() const { CBasePlayer *pOwner = ToBasePlayer(GetOwner()); @@ -647,6 +642,46 @@ int CNEOBaseCombatWeapon::LookupReloadSequence(const char *pszName) const return pVM ? pVM->LookupSequence(pszName) : -1; } +// Sound pieces play on their own channel entries, so a switch or a drop stops them by name, +// as the player stops the single reload sound +void CNEOBaseCombatWeapon::StopReloadSoundPieces() +{ + CBaseCombatCharacter *pOwner = GetOwner(); + if (!pOwner) + { + return; + } + + const CNEOWeaponInfo &info = GetNEOWpnData(); + for (int t = 0; t < info.m_iNumReloadTables; ++t) + { + for (int i = 0; i < info.m_reloadTables[t].iNumRows; ++i) + { + for (int j = 0; j < RELOAD_SOUNDS_PER_ROW; ++j) + { + const char *pszName = info.m_reloadTables[t].rows[i].sounds[j].szName; + if (pszName[0]) + { + StopSound(pOwner->entindex(), pszName); + } + } + } + } +} + +// A dropped weapon cancels its reload as on master: the next owner does not resume it +void CNEOBaseCombatWeapon::StopReloadOnDrop() +{ + if (!IsReloadPhaseSystemEnabled()) + { + return; + } + + StopReloadSoundPieces(); + m_nReloadPhase = RELOAD_PHASE_NONE; + m_nReloadTable = -1; +} + // Play a reload sound piece from the owner, as WeaponSound does: predicted for the owner, from the server for the rest void CNEOBaseCombatWeapon::EmitReloadSoundPiece(const char *pszSound) { @@ -682,10 +717,10 @@ void CNEOBaseCombatWeapon::FinishReload(void) } m_flReloadReadyTime = 0.0f; - // the magazine is in: nothing is left to credit or resume + // the magazine is in: the phases up to the seat are done, and a switch from here leaves nothing to resume if (IsReloadPhaseSystemEnabled()) { - EndReloadPhases(); + m_nReloadPhase = Max(m_nReloadPhase.Get(), static_cast(RELOAD_PHASE_SEATED)); } CBaseCombatCharacter* pOwner = GetOwner(); @@ -737,19 +772,15 @@ bool CNEOBaseCombatWeapon::Deploy(void) // An empty weapon draws with its slide held back where the model has that draw, // which carries no activity, so it is picked by name static constexpr const char *VM_SEQ_DRAW_EMPTY = "drawempty"; - const int iDrawEmpty = (UsesClipsForAmmo1() && m_iClip1 <= 0) ? LookupSequence(VM_SEQ_DRAW_EMPTY) : ACTIVITY_NOT_AVAILABLE; + // a reload interrupted by a switch goes on in the draw + const bool bResumed = IsReloadPhaseSystemEnabled() && m_nReloadPhase != RELOAD_PHASE_NONE && ResumeReload(); + const int iDrawEmpty = (!bResumed && UsesClipsForAmmo1() && m_iClip1 <= 0) ? LookupSequence(VM_SEQ_DRAW_EMPTY) : ACTIVITY_NOT_AVAILABLE; if (iDrawEmpty != ACTIVITY_NOT_AVAILABLE) { SetSequence(iDrawEmpty); SendViewModelAnim(iDrawEmpty); } - // A reload interrupted by a switch goes on in the draw - if (IsReloadPhaseSystemEnabled() && m_nReloadPhase != RELOAD_PHASE_NONE) - { - ResumeReload(); - } - #ifdef DEBUG CNEO_Player* pOwner = NULL; if (GetOwner()) @@ -818,6 +849,7 @@ bool CNEOBaseCombatWeapon::Holster(CBaseCombatWeapon* pSwitchingTo) m_nReloadPhase = RELOAD_PHASE_NONE; } m_nReloadTable = -1; + StopReloadSoundPieces(); } return BaseClass::Holster(pSwitchingTo); @@ -831,12 +863,6 @@ void CNEOBaseCombatWeapon::CheckReload(void) } BaseClass::CheckReload(); - - // a reload that ran to its end leaves nothing to resume - if (IsReloadPhaseSystemEnabled() && !m_bInReload && m_nReloadTable >= 0) - { - EndReloadPhases(); - } } float CNEOBaseCombatWeapon::GetAccuracyPenaltyDecay() diff --git a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h index 433b63150e..8ac42df588 100644 --- a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h +++ b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h @@ -264,6 +264,7 @@ class CNEOBaseCombatWeapon : public CBaseHL2MPCombatWeapon virtual float GetFireRate() override final; float GetPenetration() const; + void StopReloadOnDrop(); #ifdef CLIENT_DLL float m_flTemperature; int m_spawnflags; @@ -300,7 +301,7 @@ class CNEOBaseCombatWeapon : public CBaseHL2MPCombatWeapon // Reload phases (weapons whose script has a ReloadPhases block): the last phase credited, kept across a switch CNetworkVar(int, m_nReloadPhase); - // the phase table of the sequence playing, -1 none + // the phase table of the reload sequence started last, -1 none CNetworkVar(int, m_nReloadTable); // when the reload sequence started; phase credits are offsets from it CNetworkVar(float, m_flReloadStart); @@ -312,10 +313,10 @@ class CNEOBaseCombatWeapon : public CBaseHL2MPCombatWeapon bool HasEmptyIdle(); void StartReloadPhases(int iTable); - void EndReloadPhases(); void RunReloadPhases(); void CreditReloadPhase(ReloadPhase_t phase); - void ResumeReload(); + bool ResumeReload(); + void StopReloadSoundPieces(); void EmitReloadSoundPiece(const char *pszSound); CBaseViewModel *ReloadViewModel() const; int LookupReloadSequence(const char *pszName) const; From 6857c4932e08f2c7f3ed1287a596151d74f71037 Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sat, 7 Nov 2026 18:52:48 -0700 Subject: [PATCH 05/55] Tidy the reload-phase code for review Describe what sv_neo_reload_experimental does in its help text and bound it to 0-1 like the other weapon cvars. Hoist the parser's name tables to file scope, group FindReloadTable with the other methods, and word the comments without reference to the base branch. No behavior change. --- src/game/server/neo/neo_player.cpp | 1 + .../shared/neo/weapons/neo_weapon_parse.cpp | 17 ++++++++++------- src/game/shared/neo/weapons/neo_weapon_parse.h | 4 ++-- .../neo/weapons/weapon_neobasecombatweapon.cpp | 9 +++++---- 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/game/server/neo/neo_player.cpp b/src/game/server/neo/neo_player.cpp index 0a66c4922f..6e038c727f 100644 --- a/src/game/server/neo/neo_player.cpp +++ b/src/game/server/neo/neo_player.cpp @@ -2486,6 +2486,7 @@ void CNEO_Player::Weapon_DropOnDeath(CNEOBaseCombatWeapon* pNeoWeapon, Vector da } pNeoWeapon->StopReloadOnDrop(); + Vector playerVelocity = vec3_origin; GetVelocity(&playerVelocity, nullptr); pNeoWeapon->Drop(playerVelocity); diff --git a/src/game/shared/neo/weapons/neo_weapon_parse.cpp b/src/game/shared/neo/weapons/neo_weapon_parse.cpp index 71c9469276..787c490a24 100644 --- a/src/game/shared/neo/weapons/neo_weapon_parse.cpp +++ b/src/game/shared/neo/weapons/neo_weapon_parse.cpp @@ -32,12 +32,18 @@ CNEOWeaponInfo::CNEOWeaponInfo() } +// Weapon-script names of the reload phases, by ReloadPhase_t +static constexpr const char *RELOAD_PHASE_NAMES[RELOAD_PHASE_COUNT] = { "", "drop", "seat", "bolt" }; +// Weapon-script keys of a phase's sound pieces: { sound name, time } +static constexpr const char *RELOAD_SOUND_KEYS[RELOAD_SOUNDS_PER_ROW][2] = { + { "sound", "at" }, { "sound2", "at2" }, { "sound3", "at3" } +}; + static ReloadPhase_t ReloadPhaseFromName(const char *pszName) { - static constexpr const char *PHASE_NAMES[RELOAD_PHASE_COUNT] = { "", "drop", "seat", "bolt" }; for (int i = RELOAD_PHASE_DROPPED; i < RELOAD_PHASE_COUNT; ++i) { - if (V_stricmp(pszName, PHASE_NAMES[i]) == 0) + if (V_stricmp(pszName, RELOAD_PHASE_NAMES[i]) == 0) { return static_cast(i); } @@ -72,13 +78,10 @@ void CNEOWeaponInfo::ParseReloadPhases(KeyValues *pBlock) ReloadPhaseRow_t &row = table.rows[table.iNumRows++]; row.phase = phase; row.flCredit = pRow->GetFloat("credit"); - static constexpr const char *SOUND_KEYS[RELOAD_SOUNDS_PER_ROW][2] = { - { "sound", "at" }, { "sound2", "at2" }, { "sound3", "at3" } - }; for (int j = 0; j < RELOAD_SOUNDS_PER_ROW; ++j) { - row.sounds[j].flAt = pRow->GetFloat(SOUND_KEYS[j][1]); - V_strncpy(row.sounds[j].szName, pRow->GetString(SOUND_KEYS[j][0]), sizeof(row.sounds[j].szName)); + row.sounds[j].flAt = pRow->GetFloat(RELOAD_SOUND_KEYS[j][1]); + V_strncpy(row.sounds[j].szName, pRow->GetString(RELOAD_SOUND_KEYS[j][0]), sizeof(row.sounds[j].szName)); } } } diff --git a/src/game/shared/neo/weapons/neo_weapon_parse.h b/src/game/shared/neo/weapons/neo_weapon_parse.h index 87a12bf85a..7bf2def14f 100644 --- a/src/game/shared/neo/weapons/neo_weapon_parse.h +++ b/src/game/shared/neo/weapons/neo_weapon_parse.h @@ -74,8 +74,6 @@ class CNEOWeaponInfo : public CHL2MPSWeaponInfo float m_flReloadReadyBeforeEnd; int m_iNumReloadTables; // 0: the weapon reloads without phases ReloadPhaseTable_t m_reloadTables[RELOAD_PHASE_TABLES_MAX]; - - int FindReloadTable(const char *pszSequence) const; char szViewModel2[MAX_WEAPON_STRING]; // Team 2 (NSF) wep vm char szBulletCharacter[MAX_BULLET_CHARACTER];// character used to display ammunition in current clip char szDeathIcon[MAX_BULLET_CHARACTER]; @@ -91,6 +89,8 @@ class CNEOWeaponInfo : public CHL2MPSWeaponInfo Vector m_vecVMAimPosOffset; QAngle m_angVMAimAngOffset; + int FindReloadTable(const char *pszSequence) const; + private: void ParseReloadPhases(::KeyValues *pBlock); }; diff --git a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp index 62e60edc25..d667b5e76b 100644 --- a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp +++ b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp @@ -102,7 +102,8 @@ END_DATADESC() ConVar sv_neo_accuracy_penalty_scale("sv_neo_accuracy_penalty_scale", "1.0", FCVAR_REPLICATED, "Scales the accuracy penalty per shot.", true, 0.0f, true, 2.0f); ConVar sv_neo_dynamic_viewkick("sv_neo_dynamic_viewkick", "0", FCVAR_REPLICATED, "Enables view kick scaling based on current inaccuracy.", true, 0.0f, true, 1.0f); ConVar sv_neo_reload_experimental("sv_neo_reload_experimental", "0", FCVAR_REPLICATED, - "Server reload-phase setting; set before a game starts; mid-game changes are unsupported."); + "Lets a switch interrupt a reload after the magazine is out, for weapons that define reload phases. Set before the map loads.", + true, 0.0f, true, 1.0f); const char *GetWeaponByLoadoutId(int id) { @@ -583,7 +584,7 @@ void CNEOBaseCombatWeapon::RunReloadPhases() void CNEOBaseCombatWeapon::CreditReloadPhase(ReloadPhase_t phase) { // The drop takes no rounds: they are lost only if a switch interrupts the reload after it (ResumeReload), - // so an uninterrupted reload shows the clip as master's does + // so an uninterrupted reload shows the same clip as without phases if (phase == RELOAD_PHASE_SEATED) { // the magazine loads now, as at a reload's ready time (ItemBusyFrame) @@ -594,7 +595,7 @@ void CNEOBaseCombatWeapon::CreditReloadPhase(ReloadPhase_t phase) } // Resume, in the draw, a reload interrupted by a switch. A model without the resume sequence keeps the old magazine, -// as when master cancels a reload; returns whether the reload resumed +// as a cancelled reload does; returns whether the reload resumed bool CNEOBaseCombatWeapon::ResumeReload() { const char *pszName = ResumeSequenceName(m_nReloadPhase); @@ -669,7 +670,7 @@ void CNEOBaseCombatWeapon::StopReloadSoundPieces() } } -// A dropped weapon cancels its reload as on master: the next owner does not resume it +// A dropped weapon cancels its reload: the next owner does not resume it void CNEOBaseCombatWeapon::StopReloadOnDrop() { if (!IsReloadPhaseSystemEnabled()) From 07bfdb6081cca2ab4c99a4b0f9f0d781bbc69241 Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sat, 7 Nov 2026 18:53:36 -0700 Subject: [PATCH 06/55] Take the ZR68C reload phases from neoAssets weapon_zr68c.txt includes its ReloadPhases rows with #base from weapon_zr68c_reload_phases.txt, which neoAssets ships and times from the Blender markers, so the sound and credit times follow the animation. A missing file leaves the block empty; the parser then warns and the weapon reloads without phases, as it does without the flag. The configure copy of neoAssets is ignored by git. --- .gitignore | 3 +++ game/neo/scripts/weapon_zr68c.txt | 18 ++++-------------- .../shared/neo/weapons/neo_weapon_parse.cpp | 6 ++++++ 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index 3d541782cc..590e093b19 100644 --- a/.gitignore +++ b/.gitignore @@ -49,6 +49,9 @@ out # Match session restore file /game/neo/scripts/match_session_restore_point.txt +# Reload phases copied from neoAssets +/game/neo/scripts/weapon_*_reload_phases.txt + # Shader state debug image dumps /game/neo/*.tga diff --git a/game/neo/scripts/weapon_zr68c.txt b/game/neo/scripts/weapon_zr68c.txt index a5fef48d68..d7f86f9791 100644 --- a/game/neo/scripts/weapon_zr68c.txt +++ b/game/neo/scripts/weapon_zr68c.txt @@ -1,3 +1,5 @@ +#base "weapon_zr68c_reload_phases.txt" + // ZR68S WeaponData @@ -17,20 +19,8 @@ WeaponData "CycleTime" "0.090909" // time between shots "ReloadReadyBeforeEnd" "0.483" // the reload is done at the last reload click, this long before its animation ends - // Reload phases (sv_neo_reload_experimental): per viewmodel sequence, when each phase counts ("credit") - // and when each sound piece's first transient plays ("at"), in seconds from the sequence start - "ReloadPhases" - { - "reload" - { - "drop" { "credit" "0.700" } - } - "draw_resume_drop_dry" - { - "seat" { "credit" "1.433" "sound" "weapon_zr68.reload_seat" "at" "1.394" "sound2" "weapon_zr68.reload_slap" "at2" "1.829" } - "bolt" { "credit" "2.367" "sound" "weapon_zr68.reload_bolt" "at" "2.129" } - } - } + // Reload phases (sv_neo_reload_experimental): the rows come from neoAssets, timed from its Blender markers + "ReloadPhases" {} "TPMuzzleFlashScale" "0.5" diff --git a/src/game/shared/neo/weapons/neo_weapon_parse.cpp b/src/game/shared/neo/weapons/neo_weapon_parse.cpp index 787c490a24..aa4a736c8e 100644 --- a/src/game/shared/neo/weapons/neo_weapon_parse.cpp +++ b/src/game/shared/neo/weapons/neo_weapon_parse.cpp @@ -60,6 +60,12 @@ void CNEOWeaponInfo::ParseReloadPhases(KeyValues *pBlock) return; } + if (!pBlock->GetFirstTrueSubKey()) + { + Warning("%s: \"ReloadPhases\" is empty (is its neoAssets #base file missing?); reloading without phases\n", szClassName); + return; + } + for (KeyValues *pSeq = pBlock->GetFirstTrueSubKey(); pSeq && m_iNumReloadTables < RELOAD_PHASE_TABLES_MAX; pSeq = pSeq->GetNextTrueSubKey()) { ReloadPhaseTable_t &table = m_reloadTables[m_iNumReloadTables++]; From 8f82986a0db79ecf27bfd9b786f36526cce26ed9 Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sat, 7 Nov 2026 19:05:30 -0700 Subject: [PATCH 07/55] Name the ZR68C reload steps by number Use the step names neoAssets now ships: phases 1_unload, 2_load and 3_cycle (RELOAD_PHASE_UNLOADED, LOADED, CYCLED), the resume sequence resume_after_1_unload_empty, the row keys ammo, sound and sound2 (sound names under sound_name, sound2_name), and sound entries named after their step. No behavior change. --- game/neo/scripts/game_sounds_weapons.txt | 15 +++++----- .../shared/neo/weapons/neo_weapon_parse.cpp | 10 +++---- .../shared/neo/weapons/neo_weapon_parse.h | 14 +++++----- .../weapons/weapon_neobasecombatweapon.cpp | 28 +++++++++---------- .../neo/weapons/weapon_neobasecombatweapon.h | 6 ++-- 5 files changed, 37 insertions(+), 36 deletions(-) diff --git a/game/neo/scripts/game_sounds_weapons.txt b/game/neo/scripts/game_sounds_weapons.txt index 24d8e65ced..4d0cfc3a15 100644 --- a/game/neo/scripts/game_sounds_weapons.txt +++ b/game/neo/scripts/game_sounds_weapons.txt @@ -759,33 +759,34 @@ "wave" "weapons/zr68/zr68_reload.wav" } -// ZR68 reload in per-phase pieces (sv_neo_reload_experimental): each file starts just before its first transient +// ZR68 reload in per-step pieces (sv_neo_reload_experimental), named after the step; _2 is a step's second sound. +// Each file starts just before its first transient -"weapon_zr68.reload_seat" +"weapon_zr68.reload_2_load" { "channel" "CHAN_ITEM" "soundlevel" "SNDLVL_NORM" "volume" "1.0" "pitch" "PITCH_NORM" - "wave" ")weapons/zr68/zr68_reload_seat.wav" + "wave" ")weapons/zr68/zr68_reload_2_load.wav" } -"weapon_zr68.reload_slap" +"weapon_zr68.reload_2_load_2" { "channel" "CHAN_ITEM" "soundlevel" "SNDLVL_NORM" "volume" "1.0" "pitch" "PITCH_NORM" - "wave" ")weapons/zr68/zr68_reload_slap.wav" + "wave" ")weapons/zr68/zr68_reload_2_load_2.wav" } -"weapon_zr68.reload_bolt" +"weapon_zr68.reload_3_cycle" { "channel" "CHAN_ITEM" "soundlevel" "SNDLVL_NORM" "volume" "1.0" "pitch" "PITCH_NORM" - "wave" ")weapons/zr68/zr68_reload_bolt.wav" + "wave" ")weapons/zr68/zr68_reload_3_cycle.wav" } //------------------- diff --git a/src/game/shared/neo/weapons/neo_weapon_parse.cpp b/src/game/shared/neo/weapons/neo_weapon_parse.cpp index aa4a736c8e..80223a535d 100644 --- a/src/game/shared/neo/weapons/neo_weapon_parse.cpp +++ b/src/game/shared/neo/weapons/neo_weapon_parse.cpp @@ -33,15 +33,15 @@ CNEOWeaponInfo::CNEOWeaponInfo() // Weapon-script names of the reload phases, by ReloadPhase_t -static constexpr const char *RELOAD_PHASE_NAMES[RELOAD_PHASE_COUNT] = { "", "drop", "seat", "bolt" }; +static constexpr const char *RELOAD_PHASE_NAMES[RELOAD_PHASE_COUNT] = { "", "1_unload", "2_load", "3_cycle" }; // Weapon-script keys of a phase's sound pieces: { sound name, time } static constexpr const char *RELOAD_SOUND_KEYS[RELOAD_SOUNDS_PER_ROW][2] = { - { "sound", "at" }, { "sound2", "at2" }, { "sound3", "at3" } + { "sound_name", "sound" }, { "sound2_name", "sound2" }, { "sound3_name", "sound3" } }; static ReloadPhase_t ReloadPhaseFromName(const char *pszName) { - for (int i = RELOAD_PHASE_DROPPED; i < RELOAD_PHASE_COUNT; ++i) + for (int i = RELOAD_PHASE_UNLOADED; i < RELOAD_PHASE_COUNT; ++i) { if (V_stricmp(pszName, RELOAD_PHASE_NAMES[i]) == 0) { @@ -51,7 +51,7 @@ static ReloadPhase_t ReloadPhaseFromName(const char *pszName) return RELOAD_PHASE_NONE; } -// "ReloadPhases" { "" { "" { "credit" "s" "sound" "name" "at" "s" } ... } ... } +// "ReloadPhases" { "" { "" { "ammo" "s" "sound" "s" "sound_name" "name" } ... } ... } void CNEOWeaponInfo::ParseReloadPhases(KeyValues *pBlock) { m_iNumReloadTables = 0; @@ -83,7 +83,7 @@ void CNEOWeaponInfo::ParseReloadPhases(KeyValues *pBlock) ReloadPhaseRow_t &row = table.rows[table.iNumRows++]; row.phase = phase; - row.flCredit = pRow->GetFloat("credit"); + row.flAmmo = pRow->GetFloat("ammo"); for (int j = 0; j < RELOAD_SOUNDS_PER_ROW; ++j) { row.sounds[j].flAt = pRow->GetFloat(RELOAD_SOUND_KEYS[j][1]); diff --git a/src/game/shared/neo/weapons/neo_weapon_parse.h b/src/game/shared/neo/weapons/neo_weapon_parse.h index 7bf2def14f..ea7fc66361 100644 --- a/src/game/shared/neo/weapons/neo_weapon_parse.h +++ b/src/game/shared/neo/weapons/neo_weapon_parse.h @@ -12,13 +12,13 @@ #include "hl2mp_weapon_parse.h" -// A reload is a linear sequence of phases; a reload sequence credits each phase at a point of its animation +// A reload is a linear sequence of phases; a reload sequence finishes each phase at a point of its animation enum ReloadPhase_t { RELOAD_PHASE_NONE = 0, // no reload in progress, or none pending - RELOAD_PHASE_DROPPED, // the old magazine is out - RELOAD_PHASE_SEATED, // the fresh magazine is in - RELOAD_PHASE_BOLTED, // the bolt or charging handle chambered a round + RELOAD_PHASE_UNLOADED, // 1_unload: the old magazine is out + RELOAD_PHASE_LOADED, // 2_load: the fresh magazine is in + RELOAD_PHASE_CYCLED, // 3_cycle: the bolt or charging handle chambered a round RELOAD_PHASE_COUNT }; @@ -33,7 +33,7 @@ static_assert((1 << (RELOAD_PHASE_TABLE_BITS - 1)) >= RELOAD_PHASE_TABLES_MAX, " static constexpr int RELOAD_PHASE_ROWS_MAX = RELOAD_PHASE_COUNT - 1; static constexpr int RELOAD_SOUND_NAME_MAX = 64; static constexpr int RELOAD_SEQUENCE_NAME_MAX = 32; -// a phase may need more than one sound piece, such as a magazine seat and its slap +// a phase may need more than one sound piece, such as loading a magazine and the tap after it static constexpr int RELOAD_SOUNDS_PER_ROW = 3; // A sound piece of a phase @@ -43,11 +43,11 @@ struct ReloadSoundPiece_t char szName[RELOAD_SOUND_NAME_MAX]; }; -// One phase of a reload sequence: when it is credited, and the sound pieces that go with it +// One phase of a reload sequence: when its ammo counts, and the sound pieces that go with it struct ReloadPhaseRow_t { ReloadPhase_t phase; - float flCredit; // seconds from the sequence start + float flAmmo; // seconds from the sequence start ReloadSoundPiece_t sounds[RELOAD_SOUNDS_PER_ROW]; }; diff --git a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp index d667b5e76b..566b7df4ad 100644 --- a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp +++ b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp @@ -511,15 +511,15 @@ bool CNEOBaseCombatWeapon::Reload( void ) // Each reload sound piece's file starts this long before its first transient static constexpr float RELOAD_SOUND_LEAD = 0.02f; -// The viewmodel sequence that resumes a reload interrupted after the phase credited last; nullptr: none +// The viewmodel sequence that resumes a reload interrupted after the phase finished last; nullptr: none // (resume sequences carry no activity, so they are picked by name) static const char *ResumeSequenceName(int iPhaseDone) { switch (iPhaseDone) { - case RELOAD_PHASE_DROPPED: + case RELOAD_PHASE_UNLOADED: // the magazine is out: the draw itself brings the fresh one up - return "draw_resume_drop_dry"; + return "resume_after_1_unload_empty"; default: return nullptr; } @@ -530,7 +530,7 @@ bool CNEOBaseCombatWeapon::IsReloadPhaseSystemEnabled() const return m_bReloadExperimentalEnabled && GetNEOWpnData().m_iNumReloadTables > 0; } -// Credit the phases of a reload sequence that starts now (-1: a sequence without a table credits nothing) +// Time the phases of a reload sequence that starts now (-1: a sequence without a table finishes none) void CNEOBaseCombatWeapon::StartReloadPhases(int iTable) { m_nReloadTable = iTable; @@ -538,7 +538,7 @@ void CNEOBaseCombatWeapon::StartReloadPhases(int iTable) m_nReloadSoundsDone = 0; } -// Credit every phase of the playing reload sequence whose time has come, and play its sound pieces +// Finish every phase of the playing reload sequence whose time has come, and play its sound pieces void CNEOBaseCombatWeapon::RunReloadPhases() { if (!m_bInReload || m_nReloadTable < 0) @@ -549,7 +549,7 @@ void CNEOBaseCombatWeapon::RunReloadPhases() const ReloadPhaseTable_t &table = GetNEOWpnData().m_reloadTables[m_nReloadTable]; const float flElapsed = gpGlobals->curtime - m_flReloadStart; - // Sound pieces play on their own times, before or after their phase's credit + // Sound pieces play on their own times, before or after their phase's ammo time for (int i = 0; i < table.iNumRows; ++i) { for (int j = 0; j < RELOAD_SOUNDS_PER_ROW; ++j) @@ -572,20 +572,20 @@ void CNEOBaseCombatWeapon::RunReloadPhases() continue; } - if (flElapsed < row.flCredit) + if (flElapsed < row.flAmmo) { break; } - CreditReloadPhase(row.phase); + FinishReloadPhase(row.phase); } } -void CNEOBaseCombatWeapon::CreditReloadPhase(ReloadPhase_t phase) +void CNEOBaseCombatWeapon::FinishReloadPhase(ReloadPhase_t phase) { - // The drop takes no rounds: they are lost only if a switch interrupts the reload after it (ResumeReload), + // The unload takes no rounds: they are lost only if a switch interrupts the reload after it (ResumeReload), // so an uninterrupted reload shows the same clip as without phases - if (phase == RELOAD_PHASE_SEATED) + if (phase == RELOAD_PHASE_LOADED) { // the magazine loads now, as at a reload's ready time (ItemBusyFrame) m_flReloadReadyTime = gpGlobals->curtime; @@ -621,7 +621,7 @@ bool CNEOBaseCombatWeapon::ResumeReload() m_flNextPrimaryAttack = m_flNextSecondaryAttack = flEnd; SetWeaponIdleTime(flEnd); - // the seat credit loads the magazine + // the load phase loads the magazine m_flReloadReadyTime = 0.0f; StartReloadPhases(iTable); m_bInReload = true; @@ -718,10 +718,10 @@ void CNEOBaseCombatWeapon::FinishReload(void) } m_flReloadReadyTime = 0.0f; - // the magazine is in: the phases up to the seat are done, and a switch from here leaves nothing to resume + // the magazine is in: the phases up to the load are done, and a switch from here leaves nothing to resume if (IsReloadPhaseSystemEnabled()) { - m_nReloadPhase = Max(m_nReloadPhase.Get(), static_cast(RELOAD_PHASE_SEATED)); + m_nReloadPhase = Max(m_nReloadPhase.Get(), static_cast(RELOAD_PHASE_LOADED)); } CBaseCombatCharacter* pOwner = GetOwner(); diff --git a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h index 8ac42df588..90d2164b16 100644 --- a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h +++ b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h @@ -299,11 +299,11 @@ class CNEOBaseCombatWeapon : public CBaseHL2MPCombatWeapon // The server's pre-game reload setting, snapshotted for prediction CNetworkVar(bool, m_bReloadExperimentalEnabled); - // Reload phases (weapons whose script has a ReloadPhases block): the last phase credited, kept across a switch + // Reload phases (weapons whose script has a ReloadPhases block): the last phase finished, kept across a switch CNetworkVar(int, m_nReloadPhase); // the phase table of the reload sequence started last, -1 none CNetworkVar(int, m_nReloadTable); - // when the reload sequence started; phase credits are offsets from it + // when the reload sequence started; phase times are offsets from it CNetworkVar(float, m_flReloadStart); // the sound pieces of the playing sequence already started, one bit per piece CNetworkVar(int, m_nReloadSoundsDone); @@ -314,7 +314,7 @@ class CNEOBaseCombatWeapon : public CBaseHL2MPCombatWeapon void StartReloadPhases(int iTable); void RunReloadPhases(); - void CreditReloadPhase(ReloadPhase_t phase); + void FinishReloadPhase(ReloadPhase_t phase); bool ResumeReload(); void StopReloadSoundPieces(); void EmitReloadSoundPiece(const char *pszSound); From 1e047b057fc263097eb3c12248473c3c4f28fc90 Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sat, 7 Nov 2026 20:03:41 -0700 Subject: [PATCH 08/55] Allow fire at a resume's ready time A resume sequence's ReloadPhases block may give a 4_ready time: the reload is done and fire is allowed there, and the clip plays on to its end unless a shot interrupts it. Without the key, fire waits for the end of the sequence as before. --- src/game/shared/neo/weapons/neo_weapon_parse.cpp | 3 ++- src/game/shared/neo/weapons/neo_weapon_parse.h | 1 + src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp | 7 +++++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/game/shared/neo/weapons/neo_weapon_parse.cpp b/src/game/shared/neo/weapons/neo_weapon_parse.cpp index 80223a535d..8487003102 100644 --- a/src/game/shared/neo/weapons/neo_weapon_parse.cpp +++ b/src/game/shared/neo/weapons/neo_weapon_parse.cpp @@ -51,7 +51,7 @@ static ReloadPhase_t ReloadPhaseFromName(const char *pszName) return RELOAD_PHASE_NONE; } -// "ReloadPhases" { "" { "" { "ammo" "s" "sound" "s" "sound_name" "name" } ... } ... } +// "ReloadPhases" { "" { "4_ready" "s" "" { "ammo" "s" "sound" "s" "sound_name" "name" } ... } ... } void CNEOWeaponInfo::ParseReloadPhases(KeyValues *pBlock) { m_iNumReloadTables = 0; @@ -70,6 +70,7 @@ void CNEOWeaponInfo::ParseReloadPhases(KeyValues *pBlock) { ReloadPhaseTable_t &table = m_reloadTables[m_iNumReloadTables++]; V_strncpy(table.szSequence, pSeq->GetName(), sizeof(table.szSequence)); + table.flReady = pSeq->GetFloat("4_ready"); table.iNumRows = 0; for (KeyValues *pRow = pSeq->GetFirstTrueSubKey(); pRow && table.iNumRows < RELOAD_PHASE_ROWS_MAX; pRow = pRow->GetNextTrueSubKey()) diff --git a/src/game/shared/neo/weapons/neo_weapon_parse.h b/src/game/shared/neo/weapons/neo_weapon_parse.h index ea7fc66361..0a7384faef 100644 --- a/src/game/shared/neo/weapons/neo_weapon_parse.h +++ b/src/game/shared/neo/weapons/neo_weapon_parse.h @@ -55,6 +55,7 @@ struct ReloadPhaseRow_t struct ReloadPhaseTable_t { char szSequence[RELOAD_SEQUENCE_NAME_MAX]; + float flReady; // when the reload is done and fire is allowed, seconds from the sequence start; 0: at its end int iNumRows; ReloadPhaseRow_t rows[RELOAD_PHASE_ROWS_MAX]; }; diff --git a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp index 566b7df4ad..0e6facbda6 100644 --- a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp +++ b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp @@ -616,9 +616,12 @@ bool CNEOBaseCombatWeapon::ResumeReload() // the draw is part of the motion: the full reload gesture fits the resume ToHL2MPPlayer(GetOwner())->DoAnimationEvent(PLAYERANIMEVENT_RELOAD); + // The reload is done and fire is allowed at the ready time; the clip plays on unless a shot interrupts it const float flEnd = gpGlobals->curtime + ReloadViewModel()->SequenceDuration(iSequence); - GetOwner()->SetNextAttack(flEnd); - m_flNextPrimaryAttack = m_flNextSecondaryAttack = flEnd; + const float flReady = GetNEOWpnData().m_reloadTables[iTable].flReady; + const float flFire = (flReady > 0.0f) ? Min(flEnd, gpGlobals->curtime + flReady) : flEnd; + GetOwner()->SetNextAttack(flFire); + m_flNextPrimaryAttack = m_flNextSecondaryAttack = flFire; SetWeaponIdleTime(flEnd); // the load phase loads the magazine From f39b3c4f66345e24b06f5cd7ba22766efaf9aa3b Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sat, 7 Nov 2026 20:31:05 -0700 Subject: [PATCH 09/55] Finish a resume at its clip end Drop the 4_ready time: the resume clip now ends where the hands are at rest, so the reload finishes and fire is allowed when it ends. --- src/game/shared/neo/weapons/neo_weapon_parse.cpp | 3 +-- src/game/shared/neo/weapons/neo_weapon_parse.h | 1 - src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp | 7 ++----- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/game/shared/neo/weapons/neo_weapon_parse.cpp b/src/game/shared/neo/weapons/neo_weapon_parse.cpp index 8487003102..80223a535d 100644 --- a/src/game/shared/neo/weapons/neo_weapon_parse.cpp +++ b/src/game/shared/neo/weapons/neo_weapon_parse.cpp @@ -51,7 +51,7 @@ static ReloadPhase_t ReloadPhaseFromName(const char *pszName) return RELOAD_PHASE_NONE; } -// "ReloadPhases" { "" { "4_ready" "s" "" { "ammo" "s" "sound" "s" "sound_name" "name" } ... } ... } +// "ReloadPhases" { "" { "" { "ammo" "s" "sound" "s" "sound_name" "name" } ... } ... } void CNEOWeaponInfo::ParseReloadPhases(KeyValues *pBlock) { m_iNumReloadTables = 0; @@ -70,7 +70,6 @@ void CNEOWeaponInfo::ParseReloadPhases(KeyValues *pBlock) { ReloadPhaseTable_t &table = m_reloadTables[m_iNumReloadTables++]; V_strncpy(table.szSequence, pSeq->GetName(), sizeof(table.szSequence)); - table.flReady = pSeq->GetFloat("4_ready"); table.iNumRows = 0; for (KeyValues *pRow = pSeq->GetFirstTrueSubKey(); pRow && table.iNumRows < RELOAD_PHASE_ROWS_MAX; pRow = pRow->GetNextTrueSubKey()) diff --git a/src/game/shared/neo/weapons/neo_weapon_parse.h b/src/game/shared/neo/weapons/neo_weapon_parse.h index 0a7384faef..ea7fc66361 100644 --- a/src/game/shared/neo/weapons/neo_weapon_parse.h +++ b/src/game/shared/neo/weapons/neo_weapon_parse.h @@ -55,7 +55,6 @@ struct ReloadPhaseRow_t struct ReloadPhaseTable_t { char szSequence[RELOAD_SEQUENCE_NAME_MAX]; - float flReady; // when the reload is done and fire is allowed, seconds from the sequence start; 0: at its end int iNumRows; ReloadPhaseRow_t rows[RELOAD_PHASE_ROWS_MAX]; }; diff --git a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp index 0e6facbda6..566b7df4ad 100644 --- a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp +++ b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp @@ -616,12 +616,9 @@ bool CNEOBaseCombatWeapon::ResumeReload() // the draw is part of the motion: the full reload gesture fits the resume ToHL2MPPlayer(GetOwner())->DoAnimationEvent(PLAYERANIMEVENT_RELOAD); - // The reload is done and fire is allowed at the ready time; the clip plays on unless a shot interrupts it const float flEnd = gpGlobals->curtime + ReloadViewModel()->SequenceDuration(iSequence); - const float flReady = GetNEOWpnData().m_reloadTables[iTable].flReady; - const float flFire = (flReady > 0.0f) ? Min(flEnd, gpGlobals->curtime + flReady) : flEnd; - GetOwner()->SetNextAttack(flFire); - m_flNextPrimaryAttack = m_flNextSecondaryAttack = flFire; + GetOwner()->SetNextAttack(flEnd); + m_flNextPrimaryAttack = m_flNextSecondaryAttack = flEnd; SetWeaponIdleTime(flEnd); // the load phase loads the magazine From 0f56ad40e049e49919edd3ab63f440d11eeffab9 Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sat, 7 Nov 2026 21:05:39 -0700 Subject: [PATCH 10/55] Take the resume sequence from the phases file Reload() now times the phases of the sequence the viewmodel plays, not a fixed "reload", so a gun whose empty reload is reloadempty gets that table. A row's "resume" key names the sequence that resumes a reload interrupted after its step; Holster keeps the phase and the table that names it, and a second switch before a resume's first step plays that resume again. This replaces the hardcoded resume name. Sound pieces stop from the playing table only. --- .../shared/neo/weapons/neo_weapon_parse.cpp | 3 +- .../shared/neo/weapons/neo_weapon_parse.h | 1 + .../weapons/weapon_neobasecombatweapon.cpp | 74 +++++++++++-------- .../neo/weapons/weapon_neobasecombatweapon.h | 1 + 4 files changed, 46 insertions(+), 33 deletions(-) diff --git a/src/game/shared/neo/weapons/neo_weapon_parse.cpp b/src/game/shared/neo/weapons/neo_weapon_parse.cpp index 80223a535d..77872fa0eb 100644 --- a/src/game/shared/neo/weapons/neo_weapon_parse.cpp +++ b/src/game/shared/neo/weapons/neo_weapon_parse.cpp @@ -51,7 +51,7 @@ static ReloadPhase_t ReloadPhaseFromName(const char *pszName) return RELOAD_PHASE_NONE; } -// "ReloadPhases" { "" { "" { "ammo" "s" "sound" "s" "sound_name" "name" } ... } ... } +// "ReloadPhases" { "" { "" { "ammo" "s" "sound" "s" "sound_name" "name" "resume" "sequence" } ... } ... } void CNEOWeaponInfo::ParseReloadPhases(KeyValues *pBlock) { m_iNumReloadTables = 0; @@ -89,6 +89,7 @@ void CNEOWeaponInfo::ParseReloadPhases(KeyValues *pBlock) row.sounds[j].flAt = pRow->GetFloat(RELOAD_SOUND_KEYS[j][1]); V_strncpy(row.sounds[j].szName, pRow->GetString(RELOAD_SOUND_KEYS[j][0]), sizeof(row.sounds[j].szName)); } + V_strncpy(row.szResume, pRow->GetString("resume"), sizeof(row.szResume)); } } } diff --git a/src/game/shared/neo/weapons/neo_weapon_parse.h b/src/game/shared/neo/weapons/neo_weapon_parse.h index ea7fc66361..dc10c7d7ca 100644 --- a/src/game/shared/neo/weapons/neo_weapon_parse.h +++ b/src/game/shared/neo/weapons/neo_weapon_parse.h @@ -49,6 +49,7 @@ struct ReloadPhaseRow_t ReloadPhase_t phase; float flAmmo; // seconds from the sequence start ReloadSoundPiece_t sounds[RELOAD_SOUNDS_PER_ROW]; + char szResume[RELOAD_SEQUENCE_NAME_MAX]; // the sequence that resumes a reload interrupted after this phase, or empty }; // The phases one reload sequence carries, in order diff --git a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp index 566b7df4ad..a314fde42f 100644 --- a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp +++ b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp @@ -446,9 +446,6 @@ void CNEOBaseCombatWeapon::Equip(CBaseCombatCharacter* pOwner) } -// The shipped reload sequence -static constexpr const char *VM_SEQ_RELOAD = "reload"; - bool CNEOBaseCombatWeapon::Reload( void ) { const bool bEmptyReload = UsesClipsForAmmo1() && m_iClip1 <= 0 && @@ -474,8 +471,10 @@ bool CNEOBaseCombatWeapon::Reload( void ) if (IsReloadPhaseSystemEnabled()) { + // the phases are those of the sequence the reload plays, such as reload or reloadempty + CBaseViewModel *pVM = ReloadViewModel(); m_nReloadPhase = RELOAD_PHASE_NONE; - StartReloadPhases(GetNEOWpnData().FindReloadTable(VM_SEQ_RELOAD)); + StartReloadPhases(pVM ? GetNEOWpnData().FindReloadTable(pVM->GetSequenceName(pVM->GetSequence())) : -1); } return true; @@ -511,23 +510,36 @@ bool CNEOBaseCombatWeapon::Reload( void ) // Each reload sound piece's file starts this long before its first transient static constexpr float RELOAD_SOUND_LEAD = 0.02f; -// The viewmodel sequence that resumes a reload interrupted after the phase finished last; nullptr: none -// (resume sequences carry no activity, so they are picked by name) -static const char *ResumeSequenceName(int iPhaseDone) +bool CNEOBaseCombatWeapon::IsReloadPhaseSystemEnabled() const +{ + return m_bReloadExperimentalEnabled && GetNEOWpnData().m_iNumReloadTables > 0; +} + +// The viewmodel sequence that resumes the reload interrupted now, from the phase table of the playing sequence; +// nullptr: none (resume sequences carry no activity, so they are picked by name) +const char *CNEOBaseCombatWeapon::FindResumeSequence() const { - switch (iPhaseDone) + const ReloadPhase_t phase = static_cast(m_nReloadPhase.Get()); + if (phase == RELOAD_PHASE_NONE || m_nReloadTable < 0) { - case RELOAD_PHASE_UNLOADED: - // the magazine is out: the draw itself brings the fresh one up - return "resume_after_1_unload_empty"; - default: return nullptr; } -} -bool CNEOBaseCombatWeapon::IsReloadPhaseSystemEnabled() const -{ - return m_bReloadExperimentalEnabled && GetNEOWpnData().m_iNumReloadTables > 0; + // a sequence that starts after the phase is itself the resume from it, interrupted again before its first phase + const ReloadPhaseTable_t &table = GetNEOWpnData().m_reloadTables[m_nReloadTable]; + if (table.iNumRows > 0 && table.rows[0].phase > phase) + { + return table.szSequence; + } + + for (int i = 0; i < table.iNumRows; ++i) + { + if (table.rows[i].phase == phase) + { + return table.rows[i].szResume[0] ? table.rows[i].szResume : nullptr; + } + } + return nullptr; } // Time the phases of a reload sequence that starts now (-1: a sequence without a table finishes none) @@ -598,12 +610,13 @@ void CNEOBaseCombatWeapon::FinishReloadPhase(ReloadPhase_t phase) // as a cancelled reload does; returns whether the reload resumed bool CNEOBaseCombatWeapon::ResumeReload() { - const char *pszName = ResumeSequenceName(m_nReloadPhase); + const char *pszName = FindResumeSequence(); const int iTable = pszName ? GetNEOWpnData().FindReloadTable(pszName) : -1; const int iSequence = (iTable >= 0) ? LookupReloadSequence(pszName) : -1; if (iSequence < 0) { m_nReloadPhase = RELOAD_PHASE_NONE; + m_nReloadTable = -1; return false; } @@ -648,23 +661,20 @@ int CNEOBaseCombatWeapon::LookupReloadSequence(const char *pszName) const void CNEOBaseCombatWeapon::StopReloadSoundPieces() { CBaseCombatCharacter *pOwner = GetOwner(); - if (!pOwner) + if (!pOwner || m_nReloadTable < 0) { return; } - const CNEOWeaponInfo &info = GetNEOWpnData(); - for (int t = 0; t < info.m_iNumReloadTables; ++t) + const ReloadPhaseTable_t &table = GetNEOWpnData().m_reloadTables[m_nReloadTable]; + for (int i = 0; i < table.iNumRows; ++i) { - for (int i = 0; i < info.m_reloadTables[t].iNumRows; ++i) + for (int j = 0; j < RELOAD_SOUNDS_PER_ROW; ++j) { - for (int j = 0; j < RELOAD_SOUNDS_PER_ROW; ++j) + const char *pszName = table.rows[i].sounds[j].szName; + if (pszName[0]) { - const char *pszName = info.m_reloadTables[t].rows[i].sounds[j].szName; - if (pszName[0]) - { - StopSound(pOwner->entindex(), pszName); - } + StopSound(pOwner->entindex(), pszName); } } } @@ -721,7 +731,7 @@ void CNEOBaseCombatWeapon::FinishReload(void) // the magazine is in: the phases up to the load are done, and a switch from here leaves nothing to resume if (IsReloadPhaseSystemEnabled()) { - m_nReloadPhase = Max(m_nReloadPhase.Get(), static_cast(RELOAD_PHASE_LOADED)); + m_nReloadPhase = Max(static_cast(m_nReloadPhase.Get()), RELOAD_PHASE_LOADED); } CBaseCombatCharacter* pOwner = GetOwner(); @@ -842,15 +852,15 @@ float CNEOBaseCombatWeapon::GetPenetration() const bool CNEOBaseCombatWeapon::Holster(CBaseCombatWeapon* pSwitchingTo) { - // Only a phase that a sequence resumes from outlasts the switch + // Only a phase that a sequence resumes from outlasts the switch, with the table that names the resume if (IsReloadPhaseSystemEnabled()) { - if (!ResumeSequenceName(m_nReloadPhase)) + StopReloadSoundPieces(); + if (!FindResumeSequence()) { m_nReloadPhase = RELOAD_PHASE_NONE; + m_nReloadTable = -1; } - m_nReloadTable = -1; - StopReloadSoundPieces(); } return BaseClass::Holster(pSwitchingTo); diff --git a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h index 90d2164b16..77efdc22b2 100644 --- a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h +++ b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h @@ -315,6 +315,7 @@ class CNEOBaseCombatWeapon : public CBaseHL2MPCombatWeapon void StartReloadPhases(int iTable); void RunReloadPhases(); void FinishReloadPhase(ReloadPhase_t phase); + const char *FindResumeSequence() const; bool ResumeReload(); void StopReloadSoundPieces(); void EmitReloadSoundPiece(const char *pszSound); From 4ca81d36e5514055e93ba4400cd5de656bc6b93c Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sat, 7 Nov 2026 21:20:15 -0700 Subject: [PATCH 11/55] Parse the ReloadPhases weapon script block A weapon script can now list timed reload phases (clip, ammo, sound and resume steps). The parser only stores the rows; a later commit uses them. Scripts without the block parse as before. --- .../shared/neo/weapons/neo_weapon_parse.cpp | 76 +++++++++++++++++++ .../shared/neo/weapons/neo_weapon_parse.h | 55 ++++++++++++++ 2 files changed, 131 insertions(+) diff --git a/src/game/shared/neo/weapons/neo_weapon_parse.cpp b/src/game/shared/neo/weapons/neo_weapon_parse.cpp index bafe4597b6..77872fa0eb 100644 --- a/src/game/shared/neo/weapons/neo_weapon_parse.cpp +++ b/src/game/shared/neo/weapons/neo_weapon_parse.cpp @@ -24,6 +24,7 @@ CNEOWeaponInfo::CNEOWeaponInfo() m_flPenetration = 0.f; m_bDropOnDeath = true; iAimFOV = 0; + m_iNumReloadTables = 0; m_flVMFov = m_flVMAimFov = 0.f; m_vecVMPosOffset = m_vecVMAimPosOffset = vec3_origin; @@ -31,6 +32,80 @@ CNEOWeaponInfo::CNEOWeaponInfo() } +// Weapon-script names of the reload phases, by ReloadPhase_t +static constexpr const char *RELOAD_PHASE_NAMES[RELOAD_PHASE_COUNT] = { "", "1_unload", "2_load", "3_cycle" }; +// Weapon-script keys of a phase's sound pieces: { sound name, time } +static constexpr const char *RELOAD_SOUND_KEYS[RELOAD_SOUNDS_PER_ROW][2] = { + { "sound_name", "sound" }, { "sound2_name", "sound2" }, { "sound3_name", "sound3" } +}; + +static ReloadPhase_t ReloadPhaseFromName(const char *pszName) +{ + for (int i = RELOAD_PHASE_UNLOADED; i < RELOAD_PHASE_COUNT; ++i) + { + if (V_stricmp(pszName, RELOAD_PHASE_NAMES[i]) == 0) + { + return static_cast(i); + } + } + return RELOAD_PHASE_NONE; +} + +// "ReloadPhases" { "" { "" { "ammo" "s" "sound" "s" "sound_name" "name" "resume" "sequence" } ... } ... } +void CNEOWeaponInfo::ParseReloadPhases(KeyValues *pBlock) +{ + m_iNumReloadTables = 0; + if (!pBlock) + { + return; + } + + if (!pBlock->GetFirstTrueSubKey()) + { + Warning("%s: \"ReloadPhases\" is empty (is its neoAssets #base file missing?); reloading without phases\n", szClassName); + return; + } + + for (KeyValues *pSeq = pBlock->GetFirstTrueSubKey(); pSeq && m_iNumReloadTables < RELOAD_PHASE_TABLES_MAX; pSeq = pSeq->GetNextTrueSubKey()) + { + ReloadPhaseTable_t &table = m_reloadTables[m_iNumReloadTables++]; + V_strncpy(table.szSequence, pSeq->GetName(), sizeof(table.szSequence)); + table.iNumRows = 0; + + for (KeyValues *pRow = pSeq->GetFirstTrueSubKey(); pRow && table.iNumRows < RELOAD_PHASE_ROWS_MAX; pRow = pRow->GetNextTrueSubKey()) + { + const ReloadPhase_t phase = ReloadPhaseFromName(pRow->GetName()); + if (phase == RELOAD_PHASE_NONE) + { + Warning("%s: unknown reload phase \"%s\" in \"%s\"\n", szClassName, pRow->GetName(), table.szSequence); + continue; + } + + ReloadPhaseRow_t &row = table.rows[table.iNumRows++]; + row.phase = phase; + row.flAmmo = pRow->GetFloat("ammo"); + for (int j = 0; j < RELOAD_SOUNDS_PER_ROW; ++j) + { + row.sounds[j].flAt = pRow->GetFloat(RELOAD_SOUND_KEYS[j][1]); + V_strncpy(row.sounds[j].szName, pRow->GetString(RELOAD_SOUND_KEYS[j][0]), sizeof(row.sounds[j].szName)); + } + V_strncpy(row.szResume, pRow->GetString("resume"), sizeof(row.szResume)); + } + } +} + +int CNEOWeaponInfo::FindReloadTable(const char *pszSequence) const +{ + for (int i = 0; i < m_iNumReloadTables; ++i) + { + if (V_stricmp(m_reloadTables[i].szSequence, pszSequence) == 0) + { + return i; + } + } + return -1; +} + void CNEOWeaponInfo::Parse( KeyValues *pKeyValuesData, const char *szWeaponName ) { BaseClass::Parse( pKeyValuesData, szWeaponName ); @@ -39,6 +114,7 @@ void CNEOWeaponInfo::Parse( KeyValues *pKeyValuesData, const char *szWeaponName m_iBullets = pKeyValuesData->GetInt( "Bullets", 1 ); m_flCycleTime = pKeyValuesData->GetFloat( "CycleTime", 0.15 ); m_flReloadReadyBeforeEnd = pKeyValuesData->GetFloat( "ReloadReadyBeforeEnd", 0.0f ); + ParseReloadPhases(pKeyValuesData->FindKey("ReloadPhases")); const char *notFoundStr = "notfound"; Q_strncpy(szViewModel2, pKeyValuesData->GetString("team2viewmodel", notFoundStr), MAX_WEAPON_STRING); diff --git a/src/game/shared/neo/weapons/neo_weapon_parse.h b/src/game/shared/neo/weapons/neo_weapon_parse.h index 040dc00649..dc10c7d7ca 100644 --- a/src/game/shared/neo/weapons/neo_weapon_parse.h +++ b/src/game/shared/neo/weapons/neo_weapon_parse.h @@ -12,6 +12,54 @@ #include "hl2mp_weapon_parse.h" +// A reload is a linear sequence of phases; a reload sequence finishes each phase at a point of its animation +enum ReloadPhase_t +{ + RELOAD_PHASE_NONE = 0, // no reload in progress, or none pending + RELOAD_PHASE_UNLOADED, // 1_unload: the old magazine is out + RELOAD_PHASE_LOADED, // 2_load: the fresh magazine is in + RELOAD_PHASE_CYCLED, // 3_cycle: the bolt or charging handle chambered a round + + RELOAD_PHASE_COUNT +}; + +// bits to network a phase +static constexpr int RELOAD_PHASE_BITS = 2; +static_assert((1 << RELOAD_PHASE_BITS) >= RELOAD_PHASE_COUNT, "RELOAD_PHASE_BITS cannot hold every phase"); +static constexpr int RELOAD_PHASE_TABLES_MAX = 12; +// bits to network a table index, signed so that -1 (no table) fits +static constexpr int RELOAD_PHASE_TABLE_BITS = 5; +static_assert((1 << (RELOAD_PHASE_TABLE_BITS - 1)) >= RELOAD_PHASE_TABLES_MAX, "RELOAD_PHASE_TABLE_BITS cannot hold every table index"); +static constexpr int RELOAD_PHASE_ROWS_MAX = RELOAD_PHASE_COUNT - 1; +static constexpr int RELOAD_SOUND_NAME_MAX = 64; +static constexpr int RELOAD_SEQUENCE_NAME_MAX = 32; +// a phase may need more than one sound piece, such as loading a magazine and the tap after it +static constexpr int RELOAD_SOUNDS_PER_ROW = 3; + +// A sound piece of a phase +struct ReloadSoundPiece_t +{ + float flAt; // when the piece's first transient plays, seconds from the sequence start + char szName[RELOAD_SOUND_NAME_MAX]; +}; + +// One phase of a reload sequence: when its ammo counts, and the sound pieces that go with it +struct ReloadPhaseRow_t +{ + ReloadPhase_t phase; + float flAmmo; // seconds from the sequence start + ReloadSoundPiece_t sounds[RELOAD_SOUNDS_PER_ROW]; + char szResume[RELOAD_SEQUENCE_NAME_MAX]; // the sequence that resumes a reload interrupted after this phase, or empty +}; + +// The phases one reload sequence carries, in order +struct ReloadPhaseTable_t +{ + char szSequence[RELOAD_SEQUENCE_NAME_MAX]; + int iNumRows; + ReloadPhaseRow_t rows[RELOAD_PHASE_ROWS_MAX]; +}; + //-------------------------------------------------------------------------------------------------------- class CNEOWeaponInfo : public CHL2MPSWeaponInfo { @@ -25,6 +73,8 @@ class CNEOWeaponInfo : public CHL2MPSWeaponInfo int m_iBullets; float m_flCycleTime; float m_flReloadReadyBeforeEnd; + int m_iNumReloadTables; // 0: the weapon reloads without phases + ReloadPhaseTable_t m_reloadTables[RELOAD_PHASE_TABLES_MAX]; char szViewModel2[MAX_WEAPON_STRING]; // Team 2 (NSF) wep vm char szBulletCharacter[MAX_BULLET_CHARACTER];// character used to display ammunition in current clip char szDeathIcon[MAX_BULLET_CHARACTER]; @@ -39,6 +89,11 @@ class CNEOWeaponInfo : public CHL2MPSWeaponInfo float m_flVMAimFov; Vector m_vecVMAimPosOffset; QAngle m_angVMAimAngOffset; + + int FindReloadTable(const char *pszSequence) const; + +private: + void ParseReloadPhases(::KeyValues *pBlock); }; From 5b158bafd8f75cda87a76ae536a1f1f21b915d7a Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sat, 7 Nov 2026 21:20:15 -0700 Subject: [PATCH 12/55] Resume a reload after the magazine is dropped Reloading with a dropped magazine used to restart the whole reload animation. With sv_neo_reload_experimental, a weapon with reload phases plays the unload part once and resumes from the empty-gun pose, finishing at the clip end. A weapon dropped mid-reload stops the reload so it does not resume on pickup. --- src/game/server/neo/neo_player.cpp | 3 + .../weapons/weapon_neobasecombatweapon.cpp | 270 +++++++++++++++++- .../neo/weapons/weapon_neobasecombatweapon.h | 24 ++ 3 files changed, 296 insertions(+), 1 deletion(-) diff --git a/src/game/server/neo/neo_player.cpp b/src/game/server/neo/neo_player.cpp index e09dfbe8b9..6e038c727f 100644 --- a/src/game/server/neo/neo_player.cpp +++ b/src/game/server/neo/neo_player.cpp @@ -2485,6 +2485,8 @@ void CNEO_Player::Weapon_DropOnDeath(CNEOBaseCombatWeapon* pNeoWeapon, Vector da pNeoWeapon->AddEffects(EF_BONEMERGE); } + pNeoWeapon->StopReloadOnDrop(); + Vector playerVelocity = vec3_origin; GetVelocity(&playerVelocity, nullptr); pNeoWeapon->Drop(playerVelocity); @@ -2953,6 +2955,7 @@ void CNEO_Player::Weapon_Drop( CBaseCombatWeapon *pWeapon, return; // Return early to not drop weapon } + neoWeapon->StopReloadOnDrop(); pWeapon->m_bInReload = false; pWeapon->StopWeaponSound(RELOAD_NPC); diff --git a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp index 979d70f8a7..a314fde42f 100644 --- a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp +++ b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp @@ -42,6 +42,11 @@ BEGIN_NETWORK_TABLE( CNEOBaseCombatWeapon, DT_NEOBaseCombatWeapon ) RecvPropInt(RECVINFO(m_nNumShotsFired)), RecvPropBool(RECVINFO(m_bTriggerReset)), RecvPropTime(RECVINFO(m_flReloadReadyTime)), + RecvPropBool(RECVINFO(m_bReloadExperimentalEnabled)), + RecvPropInt(RECVINFO(m_nReloadPhase)), + RecvPropInt(RECVINFO(m_nReloadTable)), + RecvPropTime(RECVINFO(m_flReloadStart)), + RecvPropInt(RECVINFO(m_nReloadSoundsDone)), RecvPropInt(RECVINFO(m_spawnflags)), #else SendPropTime(SENDINFO(m_flSoonestAttack)), @@ -50,6 +55,11 @@ BEGIN_NETWORK_TABLE( CNEOBaseCombatWeapon, DT_NEOBaseCombatWeapon ) SendPropInt(SENDINFO(m_nNumShotsFired)), SendPropBool(SENDINFO(m_bTriggerReset)), SendPropTime(SENDINFO(m_flReloadReadyTime)), + SendPropBool(SENDINFO(m_bReloadExperimentalEnabled)), + SendPropInt(SENDINFO(m_nReloadPhase), RELOAD_PHASE_BITS, SPROP_UNSIGNED), + SendPropInt(SENDINFO(m_nReloadTable), RELOAD_PHASE_TABLE_BITS), + SendPropTime(SENDINFO(m_flReloadStart)), + SendPropInt(SENDINFO(m_nReloadSoundsDone), RELOAD_PHASE_ROWS_MAX * RELOAD_SOUNDS_PER_ROW, SPROP_UNSIGNED), SendPropInt(SENDINFO(m_spawnflags)), SendPropExclude("DT_BaseAnimating", "m_nSequence"), #endif @@ -63,6 +73,11 @@ BEGIN_PREDICTION_DATA(CNEOBaseCombatWeapon) DEFINE_PRED_FIELD(m_nNumShotsFired, FIELD_INTEGER, FTYPEDESC_INSENDTABLE), DEFINE_PRED_FIELD(m_bTriggerReset, FIELD_BOOLEAN, FTYPEDESC_INSENDTABLE), DEFINE_PRED_FIELD(m_flReloadReadyTime, FIELD_FLOAT, FTYPEDESC_INSENDTABLE), + DEFINE_PRED_FIELD(m_bReloadExperimentalEnabled, FIELD_BOOLEAN, FTYPEDESC_INSENDTABLE), + DEFINE_PRED_FIELD(m_nReloadPhase, FIELD_INTEGER, FTYPEDESC_INSENDTABLE), + DEFINE_PRED_FIELD(m_nReloadTable, FIELD_INTEGER, FTYPEDESC_INSENDTABLE), + DEFINE_PRED_FIELD(m_flReloadStart, FIELD_FLOAT, FTYPEDESC_INSENDTABLE), + DEFINE_PRED_FIELD(m_nReloadSoundsDone, FIELD_INTEGER, FTYPEDESC_INSENDTABLE), END_PREDICTION_DATA() #endif @@ -76,11 +91,19 @@ BEGIN_DATADESC( CNEOBaseCombatWeapon ) DEFINE_FIELD(m_nNumShotsFired, FIELD_INTEGER), DEFINE_FIELD(m_bTriggerReset, FIELD_BOOLEAN), DEFINE_FIELD(m_flReloadReadyTime, FIELD_TIME), + DEFINE_FIELD(m_bReloadExperimentalEnabled, FIELD_BOOLEAN), + DEFINE_FIELD(m_nReloadPhase, FIELD_INTEGER), + DEFINE_FIELD(m_nReloadTable, FIELD_INTEGER), + DEFINE_FIELD(m_flReloadStart, FIELD_TIME), + DEFINE_FIELD(m_nReloadSoundsDone, FIELD_INTEGER), END_DATADESC() #endif ConVar sv_neo_accuracy_penalty_scale("sv_neo_accuracy_penalty_scale", "1.0", FCVAR_REPLICATED, "Scales the accuracy penalty per shot.", true, 0.0f, true, 2.0f); ConVar sv_neo_dynamic_viewkick("sv_neo_dynamic_viewkick", "0", FCVAR_REPLICATED, "Enables view kick scaling based on current inaccuracy.", true, 0.0f, true, 1.0f); +ConVar sv_neo_reload_experimental("sv_neo_reload_experimental", "0", FCVAR_REPLICATED, + "Lets a switch interrupt a reload after the magazine is out, for weapons that define reload phases. Set before the map loads.", + true, 0.0f, true, 1.0f); const char *GetWeaponByLoadoutId(int id) { @@ -232,7 +255,12 @@ static const WeaponHandlingInfo_t handlingTable[] = { CNEOBaseCombatWeapon::CNEOBaseCombatWeapon( void ) { + m_bReloadExperimentalEnabled = sv_neo_reload_experimental.GetBool(); m_bTriggerReset = true; + m_nReloadPhase = RELOAD_PHASE_NONE; + m_nReloadTable = -1; + m_flReloadStart = 0.0f; + m_nReloadSoundsDone = 0; } const CNEOWeaponInfo &CNEOBaseCombatWeapon::GetNEOWpnData() const @@ -441,6 +469,14 @@ bool CNEOBaseCombatWeapon::Reload( void ) // the animation and the wait to fire still run to the end m_flReloadReadyTime = Max(gpGlobals->curtime, m_flNextPrimaryAttack - GetNEOWpnData().m_flReloadReadyBeforeEnd); + if (IsReloadPhaseSystemEnabled()) + { + // the phases are those of the sequence the reload plays, such as reload or reloadempty + CBaseViewModel *pVM = ReloadViewModel(); + m_nReloadPhase = RELOAD_PHASE_NONE; + StartReloadPhases(pVM ? GetNEOWpnData().FindReloadTable(pVM->GetSequenceName(pVM->GetSequence())) : -1); + } + return true; #if(0) @@ -471,6 +507,214 @@ bool CNEOBaseCombatWeapon::Reload( void ) #endif } +// Each reload sound piece's file starts this long before its first transient +static constexpr float RELOAD_SOUND_LEAD = 0.02f; + +bool CNEOBaseCombatWeapon::IsReloadPhaseSystemEnabled() const +{ + return m_bReloadExperimentalEnabled && GetNEOWpnData().m_iNumReloadTables > 0; +} + +// The viewmodel sequence that resumes the reload interrupted now, from the phase table of the playing sequence; +// nullptr: none (resume sequences carry no activity, so they are picked by name) +const char *CNEOBaseCombatWeapon::FindResumeSequence() const +{ + const ReloadPhase_t phase = static_cast(m_nReloadPhase.Get()); + if (phase == RELOAD_PHASE_NONE || m_nReloadTable < 0) + { + return nullptr; + } + + // a sequence that starts after the phase is itself the resume from it, interrupted again before its first phase + const ReloadPhaseTable_t &table = GetNEOWpnData().m_reloadTables[m_nReloadTable]; + if (table.iNumRows > 0 && table.rows[0].phase > phase) + { + return table.szSequence; + } + + for (int i = 0; i < table.iNumRows; ++i) + { + if (table.rows[i].phase == phase) + { + return table.rows[i].szResume[0] ? table.rows[i].szResume : nullptr; + } + } + return nullptr; +} + +// Time the phases of a reload sequence that starts now (-1: a sequence without a table finishes none) +void CNEOBaseCombatWeapon::StartReloadPhases(int iTable) +{ + m_nReloadTable = iTable; + m_flReloadStart = gpGlobals->curtime; + m_nReloadSoundsDone = 0; +} + +// Finish every phase of the playing reload sequence whose time has come, and play its sound pieces +void CNEOBaseCombatWeapon::RunReloadPhases() +{ + if (!m_bInReload || m_nReloadTable < 0) + { + return; + } + + const ReloadPhaseTable_t &table = GetNEOWpnData().m_reloadTables[m_nReloadTable]; + const float flElapsed = gpGlobals->curtime - m_flReloadStart; + + // Sound pieces play on their own times, before or after their phase's ammo time + for (int i = 0; i < table.iNumRows; ++i) + { + for (int j = 0; j < RELOAD_SOUNDS_PER_ROW; ++j) + { + const ReloadSoundPiece_t &piece = table.rows[i].sounds[j]; + const int iBit = 1 << (i * RELOAD_SOUNDS_PER_ROW + j); + if (piece.szName[0] && !(m_nReloadSoundsDone & iBit) && flElapsed >= piece.flAt - RELOAD_SOUND_LEAD) + { + m_nReloadSoundsDone |= iBit; + EmitReloadSoundPiece(piece.szName); + } + } + } + + for (int i = 0; i < table.iNumRows; ++i) + { + const ReloadPhaseRow_t &row = table.rows[i]; + if (row.phase <= m_nReloadPhase) + { + continue; + } + + if (flElapsed < row.flAmmo) + { + break; + } + + FinishReloadPhase(row.phase); + } +} + +void CNEOBaseCombatWeapon::FinishReloadPhase(ReloadPhase_t phase) +{ + // The unload takes no rounds: they are lost only if a switch interrupts the reload after it (ResumeReload), + // so an uninterrupted reload shows the same clip as without phases + if (phase == RELOAD_PHASE_LOADED) + { + // the magazine loads now, as at a reload's ready time (ItemBusyFrame) + m_flReloadReadyTime = gpGlobals->curtime; + } + + m_nReloadPhase = phase; +} + +// Resume, in the draw, a reload interrupted by a switch. A model without the resume sequence keeps the old magazine, +// as a cancelled reload does; returns whether the reload resumed +bool CNEOBaseCombatWeapon::ResumeReload() +{ + const char *pszName = FindResumeSequence(); + const int iTable = pszName ? GetNEOWpnData().FindReloadTable(pszName) : -1; + const int iSequence = (iTable >= 0) ? LookupReloadSequence(pszName) : -1; + if (iSequence < 0) + { + m_nReloadPhase = RELOAD_PHASE_NONE; + m_nReloadTable = -1; + return false; + } + + // the old magazine and its rounds are gone, as when a reload loads at its ready time + m_iClip1 = 0; + + SetSequence(iSequence); + SendViewModelAnim(iSequence); + + // the draw is part of the motion: the full reload gesture fits the resume + ToHL2MPPlayer(GetOwner())->DoAnimationEvent(PLAYERANIMEVENT_RELOAD); + + const float flEnd = gpGlobals->curtime + ReloadViewModel()->SequenceDuration(iSequence); + GetOwner()->SetNextAttack(flEnd); + m_flNextPrimaryAttack = m_flNextSecondaryAttack = flEnd; + SetWeaponIdleTime(flEnd); + + // the load phase loads the magazine + m_flReloadReadyTime = 0.0f; + StartReloadPhases(iTable); + m_bInReload = true; + return true; +} + +// Reload sequences are looked up on the owner's viewmodel, the entity that plays them. The weapon entity's model is not +// always that viewmodel on the client: CalcOverrideModelIndex gives it the world model whenever the local player does +// not draw its viewmodel +CBaseViewModel *CNEOBaseCombatWeapon::ReloadViewModel() const +{ + CBasePlayer *pOwner = ToBasePlayer(GetOwner()); + return pOwner ? pOwner->GetViewModel(m_nViewModelIndex) : nullptr; +} + +int CNEOBaseCombatWeapon::LookupReloadSequence(const char *pszName) const +{ + CBaseViewModel *pVM = ReloadViewModel(); + return pVM ? pVM->LookupSequence(pszName) : -1; +} + +// Sound pieces play on their own channel entries, so a switch or a drop stops them by name, +// as the player stops the single reload sound +void CNEOBaseCombatWeapon::StopReloadSoundPieces() +{ + CBaseCombatCharacter *pOwner = GetOwner(); + if (!pOwner || m_nReloadTable < 0) + { + return; + } + + const ReloadPhaseTable_t &table = GetNEOWpnData().m_reloadTables[m_nReloadTable]; + for (int i = 0; i < table.iNumRows; ++i) + { + for (int j = 0; j < RELOAD_SOUNDS_PER_ROW; ++j) + { + const char *pszName = table.rows[i].sounds[j].szName; + if (pszName[0]) + { + StopSound(pOwner->entindex(), pszName); + } + } + } +} + +// A dropped weapon cancels its reload: the next owner does not resume it +void CNEOBaseCombatWeapon::StopReloadOnDrop() +{ + if (!IsReloadPhaseSystemEnabled()) + { + return; + } + + StopReloadSoundPieces(); + m_nReloadPhase = RELOAD_PHASE_NONE; + m_nReloadTable = -1; +} + +// Play a reload sound piece from the owner, as WeaponSound does: predicted for the owner, from the server for the rest +void CNEOBaseCombatWeapon::EmitReloadSoundPiece(const char *pszSound) +{ + CBaseCombatCharacter *pOwner = GetOwner(); + if (!pOwner) + { + return; + } + + CSoundParameters params; + if (!GetParametersForSound(pszSound, params, NULL)) + { + return; + } + + CPASAttenuationFilter filter(pOwner, params.soundlevel); + if (IsPredicted() && CBaseEntity::GetPredictionPlayer()) + { + filter.UsePredictionRules(); + } + EmitSound(filter, pOwner->entindex(), pszSound); +} //----------------------------------------------------------------------------- // Purpose: Reload has finished. @@ -484,6 +728,12 @@ void CNEOBaseCombatWeapon::FinishReload(void) } m_flReloadReadyTime = 0.0f; + // the magazine is in: the phases up to the load are done, and a switch from here leaves nothing to resume + if (IsReloadPhaseSystemEnabled()) + { + m_nReloadPhase = Max(static_cast(m_nReloadPhase.Get()), RELOAD_PHASE_LOADED); + } + CBaseCombatCharacter* pOwner = GetOwner(); if (pOwner) @@ -533,7 +783,9 @@ bool CNEOBaseCombatWeapon::Deploy(void) // An empty weapon draws with its slide held back where the model has that draw, // which carries no activity, so it is picked by name static constexpr const char *VM_SEQ_DRAW_EMPTY = "drawempty"; - const int iDrawEmpty = (UsesClipsForAmmo1() && m_iClip1 <= 0) ? LookupSequence(VM_SEQ_DRAW_EMPTY) : ACTIVITY_NOT_AVAILABLE; + // a reload interrupted by a switch goes on in the draw + const bool bResumed = IsReloadPhaseSystemEnabled() && m_nReloadPhase != RELOAD_PHASE_NONE && ResumeReload(); + const int iDrawEmpty = (!bResumed && UsesClipsForAmmo1() && m_iClip1 <= 0) ? LookupSequence(VM_SEQ_DRAW_EMPTY) : ACTIVITY_NOT_AVAILABLE; if (iDrawEmpty != ACTIVITY_NOT_AVAILABLE) { SetSequence(iDrawEmpty); @@ -600,6 +852,17 @@ float CNEOBaseCombatWeapon::GetPenetration() const bool CNEOBaseCombatWeapon::Holster(CBaseCombatWeapon* pSwitchingTo) { + // Only a phase that a sequence resumes from outlasts the switch, with the table that names the resume + if (IsReloadPhaseSystemEnabled()) + { + StopReloadSoundPieces(); + if (!FindResumeSequence()) + { + m_nReloadPhase = RELOAD_PHASE_NONE; + m_nReloadTable = -1; + } + } + return BaseClass::Holster(pSwitchingTo); } @@ -655,6 +918,11 @@ void CNEOBaseCombatWeapon::ItemBusyFrame(void) BaseClass::ItemBusyFrame(); UpdateInaccuracy(); + if (IsReloadPhaseSystemEnabled()) + { + RunReloadPhases(); + } + // The owner stays busy until the reload animation ends, but the magazine loads at the reload's ready time if (m_bInReload && m_flReloadReadyTime > 0.0f && gpGlobals->curtime >= m_flReloadReadyTime) { diff --git a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h index a772edda17..77efdc22b2 100644 --- a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h +++ b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h @@ -264,6 +264,7 @@ class CNEOBaseCombatWeapon : public CBaseHL2MPCombatWeapon virtual float GetFireRate() override final; float GetPenetration() const; + void StopReloadOnDrop(); #ifdef CLIENT_DLL float m_flTemperature; int m_spawnflags; @@ -282,6 +283,7 @@ class CNEOBaseCombatWeapon : public CBaseHL2MPCombatWeapon virtual float GetMaxAccuracyPenalty() const { return 1.0; } virtual float GetAccuracyPenaltyDecay(); virtual float GetFastestDryRefireTime() const { Assert(false); return 0; } // Should never call this base class; implement in children. + bool IsReloadPhaseSystemEnabled() const; protected: CNetworkVar(float, m_flSoonestAttack); @@ -294,10 +296,32 @@ class CNEOBaseCombatWeapon : public CBaseHL2MPCombatWeapon // When the reload in progress loads the magazine, 0 once it is loaded CNetworkVar(float, m_flReloadReadyTime); + // The server's pre-game reload setting, snapshotted for prediction + CNetworkVar(bool, m_bReloadExperimentalEnabled); + + // Reload phases (weapons whose script has a ReloadPhases block): the last phase finished, kept across a switch + CNetworkVar(int, m_nReloadPhase); + // the phase table of the reload sequence started last, -1 none + CNetworkVar(int, m_nReloadTable); + // when the reload sequence started; phase times are offsets from it + CNetworkVar(float, m_flReloadStart); + // the sound pieces of the playing sequence already started, one bit per piece + CNetworkVar(int, m_nReloadSoundsDone); + private: CNEOBaseCombatWeapon(const CNEOBaseCombatWeapon &other); bool HasEmptyIdle(); + void StartReloadPhases(int iTable); + void RunReloadPhases(); + void FinishReloadPhase(ReloadPhase_t phase); + const char *FindResumeSequence() const; + bool ResumeReload(); + void StopReloadSoundPieces(); + void EmitReloadSoundPiece(const char *pszSound); + CBaseViewModel *ReloadViewModel() const; + int LookupReloadSequence(const char *pszName) const; + }; #endif // WEAPON_NEO_BASECOMBATWEAPON_SHARED_H From b647643194f0abe61031ed6df8551ef4e9b289a5 Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sat, 7 Nov 2026 21:20:15 -0700 Subject: [PATCH 13/55] Add the ZR68C reload phases and sounds Point the ZR68C script at the phases file that neoAssets ships and add the sound entries for its new reload pieces. Ignore the copied phases file in game/neo/scripts. --- .gitignore | 3 +++ game/neo/scripts/game_sounds_weapons.txt | 30 ++++++++++++++++++++++++ game/neo/scripts/weapon_zr68c.txt | 5 ++++ 3 files changed, 38 insertions(+) diff --git a/.gitignore b/.gitignore index 3d541782cc..590e093b19 100644 --- a/.gitignore +++ b/.gitignore @@ -49,6 +49,9 @@ out # Match session restore file /game/neo/scripts/match_session_restore_point.txt +# Reload phases copied from neoAssets +/game/neo/scripts/weapon_*_reload_phases.txt + # Shader state debug image dumps /game/neo/*.tga diff --git a/game/neo/scripts/game_sounds_weapons.txt b/game/neo/scripts/game_sounds_weapons.txt index ad9ac75c4f..4d0cfc3a15 100644 --- a/game/neo/scripts/game_sounds_weapons.txt +++ b/game/neo/scripts/game_sounds_weapons.txt @@ -759,6 +759,36 @@ "wave" "weapons/zr68/zr68_reload.wav" } +// ZR68 reload in per-step pieces (sv_neo_reload_experimental), named after the step; _2 is a step's second sound. +// Each file starts just before its first transient + +"weapon_zr68.reload_2_load" +{ + "channel" "CHAN_ITEM" + "soundlevel" "SNDLVL_NORM" + "volume" "1.0" + "pitch" "PITCH_NORM" + "wave" ")weapons/zr68/zr68_reload_2_load.wav" +} + +"weapon_zr68.reload_2_load_2" +{ + "channel" "CHAN_ITEM" + "soundlevel" "SNDLVL_NORM" + "volume" "1.0" + "pitch" "PITCH_NORM" + "wave" ")weapons/zr68/zr68_reload_2_load_2.wav" +} + +"weapon_zr68.reload_3_cycle" +{ + "channel" "CHAN_ITEM" + "soundlevel" "SNDLVL_NORM" + "volume" "1.0" + "pitch" "PITCH_NORM" + "wave" ")weapons/zr68/zr68_reload_3_cycle.wav" +} + //------------------- "weapon_zr68.npc_reload" diff --git a/game/neo/scripts/weapon_zr68c.txt b/game/neo/scripts/weapon_zr68c.txt index 38f426b6d0..d7f86f9791 100644 --- a/game/neo/scripts/weapon_zr68c.txt +++ b/game/neo/scripts/weapon_zr68c.txt @@ -1,3 +1,5 @@ +#base "weapon_zr68c_reload_phases.txt" + // ZR68S WeaponData @@ -16,6 +18,9 @@ WeaponData "Penetration" "28.0" "CycleTime" "0.090909" // time between shots "ReloadReadyBeforeEnd" "0.483" // the reload is done at the last reload click, this long before its animation ends + + // Reload phases (sv_neo_reload_experimental): the rows come from neoAssets, timed from its Blender markers + "ReloadPhases" {} "TPMuzzleFlashScale" "0.5" From b327de08fa229a29719386ab540472b899026e15 Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sat, 7 Nov 2026 21:22:14 -0700 Subject: [PATCH 14/55] Sketch the ZR68C chamber and partial reloads Discovery sketch on the MVP (not for review). ChamberedRound keeps a chambered round through a reload with rounds left (30+1, U2) via reload_partial; the last shot empties the chamber and 3_cycle fills it. ResumeReload is split into PlayReloadSequence, keeps the chambered round, and drops the magazine only after 1_unload. A gun dropped after 2_load keeps its phase so the next owner resumes (U4). Built: Linux dedicated Debug rc 0. --- game/neo/scripts/game_sounds_weapons.txt | 12 ++ game/neo/scripts/weapon_zr68c.txt | 3 + .../shared/neo/weapons/neo_weapon_parse.cpp | 3 + .../shared/neo/weapons/neo_weapon_parse.h | 4 + .../weapons/weapon_neobasecombatweapon.cpp | 170 +++++++++++++++++- .../neo/weapons/weapon_neobasecombatweapon.h | 14 ++ 6 files changed, 198 insertions(+), 8 deletions(-) diff --git a/game/neo/scripts/game_sounds_weapons.txt b/game/neo/scripts/game_sounds_weapons.txt index 4d0cfc3a15..805249f291 100644 --- a/game/neo/scripts/game_sounds_weapons.txt +++ b/game/neo/scripts/game_sounds_weapons.txt @@ -762,6 +762,18 @@ // ZR68 reload in per-step pieces (sv_neo_reload_experimental), named after the step; _2 is a step's second sound. // Each file starts just before its first transient +// sketch-zr68c-full: the unload piece for reload_partial (the single reload wav contains the bolt). +// NEO TODO (sunzenshen): PLACEHOLDER wav in the sketch's neoAssets (a copy of zr68_reload_2_load.wav); cut the real +// piece from zr68_reload.wav at the reload:1_unload.sound marker - 0.020 s, as the others +"weapon_zr68.reload_1_unload" +{ + "channel" "CHAN_ITEM" + "soundlevel" "SNDLVL_NORM" + "volume" "1.0" + "pitch" "PITCH_NORM" + "wave" ")weapons/zr68/zr68_reload_1_unload.wav" +} + "weapon_zr68.reload_2_load" { "channel" "CHAN_ITEM" diff --git a/game/neo/scripts/weapon_zr68c.txt b/game/neo/scripts/weapon_zr68c.txt index d7f86f9791..0d1519cf40 100644 --- a/game/neo/scripts/weapon_zr68c.txt +++ b/game/neo/scripts/weapon_zr68c.txt @@ -21,6 +21,9 @@ WeaponData // Reload phases (sv_neo_reload_experimental): the rows come from neoAssets, timed from its Blender markers "ReloadPhases" {} + // sketch-zr68c-full: closed bolt, a reload with rounds left keeps the chambered one (30+1). Gameplay, so here and + // not in the neoAssets phases file; only read while the reload phases are on (HasChamberSlot) + "ChamberedRound" "1" "TPMuzzleFlashScale" "0.5" diff --git a/src/game/shared/neo/weapons/neo_weapon_parse.cpp b/src/game/shared/neo/weapons/neo_weapon_parse.cpp index 77872fa0eb..d8dbc2c883 100644 --- a/src/game/shared/neo/weapons/neo_weapon_parse.cpp +++ b/src/game/shared/neo/weapons/neo_weapon_parse.cpp @@ -25,6 +25,7 @@ CNEOWeaponInfo::CNEOWeaponInfo() m_bDropOnDeath = true; iAimFOV = 0; m_iNumReloadTables = 0; + m_bChamberedRound = false; m_flVMFov = m_flVMAimFov = 0.f; m_vecVMPosOffset = m_vecVMAimPosOffset = vec3_origin; @@ -115,6 +116,8 @@ void CNEOWeaponInfo::Parse( KeyValues *pKeyValuesData, const char *szWeaponName m_flCycleTime = pKeyValuesData->GetFloat( "CycleTime", 0.15 ); m_flReloadReadyBeforeEnd = pKeyValuesData->GetFloat( "ReloadReadyBeforeEnd", 0.0f ); ParseReloadPhases(pKeyValuesData->FindKey("ReloadPhases")); + // sketch-zr68c-full: only meaningful with phases (the chamber round needs reload_partial); see HasChamberSlot + m_bChamberedRound = pKeyValuesData->GetBool("ChamberedRound", false); const char *notFoundStr = "notfound"; Q_strncpy(szViewModel2, pKeyValuesData->GetString("team2viewmodel", notFoundStr), MAX_WEAPON_STRING); diff --git a/src/game/shared/neo/weapons/neo_weapon_parse.h b/src/game/shared/neo/weapons/neo_weapon_parse.h index dc10c7d7ca..0febf9e36c 100644 --- a/src/game/shared/neo/weapons/neo_weapon_parse.h +++ b/src/game/shared/neo/weapons/neo_weapon_parse.h @@ -74,6 +74,10 @@ class CNEOWeaponInfo : public CHL2MPSWeaponInfo float m_flCycleTime; float m_flReloadReadyBeforeEnd; int m_iNumReloadTables; // 0: the weapon reloads without phases + // NEO TODO (sunzenshen): sketch-zr68c-full. A closed-bolt gun keeps a round in the chamber through a reload with + // rounds left (30+1). Gameplay, not asset data, so the key sits at WeaponData top level in neo's weapon script, + // not in the neoAssets phases file. Ported from the old slice (ad3749afb), where it sat inside ReloadPhases. + bool m_bChamberedRound; ReloadPhaseTable_t m_reloadTables[RELOAD_PHASE_TABLES_MAX]; char szViewModel2[MAX_WEAPON_STRING]; // Team 2 (NSF) wep vm char szBulletCharacter[MAX_BULLET_CHARACTER];// character used to display ammunition in current clip diff --git a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp index a314fde42f..917e032e92 100644 --- a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp +++ b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp @@ -47,6 +47,7 @@ BEGIN_NETWORK_TABLE( CNEOBaseCombatWeapon, DT_NEOBaseCombatWeapon ) RecvPropInt(RECVINFO(m_nReloadTable)), RecvPropTime(RECVINFO(m_flReloadStart)), RecvPropInt(RECVINFO(m_nReloadSoundsDone)), + RecvPropBool(RECVINFO(m_bChamberEmpty)), RecvPropInt(RECVINFO(m_spawnflags)), #else SendPropTime(SENDINFO(m_flSoonestAttack)), @@ -60,6 +61,7 @@ BEGIN_NETWORK_TABLE( CNEOBaseCombatWeapon, DT_NEOBaseCombatWeapon ) SendPropInt(SENDINFO(m_nReloadTable), RELOAD_PHASE_TABLE_BITS), SendPropTime(SENDINFO(m_flReloadStart)), SendPropInt(SENDINFO(m_nReloadSoundsDone), RELOAD_PHASE_ROWS_MAX * RELOAD_SOUNDS_PER_ROW, SPROP_UNSIGNED), + SendPropBool(SENDINFO(m_bChamberEmpty)), SendPropInt(SENDINFO(m_spawnflags)), SendPropExclude("DT_BaseAnimating", "m_nSequence"), #endif @@ -78,6 +80,7 @@ BEGIN_PREDICTION_DATA(CNEOBaseCombatWeapon) DEFINE_PRED_FIELD(m_nReloadTable, FIELD_INTEGER, FTYPEDESC_INSENDTABLE), DEFINE_PRED_FIELD(m_flReloadStart, FIELD_FLOAT, FTYPEDESC_INSENDTABLE), DEFINE_PRED_FIELD(m_nReloadSoundsDone, FIELD_INTEGER, FTYPEDESC_INSENDTABLE), + DEFINE_PRED_FIELD(m_bChamberEmpty, FIELD_BOOLEAN, FTYPEDESC_INSENDTABLE), END_PREDICTION_DATA() #endif @@ -96,6 +99,7 @@ BEGIN_DATADESC( CNEOBaseCombatWeapon ) DEFINE_FIELD(m_nReloadTable, FIELD_INTEGER), DEFINE_FIELD(m_flReloadStart, FIELD_TIME), DEFINE_FIELD(m_nReloadSoundsDone, FIELD_INTEGER), + DEFINE_FIELD(m_bChamberEmpty, FIELD_BOOLEAN), END_DATADESC() #endif @@ -261,6 +265,9 @@ CNEOBaseCombatWeapon::CNEOBaseCombatWeapon( void ) m_nReloadTable = -1; m_flReloadStart = 0.0f; m_nReloadSoundsDone = 0; + // NEO TODO (sunzenshen): sketch-zr68c-full. A fresh gun spawns with 30 = 29+1 here; should it spawn 30+1 (clip + // GetMaxClip1() + 1)? Open question for the user, it changes the ZR68C's spawn ammo + m_bChamberEmpty = false; } const CNEOWeaponInfo &CNEOBaseCombatWeapon::GetNEOWpnData() const @@ -448,6 +455,14 @@ void CNEOBaseCombatWeapon::Equip(CBaseCombatCharacter* pOwner) bool CNEOBaseCombatWeapon::Reload( void ) { + // sketch-zr68c-full (MVP Reload(), new lines before its first statement): a reload with a round chambered keeps it + // and skips the cycle (U2: 30+1, fire at the clip end). It bypasses DefaultReload: its single wav contains the bolt, + // and its clip >= max gate refuses 29+1. A model without reload_partial falls through to master's reload + if (StartPartialReload()) + { + return true; + } + const bool bEmptyReload = UsesClipsForAmmo1() && m_iClip1 <= 0 && SelectWeightedSequence(ACT_VM_RELOAD_EMPTY) != ACTIVITY_NOT_AVAILABLE; @@ -603,32 +618,87 @@ void CNEOBaseCombatWeapon::FinishReloadPhase(ReloadPhase_t phase) m_flReloadReadyTime = gpGlobals->curtime; } + // sketch-zr68c-full (new case in MVP FinishReloadPhase): the bolt chambers a round + if (phase == RELOAD_PHASE_CYCLED) + { + m_bChamberEmpty = false; + } + m_nReloadPhase = phase; } // Resume, in the draw, a reload interrupted by a switch. A model without the resume sequence keeps the old magazine, // as a cancelled reload does; returns whether the reload resumed +// sketch-zr68c-full: MVP ResumeReload() body split; the play part moved to PlayReloadSequence. The resume itself is +// still chosen by FindResumeSequence (M2), so the chamber-live and dry resumes need no chamber test here bool CNEOBaseCombatWeapon::ResumeReload() { const char *pszName = FindResumeSequence(); const int iTable = pszName ? GetNEOWpnData().FindReloadTable(pszName) : -1; - const int iSequence = (iTable >= 0) ? LookupReloadSequence(pszName) : -1; - if (iSequence < 0) + if (iTable < 0 || LookupReloadSequence(pszName) < 0) { m_nReloadPhase = RELOAD_PHASE_NONE; m_nReloadTable = -1; return false; } - // the old magazine and its rounds are gone, as when a reload loads at its ready time - m_iClip1 = 0; + // read from the interrupted table before PlayReloadSequence replaces it + const float flGestureCycle = ResumeGestureCycle(); + + // The old magazine and its rounds are gone, as when a reload loads at its ready time; a chambered round stays. + // Only after the unload: after 2_load the fresh magazine is already in (resume_after_2_load_empty) + if (m_nReloadPhase == RELOAD_PHASE_UNLOADED) + { + m_iClip1 = IsRoundChambered() ? 1 : 0; + } + + return PlayReloadSequence(pszName, iTable, flGestureCycle); +} + +// sketch-zr68c-full: the fresh chamber-live reload (U2). Plays reload_partial by name: it carries no activity, and +// the shipped reload (ACT_VM_RELOAD) is the dry one, as in Source's reload / reload_empty pairs read the other way +bool CNEOBaseCombatWeapon::StartPartialReload() +{ + static constexpr const char *VM_SEQ_RELOAD_PARTIAL = "reload_partial"; + if (!IsReloadPhaseSystemEnabled() || !IsRoundChambered()) + { + return false; + } + + // NEO TODO (sunzenshen): DefaultReload's other gates (owner, reserve) are repeated here, check the full list + // (ClientWantsAutoReload, m_bInReload, the HL2MP CheckReload path) before review + if (RoundsInMagazine() >= MagazineCapacity() || m_iPrimaryAmmoCount <= 0) + { + return false; + } + + const int iTable = GetNEOWpnData().FindReloadTable(VM_SEQ_RELOAD_PARTIAL); + if (iTable < 0 || LookupReloadSequence(VM_SEQ_RELOAD_PARTIAL) < 0) + { + return false; + } + + m_nReloadPhase = RELOAD_PHASE_NONE; + return PlayReloadSequence(VM_SEQ_RELOAD_PARTIAL, iTable, 0.0f); +} + +// Play a reload sequence picked by name and time its phase table. The third-person gesture starts at flGestureCycle +// (U5, ported from the old slice: a resume starts the full reload gesture where the reload resumes) +bool CNEOBaseCombatWeapon::PlayReloadSequence(const char *pszName, int iTable, float flGestureCycle) +{ + const int iSequence = LookupReloadSequence(pszName); + if (iSequence < 0) + { + return false; + } SetSequence(iSequence); SendViewModelAnim(iSequence); - // the draw is part of the motion: the full reload gesture fits the resume - ToHL2MPPlayer(GetOwner())->DoAnimationEvent(PLAYERANIMEVENT_RELOAD); + // the gesture event carries the start cycle in thousandths (CHL2MPPlayerAnimState::DoAnimationEvent) + ToHL2MPPlayer(GetOwner())->DoAnimationEvent(PLAYERANIMEVENT_RELOAD, static_cast(flGestureCycle * 1000.0f)); + // the clip end is the fire point: no ReloadReadyBeforeEnd on this path const float flEnd = gpGlobals->curtime + ReloadViewModel()->SequenceDuration(iSequence); GetOwner()->SetNextAttack(flEnd); m_flNextPrimaryAttack = m_flNextSecondaryAttack = flEnd; @@ -641,6 +711,59 @@ bool CNEOBaseCombatWeapon::ResumeReload() return true; } +// Where the third-person reload gesture starts for a resume: the interrupted table's ammo time of the last finished +// phase, as a fraction of that table's sequence (0 for anything else) +// NEO TODO (sunzenshen): the gesture is the player model's reload, not the viewmodel's, so the fraction is only an +// approximation (old slice did the same). A resume interrupted again before its first phase gets 0: it should map +// back to the original reload's fraction. Open question U5 follow-up: is RELOAD_END on holster wanted too? +float CNEOBaseCombatWeapon::ResumeGestureCycle() const +{ + if (m_nReloadPhase == RELOAD_PHASE_NONE || m_nReloadTable < 0) + { + return 0.0f; + } + + const ReloadPhaseTable_t &table = GetNEOWpnData().m_reloadTables[m_nReloadTable]; + const int iSequence = LookupReloadSequence(table.szSequence); + CBaseViewModel *pVM = ReloadViewModel(); + const float flDuration = (pVM && iSequence >= 0) ? pVM->SequenceDuration(iSequence) : 0.0f; + if (flDuration <= 0.0f) + { + return 0.0f; + } + + for (int i = 0; i < table.iNumRows; ++i) + { + if (table.rows[i].phase == m_nReloadPhase) + { + return clamp(table.rows[i].flAmmo / flDuration, 0.0f, 1.0f); + } + } + return 0.0f; +} + +// sketch-zr68c-full: chamber model, ported from the old slice (ad3749afb) +bool CNEOBaseCombatWeapon::HasChamberSlot() const +{ + return IsReloadPhaseSystemEnabled() && GetNEOWpnData().m_bChamberedRound; +} + +// The clip counts the chambered round; the chamber is empty after the last shot until a 3_cycle +bool CNEOBaseCombatWeapon::IsRoundChambered() const +{ + return HasChamberSlot() && m_iClip1 > 0 && !m_bChamberEmpty; +} + +int CNEOBaseCombatWeapon::RoundsInMagazine() const +{ + return m_iClip1 - (IsRoundChambered() ? 1 : 0); +} + +int CNEOBaseCombatWeapon::MagazineCapacity() const +{ + return GetMaxClip1(); +} + // Reload sequences are looked up on the owner's viewmodel, the entity that plays them. The weapon entity's model is not // always that viewmodel on the client: CalcOverrideModelIndex gives it the world model whenever the local player does // not draw its viewmodel @@ -689,6 +812,18 @@ void CNEOBaseCombatWeapon::StopReloadOnDrop() } StopReloadSoundPieces(); + + // sketch-zr68c-full, U4 (a): a gun dropped after the load but before the cycle keeps its phase and table, so the + // next owner's draw plays the resume (resume_after_2_load_empty) and chambers the round. Without this the gun would + // hold a full magazine it cannot fire. A drop after the unload still cancels, as in the MVP (the old magazine stays) + // NEO TODO (sunzenshen): open question: should a drop after 1_unload also resume for the next owner? + // NEO TODO (sunzenshen): the dropping player's sound pieces stop here; the next owner hears the resume's own + // pieces only (sound rule: no tap) + if (m_nReloadPhase >= RELOAD_PHASE_LOADED && FindResumeSequence()) + { + return; + } + m_nReloadPhase = RELOAD_PHASE_NONE; m_nReloadTable = -1; } @@ -741,8 +876,11 @@ void CNEOBaseCombatWeapon::FinishReload(void) // If I use primary clips, reload primary if (UsesClipsForAmmo1()) { - int primary = MIN(GetMaxClip1(), m_iPrimaryAmmoCount); - m_iClip1 = primary; + // sketch-zr68c-full (master code the MVP touches): a chambered round stays, 30+1 (U2). Without a chamber + // slot IsRoundChambered() is false and this is master's fill + const int iChambered = IsRoundChambered() ? 1 : 0; + int primary = MIN(MagazineCapacity(), m_iPrimaryAmmoCount); + m_iClip1 = iChambered + primary; m_iPrimaryAmmoCount -= primary; } @@ -1285,6 +1423,16 @@ void CNEOBaseCombatWeapon::PrimaryAttack(void) return; } + // sketch-zr68c-full: a magazine is in but the chamber is empty (a reload interrupted after 2_load whose resume was + // lost, such as a model without resume_after_2_load_empty) + // NEO TODO (sunzenshen): Reload() refuses here (29+1 gate and clip >= max): allow a dry reload with a full magazine + // and an empty chamber (U4 option (b)) as the fallback, or chamber silently (option (c)). Today the gun is stuck + else if (HasChamberSlot() && m_bChamberEmpty && m_iClip1 > 0) + { + CheckReload(); + return; + } + else if (m_iClip1 == 0) { if (!m_bFireOnEmpty) @@ -1387,6 +1535,12 @@ void CNEOBaseCombatWeapon::PrimaryAttack(void) { info.m_iShots = MIN(info.m_iShots, m_iClip1); m_iClip1 -= info.m_iShots; + + // sketch-zr68c-full: the last round leaves the chamber empty, so the next reload is the dry one with the cycle + if (HasChamberSlot() && m_iClip1 <= 0) + { + m_bChamberEmpty = true; + } } else { diff --git a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h index 77efdc22b2..b815468c35 100644 --- a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h +++ b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h @@ -265,6 +265,13 @@ class CNEOBaseCombatWeapon : public CBaseHL2MPCombatWeapon virtual float GetFireRate() override final; float GetPenetration() const; void StopReloadOnDrop(); + + // sketch-zr68c-full: chamber model (old slice ad3749afb). The clip counts the chambered round, so a full + // ZR68C holds GetMaxClip1() + 1; the HUD shows it as "30+1/30" + bool HasChamberSlot() const; + bool IsRoundChambered() const; + int RoundsInMagazine() const; + int MagazineCapacity() const; #ifdef CLIENT_DLL float m_flTemperature; int m_spawnflags; @@ -307,6 +314,9 @@ class CNEOBaseCombatWeapon : public CBaseHL2MPCombatWeapon CNetworkVar(float, m_flReloadStart); // the sound pieces of the playing sequence already started, one bit per piece CNetworkVar(int, m_nReloadSoundsDone); + // sketch-zr68c-full: the last shot left the chamber empty; only a 3_cycle clears it. No m_bReloadDry as in the + // old slice: the chamber cannot change during a reload, so this flag already tells dry from live + CNetworkVar(bool, m_bChamberEmpty); private: CNEOBaseCombatWeapon(const CNEOBaseCombatWeapon &other); @@ -317,6 +327,10 @@ class CNEOBaseCombatWeapon : public CBaseHL2MPCombatWeapon void FinishReloadPhase(ReloadPhase_t phase); const char *FindResumeSequence() const; bool ResumeReload(); + // sketch-zr68c-full: factored out of the MVP's ResumeReload, shared with the fresh partial reload + bool PlayReloadSequence(const char *pszName, int iTable, float flGestureCycle); + bool StartPartialReload(); + float ResumeGestureCycle() const; void StopReloadSoundPieces(); void EmitReloadSoundPiece(const char *pszSound); CBaseViewModel *ReloadViewModel() const; From 5e3aae0e680a3e82890bb37e4020992a0f848698 Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sat, 7 Nov 2026 21:22:14 -0700 Subject: [PATCH 15/55] Sketch the resumed reload gesture start point Port the old slice's gesture start cycle (U5): a resumed reload starts the third-person reload gesture where the reload resumed. RELOAD_END on a cut-short reload is not ported. --- .../shared/hl2mp/hl2mp_playeranimstate.cpp | 28 +++++++++++++++++++ src/game/shared/hl2mp/hl2mp_playeranimstate.h | 1 + 2 files changed, 29 insertions(+) diff --git a/src/game/shared/hl2mp/hl2mp_playeranimstate.cpp b/src/game/shared/hl2mp/hl2mp_playeranimstate.cpp index 9e441acd87..b3bd548857 100644 --- a/src/game/shared/hl2mp/hl2mp_playeranimstate.cpp +++ b/src/game/shared/hl2mp/hl2mp_playeranimstate.cpp @@ -343,6 +343,13 @@ void CHL2MPPlayerAnimState::DoAnimationEvent( PlayerAnimEvent_t event, int nData { #ifdef NEO AddToGestureSlot(GESTURE_SLOT_ATTACK_AND_RELOAD, CalcReloadSequence(), true); + // a resumed reload starts the gesture where the reload resumes: nData is that cycle x 1000 + // (sketch-zr68c-full, U5: ported from the old slice reload-zr68c; RELOAD_END on a cut-short reload not ported, + // NEO TODO (sunzenshen): decide whether a switch should stop the third-person gesture) + if (nData > 0) + { + SetGestureSlotCycle(GESTURE_SLOT_ATTACK_AND_RELOAD, nData / 1000.0f); + } #else // Weapon reload. if ( GetBasePlayer()->GetFlags() & FL_DUCKING ) @@ -1013,3 +1020,24 @@ void CHL2MPPlayerAnimState::DebugShowAnimStateFull(int iStartLine) AnimStateLog("--------------------------------------------\n\n"); } + +#ifdef NEO +// Start a gesture part way through its sequence, as AddVCDSequenceToGestureSlot does for scene gestures +void CHL2MPPlayerAnimState::SetGestureSlotCycle(int iGestureSlot, float flCycle) +{ + GestureSlot_t &slot = m_aGestureSlots[iGestureSlot]; + if (!slot.m_pAnimLayer) + { + return; + } + + slot.m_pAnimLayer->m_flCycle = flCycle; + slot.m_pAnimLayer->m_flPrevCycle = flCycle; +#ifdef CLIENT_DLL + if (CBasePlayer *pPlayer = GetBasePlayer()) + { + pPlayer->m_flOverlayPrevEventCycle[iGestureSlot] = flCycle; + } +#endif +} +#endif // NEO diff --git a/src/game/shared/hl2mp/hl2mp_playeranimstate.h b/src/game/shared/hl2mp/hl2mp_playeranimstate.h index 9a05125539..0ef11f0281 100644 --- a/src/game/shared/hl2mp/hl2mp_playeranimstate.h +++ b/src/game/shared/hl2mp/hl2mp_playeranimstate.h @@ -64,6 +64,7 @@ class CHL2MPPlayerAnimState : public CMultiPlayerAnimState #ifdef NEO bool IsLeaning(CStudioHdr *pStudioHdr); + void SetGestureSlotCycle(int iGestureSlot, float flCycle); #endif // NEO CHL2MP_Player *m_pHL2MPPlayer; From 50777a47913cbc0afeddb83f4112c06bd951348e Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sat, 7 Nov 2026 21:22:14 -0700 Subject: [PATCH 16/55] Sketch the chambered round on the ammo HUD Port the old slice's 30+1 count and the fire-mode glyph's chamber icon, guarded by HasChamberSlot. --- src/game/client/neo/ui/neo_hud_ammo.cpp | 65 ++++++++++++++++++++++--- src/game/client/neo/ui/neo_hud_ammo.h | 1 + 2 files changed, 60 insertions(+), 6 deletions(-) diff --git a/src/game/client/neo/ui/neo_hud_ammo.cpp b/src/game/client/neo/ui/neo_hud_ammo.cpp index 771efb2554..dfe4a0fc05 100644 --- a/src/game/client/neo/ui/neo_hud_ammo.cpp +++ b/src/game/client/neo/ui/neo_hud_ammo.cpp @@ -6,6 +6,9 @@ #include "iclientmode.h" #include #include +#include +#include "VGuiMatSurface/IMatSystemSurface.h" +#include "cdll_client_int.h" #include #include #include @@ -160,16 +163,19 @@ void CNEOHud_Ammo::DrawAmmo() const } const char* ammoChar = nullptr; + int fireModeWidth = 0, fireModeHeight = 0; int magSizeMax = 0; int magSizeCurrent = 0; + // a gun with a chamber counts the magazine in the row, and the round icon of the fire-mode glyph shows the chamber + const bool hasChamber = activeWep->HasChamberSlot(); if ((activeWep->UsesClipsForAmmo1() && !(activeWep->GetNeoWepBits() & NEO_WEP_THROWABLE)) || (activeWep->GetNeoWepBits() & NEO_WEP_BALC)) { char fireModeText[2]{ '\0' }; ammoChar = activeWep->GetNEOWpnData().szBulletCharacter; - magSizeMax = activeWep->GetMaxClip1(); - magSizeCurrent = activeWep->Clip1(); + magSizeMax = hasChamber ? activeWep->MagazineCapacity() : activeWep->GetMaxClip1(); + magSizeCurrent = hasChamber ? activeWep->RoundsInMagazine() : activeWep->Clip1(); if(activeWep) { @@ -188,8 +194,16 @@ void CNEOHud_Ammo::DrawAmmo() const g_pVGuiLocalize->ConvertANSIToUnicode(fireModeText, unicodeFireModeText, sizeof(unicodeFireModeText)); surface()->DrawSetTextFont(m_hFireModeFont); - surface()->DrawSetTextPos(icon_xpos + xpos, icon_ypos + ypos); - surface()->DrawPrintText(unicodeFireModeText, V_wcslen(unicodeFireModeText)); + if (hasChamber) + { + surface()->GetTextSize(m_hFireModeFont, unicodeFireModeText, fireModeWidth, fireModeHeight); + DrawFireModeWithChamber(unicodeFireModeText, fireModeHeight, activeWep->IsRoundChambered()); + } + else + { + surface()->DrawSetTextPos(icon_xpos + xpos, icon_ypos + ypos); + surface()->DrawPrintText(unicodeFireModeText, V_wcslen(unicodeFireModeText)); + } } } else { @@ -216,8 +230,16 @@ void CNEOHud_Ammo::DrawAmmo() const surface()->DrawSetTextFont(m_hBulletFont); surface()->DrawSetTextPos(digit_xpos + xpos, digit_ypos + ypos); wchar_t bullets[22]; - V_swprintf_safe(bullets, L"%i/%i", magSizeCurrent, magSizeMax); - surface()->DrawPrintText(bullets, (int)(magSizeCurrent == 0 ? 1 : log10(magSizeCurrent) + 1) + (int)(log10(magSizeMax) + 1) + 1); + if (hasChamber && activeWep->IsRoundChambered()) + { + V_swprintf_safe(bullets, L"%i+1/%i", magSizeCurrent, magSizeMax); + surface()->DrawPrintText(bullets, V_wcslen(bullets)); + } + else + { + V_swprintf_safe(bullets, L"%i/%i", magSizeCurrent, magSizeMax); + surface()->DrawPrintText(bullets, (int)(magSizeCurrent == 0 ? 1 : log10(magSizeCurrent) + 1) + (int)(log10(magSizeMax) + 1) + 1); + } return; } @@ -290,6 +312,37 @@ void CNEOHud_Ammo::DrawAmmo() const } } +// sketch-zr68c-full: HUD ported unchanged from the old slice (ad3749afb), HasChamberSlot guarded +// The fire-mode glyph's top rows are a round icon (bullet or shell), its letter sits below them +static constexpr float FIRE_MODE_ROUND_ICON_HEIGHT = 0.184f; + +// Draw the fire-mode glyph with its round icon lit while a round is chambered, in the empty color otherwise; +// the letter keeps the text color. Two passes, each clipped to its part of the glyph +void CNEOHud_Ammo::DrawFireModeWithChamber(const wchar_t *pszGlyph, int iGlyphTall, bool bChambered) const +{ + const int iX = icon_xpos + xpos; + const int iY = icon_ypos + ypos; + int iScreenX = 0, iScreenY = 0; + vgui::ipanel()->GetAbsPos(GetVPanel(), iScreenX, iScreenY); + const int iSplitY = iScreenY + iY + static_cast(iGlyphTall * FIRE_MODE_ROUND_ICON_HEIGHT + 0.5f); + + int iLeft, iTop, iRight, iBottom; + bool bClippingDisabled; + g_pMatSystemSurface->GetClippingRect(iLeft, iTop, iRight, iBottom, bClippingDisabled); + + g_pMatSystemSurface->SetClippingRect(iLeft, iTop, iRight, Min(iBottom, iSplitY)); + surface()->DrawSetTextColor(bChambered ? ammo_color : emptied_ammo_color); + surface()->DrawSetTextPos(iX, iY); + surface()->DrawPrintText(pszGlyph, V_wcslen(pszGlyph)); + + g_pMatSystemSurface->SetClippingRect(iLeft, Max(iTop, iSplitY), iRight, iBottom); + surface()->DrawSetTextColor(ammo_text_color); + surface()->DrawSetTextPos(iX, iY); + surface()->DrawPrintText(pszGlyph, V_wcslen(pszGlyph)); + + g_pMatSystemSurface->SetClippingRect(iLeft, iTop, iRight, iBottom); +} + void CNEOHud_Ammo::DrawNeoHudElement() { auto *localPlayer = C_NEO_Player::GetLocalNEOPlayer(); diff --git a/src/game/client/neo/ui/neo_hud_ammo.h b/src/game/client/neo/ui/neo_hud_ammo.h index 069561e11c..637d663457 100644 --- a/src/game/client/neo/ui/neo_hud_ammo.h +++ b/src/game/client/neo/ui/neo_hud_ammo.h @@ -27,6 +27,7 @@ class CNEOHud_Ammo : public CNEOHud_ChildElement, public CHudElement, public vgu private: void DrawAmmo() const; + void DrawFireModeWithChamber(const wchar_t *pszGlyph, int iGlyphTall, bool bChambered) const; void DrawHeatMeter(C_NEOBaseCombatWeapon* activeWep) const; private: From b27d3aed5db2a2a7c08da573959844d84fd0bc9c Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sat, 7 Nov 2026 21:45:11 -0700 Subject: [PATCH 17/55] Stub the open reload TODOs as comments --- game/neo/scripts/weapon_zr68c.txt | 2 ++ src/game/client/neo/ui/neo_hud_ammo.cpp | 1 + src/game/server/neo/bot/neo_bot.cpp | 2 ++ .../shared/neo/weapons/weapon_neobasecombatweapon.cpp | 9 +++++++-- 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/game/neo/scripts/weapon_zr68c.txt b/game/neo/scripts/weapon_zr68c.txt index 0d1519cf40..1752457601 100644 --- a/game/neo/scripts/weapon_zr68c.txt +++ b/game/neo/scripts/weapon_zr68c.txt @@ -1,4 +1,6 @@ #base "weapon_zr68c_reload_phases.txt" +// NEO TODO (sunzenshen): Full slice: 3 transitions to author (rows 2, 3, 5 of the combinatorics), unload sound piece, markers 1_unload.sound, +// 2_load.exit, 2_load.join; ChamberedRound key and 29+1 spawn; see the plan's Open TODO list. // ZR68S diff --git a/src/game/client/neo/ui/neo_hud_ammo.cpp b/src/game/client/neo/ui/neo_hud_ammo.cpp index dfe4a0fc05..e8d0b8f773 100644 --- a/src/game/client/neo/ui/neo_hud_ammo.cpp +++ b/src/game/client/neo/ui/neo_hud_ammo.cpp @@ -166,6 +166,7 @@ void CNEOHud_Ammo::DrawAmmo() const int fireModeWidth = 0, fireModeHeight = 0; int magSizeMax = 0; int magSizeCurrent = 0; + // NEO TODO (sunzenshen): client tests for the 30+1/30 row and the chamber glyph (fresh, after tactical reload, after drop). // a gun with a chamber counts the magazine in the row, and the round icon of the fire-mode glyph shows the chamber const bool hasChamber = activeWep->HasChamberSlot(); diff --git a/src/game/server/neo/bot/neo_bot.cpp b/src/game/server/neo/bot/neo_bot.cpp index 7d1c1e2ef8..d9c37498c5 100644 --- a/src/game/server/neo/bot/neo_bot.cpp +++ b/src/game/server/neo/bot/neo_bot.cpp @@ -1813,6 +1813,8 @@ void CNEOBot::ReloadIfLowClip(bool bForceReload) return; } + // NEO TODO (sunzenshen): with a chamber slot 30 of 31 counts as full here, and 29+1 (clip 30) never reloads by bot + // logic. Accepted for now; revisit the threshold later. if (myWeapon->Clip1() >= myWeapon->GetMaxClip1()) { return; diff --git a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp index 917e032e92..c7ee8bebaf 100644 --- a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp +++ b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp @@ -265,8 +265,8 @@ CNEOBaseCombatWeapon::CNEOBaseCombatWeapon( void ) m_nReloadTable = -1; m_flReloadStart = 0.0f; m_nReloadSoundsDone = 0; - // NEO TODO (sunzenshen): sketch-zr68c-full. A fresh gun spawns with 30 = 29+1 here; should it spawn 30+1 (clip - // GetMaxClip1() + 1)? Open question for the user, it changes the ZR68C's spawn ammo + // NEO TODO (sunzenshen): a fresh gun spawns 29+1 (user decision 2026-11-07); the +1 appears only after a tactical + // reload, so do not raise the spawn ammo here. m_bChamberEmpty = false; } @@ -453,6 +453,8 @@ void CNEOBaseCombatWeapon::Equip(CBaseCombatCharacter* pOwner) } +// NEO TODO (sunzenshen): Chamber model: a tactical reload (clip < max + 1) plays reload_partial, no cycle, 30+1. Dry-reload fallback for a +// lost resume is still open; spawn ammo stays 29+1 (user decision 2026-11-07). bool CNEOBaseCombatWeapon::Reload( void ) { // sketch-zr68c-full (MVP Reload(), new lines before its first statement): a reload with a round chambered keeps it @@ -608,6 +610,7 @@ void CNEOBaseCombatWeapon::RunReloadPhases() } } +// NEO TODO (sunzenshen): RELOAD_END: stop the third-person reload gesture on a cut-short reload (U5b); not decided. void CNEOBaseCombatWeapon::FinishReloadPhase(ReloadPhase_t phase) { // The unload takes no rounds: they are lost only if a switch interrupts the reload after it (ResumeReload), @@ -804,6 +807,8 @@ void CNEOBaseCombatWeapon::StopReloadSoundPieces() } // A dropped weapon cancels its reload: the next owner does not resume it +// NEO TODO (sunzenshen): Fallback for a lost resume (full magazine, empty chamber): Reload() must then play the dry reload (user decision +// 2026-11-07); this function keeps the phase and table at >= 2_load but a lost resume is not handled yet. void CNEOBaseCombatWeapon::StopReloadOnDrop() { if (!IsReloadPhaseSystemEnabled()) From 063ca0f03e9c42131c67cdc6c6d8600d047bb354 Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sat, 7 Nov 2026 23:41:00 -0700 Subject: [PATCH 18/55] Rename the fresh tactical reload sequence The user renamed the slice's clips after the shipped lowtoidle pattern: reload_reloadexit is now reload_loadedtoidle. --- src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp index 7b548b5765..89b42a30d3 100644 --- a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp +++ b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp @@ -673,7 +673,7 @@ bool CNEOBaseCombatWeapon::ResumeReload() // The tactical sequence has no activity; ACT_VM_RELOAD selects the dry reload. bool CNEOBaseCombatWeapon::StartPartialReload() { - static constexpr const char *VM_SEQ_RELOAD_PARTIAL = "reload_reloadexit"; + static constexpr const char *VM_SEQ_RELOAD_PARTIAL = "reload_loadedtoidle"; if (!IsReloadPhaseSystemEnabled() || !IsRoundChambered()) { return false; From 5f7e2bdc8dbfadf8c4d885bd333ed5e9f9f3b991 Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sat, 7 Nov 2026 23:41:30 -0700 Subject: [PATCH 19/55] Name the fresh tactical reload reload_skipcycle The user chose skipcycle for the clip that returns to idle without the bolt pull: it says why the clip exists. --- src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp index 89b42a30d3..eb3e144e59 100644 --- a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp +++ b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp @@ -673,7 +673,7 @@ bool CNEOBaseCombatWeapon::ResumeReload() // The tactical sequence has no activity; ACT_VM_RELOAD selects the dry reload. bool CNEOBaseCombatWeapon::StartPartialReload() { - static constexpr const char *VM_SEQ_RELOAD_PARTIAL = "reload_loadedtoidle"; + static constexpr const char *VM_SEQ_RELOAD_PARTIAL = "reload_skipcycle"; if (!IsReloadPhaseSystemEnabled() || !IsRoundChambered()) { return false; From 3588355aa4195f2f96c445113e1f94956192cd65 Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sat, 7 Nov 2026 23:50:21 -0700 Subject: [PATCH 20/55] Store reload tables only for weapons that have them CNEOWeaponInfo held 12 fixed reload phase tables, 9 KB in every weapon script whether or not it defines a ReloadPhases block. Keep them in a CUtlVector, so a weapon without phases pays for an empty vector: sizeof(CNEOWeaponInfo) drops from 11216 to 2032 bytes. The table cap stays, so the networked table index still fits its bits. The viewmodel copied the whole weapon info each frame to read four offsets; read it by reference, which the vector's copy rules need. --- src/game/shared/neo/neo_predicted_viewmodel.cpp | 2 +- src/game/shared/neo/weapons/neo_weapon_parse.cpp | 9 ++++----- src/game/shared/neo/weapons/neo_weapon_parse.h | 5 +++-- .../shared/neo/weapons/weapon_neobasecombatweapon.cpp | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/game/shared/neo/neo_predicted_viewmodel.cpp b/src/game/shared/neo/neo_predicted_viewmodel.cpp index fd2ff5bed0..4349c215d3 100644 --- a/src/game/shared/neo/neo_predicted_viewmodel.cpp +++ b/src/game/shared/neo/neo_predicted_viewmodel.cpp @@ -487,7 +487,7 @@ void CNEOPredictedViewModel::CalcViewModelView(CBasePlayer *pOwner, return; } - CNEOWeaponInfo data = weapon->GetNEOWpnData(); + const 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 index 77872fa0eb..eee8e991f1 100644 --- a/src/game/shared/neo/weapons/neo_weapon_parse.cpp +++ b/src/game/shared/neo/weapons/neo_weapon_parse.cpp @@ -24,7 +24,6 @@ CNEOWeaponInfo::CNEOWeaponInfo() m_flPenetration = 0.f; m_bDropOnDeath = true; iAimFOV = 0; - m_iNumReloadTables = 0; m_flVMFov = m_flVMAimFov = 0.f; m_vecVMPosOffset = m_vecVMAimPosOffset = vec3_origin; @@ -54,7 +53,7 @@ static ReloadPhase_t ReloadPhaseFromName(const char *pszName) // "ReloadPhases" { "" { "" { "ammo" "s" "sound" "s" "sound_name" "name" "resume" "sequence" } ... } ... } void CNEOWeaponInfo::ParseReloadPhases(KeyValues *pBlock) { - m_iNumReloadTables = 0; + m_reloadTables.Purge(); if (!pBlock) { return; @@ -66,9 +65,9 @@ void CNEOWeaponInfo::ParseReloadPhases(KeyValues *pBlock) return; } - for (KeyValues *pSeq = pBlock->GetFirstTrueSubKey(); pSeq && m_iNumReloadTables < RELOAD_PHASE_TABLES_MAX; pSeq = pSeq->GetNextTrueSubKey()) + for (KeyValues *pSeq = pBlock->GetFirstTrueSubKey(); pSeq && m_reloadTables.Count() < RELOAD_PHASE_TABLES_MAX; pSeq = pSeq->GetNextTrueSubKey()) { - ReloadPhaseTable_t &table = m_reloadTables[m_iNumReloadTables++]; + ReloadPhaseTable_t &table = m_reloadTables[m_reloadTables.AddToTail()]; V_strncpy(table.szSequence, pSeq->GetName(), sizeof(table.szSequence)); table.iNumRows = 0; @@ -96,7 +95,7 @@ void CNEOWeaponInfo::ParseReloadPhases(KeyValues *pBlock) int CNEOWeaponInfo::FindReloadTable(const char *pszSequence) const { - for (int i = 0; i < m_iNumReloadTables; ++i) + for (int i = 0; i < m_reloadTables.Count(); ++i) { if (V_stricmp(m_reloadTables[i].szSequence, pszSequence) == 0) { diff --git a/src/game/shared/neo/weapons/neo_weapon_parse.h b/src/game/shared/neo/weapons/neo_weapon_parse.h index dc10c7d7ca..8decaa120e 100644 --- a/src/game/shared/neo/weapons/neo_weapon_parse.h +++ b/src/game/shared/neo/weapons/neo_weapon_parse.h @@ -11,6 +11,7 @@ #endif #include "hl2mp_weapon_parse.h" +#include "utlvector.h" // A reload is a linear sequence of phases; a reload sequence finishes each phase at a point of its animation enum ReloadPhase_t @@ -73,8 +74,8 @@ class CNEOWeaponInfo : public CHL2MPSWeaponInfo int m_iBullets; float m_flCycleTime; float m_flReloadReadyBeforeEnd; - int m_iNumReloadTables; // 0: the weapon reloads without phases - ReloadPhaseTable_t m_reloadTables[RELOAD_PHASE_TABLES_MAX]; + // Empty: the weapon reloads without phases. Allocated only for scripts with a ReloadPhases block. + CUtlVector m_reloadTables; char szViewModel2[MAX_WEAPON_STRING]; // Team 2 (NSF) wep vm char szBulletCharacter[MAX_BULLET_CHARACTER];// character used to display ammunition in current clip char szDeathIcon[MAX_BULLET_CHARACTER]; diff --git a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp index a314fde42f..5513ec2e85 100644 --- a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp +++ b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp @@ -512,7 +512,7 @@ static constexpr float RELOAD_SOUND_LEAD = 0.02f; bool CNEOBaseCombatWeapon::IsReloadPhaseSystemEnabled() const { - return m_bReloadExperimentalEnabled && GetNEOWpnData().m_iNumReloadTables > 0; + return m_bReloadExperimentalEnabled && !GetNEOWpnData().m_reloadTables.IsEmpty(); } // The viewmodel sequence that resumes the reload interrupted now, from the phase table of the playing sequence; From 86f7fc6e7d93dc54b74561924d83ca14a438166d Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sat, 7 Nov 2026 23:51:48 -0700 Subject: [PATCH 21/55] Read the experimental reload flag once per map Each weapon sampled sv_neo_reload_experimental when created and networked its own copy. Latch the cvar once when the map's game rules are created and network it on CNEORules, so every weapon and the client's prediction read one value, and weapons no longer carry the bool. A change to the cvar now applies from the next map. --- src/game/shared/neo/neo_gamerules.cpp | 9 +++++++++ src/game/shared/neo/neo_gamerules.h | 2 ++ .../shared/neo/weapons/weapon_neobasecombatweapon.cpp | 11 +++-------- .../shared/neo/weapons/weapon_neobasecombatweapon.h | 3 --- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/game/shared/neo/neo_gamerules.cpp b/src/game/shared/neo/neo_gamerules.cpp index 38e7155f74..45fceb7356 100644 --- a/src/game/shared/neo/neo_gamerules.cpp +++ b/src/game/shared/neo/neo_gamerules.cpp @@ -42,6 +42,7 @@ #include extern ConVar weaponstay; +extern ConVar sv_neo_reload_experimental; #endif ConVar sv_neo_loopback_warmup_round("sv_neo_loopback_warmup_round", "0", FCVAR_REPLICATED, "Allow loopback server to do warmup rounds.", true, 0.0f, true, 1.0f); @@ -306,6 +307,7 @@ BEGIN_NETWORK_TABLE_NOBASE( CNEORules, DT_NEORules ) RecvPropInt(RECVINFO(m_iForcedSkin)), RecvPropInt(RECVINFO(m_iForcedWeapon)), RecvPropBool(RECVINFO(m_bCyberspaceLevel)), + RecvPropBool(RECVINFO(m_bReloadExperimental)), RecvPropString(RECVINFO(m_szNeoJinraiClantag)), RecvPropString(RECVINFO(m_szNeoNSFClantag)), RecvPropInt(RECVINFO(m_iGhosterTeam)), @@ -349,6 +351,7 @@ BEGIN_NETWORK_TABLE_NOBASE( CNEORules, DT_NEORules ) SendPropInt(SENDINFO(m_iForcedSkin)), SendPropInt(SENDINFO(m_iForcedWeapon)), SendPropBool(SENDINFO(m_bCyberspaceLevel)), + SendPropBool(SENDINFO(m_bReloadExperimental)), SendPropString(SENDINFO(m_szNeoJinraiClantag)), SendPropString(SENDINFO(m_szNeoNSFClantag)), SendPropInt(SENDINFO(m_iGhosterTeam), NumBitsForCount(TEAM__TOTAL), SPROP_UNSIGNED), @@ -705,6 +708,12 @@ CNEORules::CNEORules() m_iForcedSkin = -1; m_iForcedWeapon = -1; m_bCyberspaceLevel = false; +#ifdef GAME_DLL + // Read once per map so that every weapon, and the client's prediction of it, sees one value for the whole map + m_bReloadExperimental = sv_neo_reload_experimental.GetBool(); +#else + m_bReloadExperimental = false; +#endif m_iClassLimitRecon = -1; m_iClassLimitAssault = -1; diff --git a/src/game/shared/neo/neo_gamerules.h b/src/game/shared/neo/neo_gamerules.h index 1bdee613ae..32e789c521 100644 --- a/src/game/shared/neo/neo_gamerules.h +++ b/src/game/shared/neo/neo_gamerules.h @@ -244,6 +244,7 @@ class CNEORules : public CHL2MPRules, public CGameEventListener int GetForcedSkin(); int GetForcedWeapon(); bool IsCyberspace(); + bool IsReloadExperimental() const { return m_bReloadExperimental; } virtual const char* GetGameTypeName(void) OVERRIDE; bool CanChangeTeamClassLoadoutWhenAlive(); bool CanRespawnAnyTime(); @@ -555,6 +556,7 @@ class CNEORules : public CHL2MPRules, public CGameEventListener CNetworkVar(int, m_iForcedSkin); CNetworkVar(int, m_iForcedWeapon); CNetworkVar(bool, m_bCyberspaceLevel); + CNetworkVar(bool, m_bReloadExperimental); CNetworkVar(int, m_nGameTypeSelected); CNetworkVar(int, m_iRoundNumber); CNetworkVar(bool, m_bIsMatchPoint); diff --git a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp index 5513ec2e85..0a944ab5dd 100644 --- a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp +++ b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp @@ -22,10 +22,10 @@ extern ConVar weaponstay; #include "in_main.h" #else #include "items.h" -#include "neo_gamerules.h" #endif // CLIENT_DLL #include "basecombatweapon_shared.h" +#include "neo_gamerules.h" #include @@ -42,7 +42,6 @@ BEGIN_NETWORK_TABLE( CNEOBaseCombatWeapon, DT_NEOBaseCombatWeapon ) RecvPropInt(RECVINFO(m_nNumShotsFired)), RecvPropBool(RECVINFO(m_bTriggerReset)), RecvPropTime(RECVINFO(m_flReloadReadyTime)), - RecvPropBool(RECVINFO(m_bReloadExperimentalEnabled)), RecvPropInt(RECVINFO(m_nReloadPhase)), RecvPropInt(RECVINFO(m_nReloadTable)), RecvPropTime(RECVINFO(m_flReloadStart)), @@ -55,7 +54,6 @@ BEGIN_NETWORK_TABLE( CNEOBaseCombatWeapon, DT_NEOBaseCombatWeapon ) SendPropInt(SENDINFO(m_nNumShotsFired)), SendPropBool(SENDINFO(m_bTriggerReset)), SendPropTime(SENDINFO(m_flReloadReadyTime)), - SendPropBool(SENDINFO(m_bReloadExperimentalEnabled)), SendPropInt(SENDINFO(m_nReloadPhase), RELOAD_PHASE_BITS, SPROP_UNSIGNED), SendPropInt(SENDINFO(m_nReloadTable), RELOAD_PHASE_TABLE_BITS), SendPropTime(SENDINFO(m_flReloadStart)), @@ -73,7 +71,6 @@ BEGIN_PREDICTION_DATA(CNEOBaseCombatWeapon) DEFINE_PRED_FIELD(m_nNumShotsFired, FIELD_INTEGER, FTYPEDESC_INSENDTABLE), DEFINE_PRED_FIELD(m_bTriggerReset, FIELD_BOOLEAN, FTYPEDESC_INSENDTABLE), DEFINE_PRED_FIELD(m_flReloadReadyTime, FIELD_FLOAT, FTYPEDESC_INSENDTABLE), - DEFINE_PRED_FIELD(m_bReloadExperimentalEnabled, FIELD_BOOLEAN, FTYPEDESC_INSENDTABLE), DEFINE_PRED_FIELD(m_nReloadPhase, FIELD_INTEGER, FTYPEDESC_INSENDTABLE), DEFINE_PRED_FIELD(m_nReloadTable, FIELD_INTEGER, FTYPEDESC_INSENDTABLE), DEFINE_PRED_FIELD(m_flReloadStart, FIELD_FLOAT, FTYPEDESC_INSENDTABLE), @@ -91,7 +88,6 @@ BEGIN_DATADESC( CNEOBaseCombatWeapon ) DEFINE_FIELD(m_nNumShotsFired, FIELD_INTEGER), DEFINE_FIELD(m_bTriggerReset, FIELD_BOOLEAN), DEFINE_FIELD(m_flReloadReadyTime, FIELD_TIME), - DEFINE_FIELD(m_bReloadExperimentalEnabled, FIELD_BOOLEAN), DEFINE_FIELD(m_nReloadPhase, FIELD_INTEGER), DEFINE_FIELD(m_nReloadTable, FIELD_INTEGER), DEFINE_FIELD(m_flReloadStart, FIELD_TIME), @@ -102,7 +98,7 @@ END_DATADESC() ConVar sv_neo_accuracy_penalty_scale("sv_neo_accuracy_penalty_scale", "1.0", FCVAR_REPLICATED, "Scales the accuracy penalty per shot.", true, 0.0f, true, 2.0f); ConVar sv_neo_dynamic_viewkick("sv_neo_dynamic_viewkick", "0", FCVAR_REPLICATED, "Enables view kick scaling based on current inaccuracy.", true, 0.0f, true, 1.0f); ConVar sv_neo_reload_experimental("sv_neo_reload_experimental", "0", FCVAR_REPLICATED, - "Lets a switch interrupt a reload after the magazine is out, for weapons that define reload phases. Set before the map loads.", + "Lets a switch interrupt a reload after the magazine is out, for weapons that define reload phases. A change applies from the next map.", true, 0.0f, true, 1.0f); const char *GetWeaponByLoadoutId(int id) @@ -255,7 +251,6 @@ static const WeaponHandlingInfo_t handlingTable[] = { CNEOBaseCombatWeapon::CNEOBaseCombatWeapon( void ) { - m_bReloadExperimentalEnabled = sv_neo_reload_experimental.GetBool(); m_bTriggerReset = true; m_nReloadPhase = RELOAD_PHASE_NONE; m_nReloadTable = -1; @@ -512,7 +507,7 @@ static constexpr float RELOAD_SOUND_LEAD = 0.02f; bool CNEOBaseCombatWeapon::IsReloadPhaseSystemEnabled() const { - return m_bReloadExperimentalEnabled && !GetNEOWpnData().m_reloadTables.IsEmpty(); + return NEORules() && NEORules()->IsReloadExperimental() && !GetNEOWpnData().m_reloadTables.IsEmpty(); } // The viewmodel sequence that resumes the reload interrupted now, from the phase table of the playing sequence; diff --git a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h index 77efdc22b2..9c1bdd2ee7 100644 --- a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h +++ b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h @@ -296,9 +296,6 @@ class CNEOBaseCombatWeapon : public CBaseHL2MPCombatWeapon // When the reload in progress loads the magazine, 0 once it is loaded CNetworkVar(float, m_flReloadReadyTime); - // The server's pre-game reload setting, snapshotted for prediction - CNetworkVar(bool, m_bReloadExperimentalEnabled); - // Reload phases (weapons whose script has a ReloadPhases block): the last phase finished, kept across a switch CNetworkVar(int, m_nReloadPhase); // the phase table of the reload sequence started last, -1 none From cf3c7189309964798f302ddd47a292b1bfb449ee Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sun, 8 Nov 2026 09:12:34 -0700 Subject: [PATCH 22/55] Fit the reload gesture to partial reloads A reload sequence played by name now sends its first-person length with the third-person reload event. A gesture longer than that reload plays only its start for a fresh partial reload, or only its end for a reload resumed in the draw, blending in or out over 0.2 s. The event also adopts the new active weapon, so the weapon-change reset no longer drops a reload that the draw resumes. Reloads that play their activity send no data and keep the whole gesture. --- .../shared/hl2mp/hl2mp_playeranimstate.cpp | 108 +++++++++++++++++- src/game/shared/hl2mp/hl2mp_playeranimstate.h | 20 ++++ .../weapons/weapon_neobasecombatweapon.cpp | 47 ++------ .../neo/weapons/weapon_neobasecombatweapon.h | 3 +- 4 files changed, 132 insertions(+), 46 deletions(-) diff --git a/src/game/shared/hl2mp/hl2mp_playeranimstate.cpp b/src/game/shared/hl2mp/hl2mp_playeranimstate.cpp index ca1ddd8b58..426777a0c7 100644 --- a/src/game/shared/hl2mp/hl2mp_playeranimstate.cpp +++ b/src/game/shared/hl2mp/hl2mp_playeranimstate.cpp @@ -80,6 +80,11 @@ CHL2MPPlayerAnimState* CreateHL2MPPlayerAnimState( CHL2MP_Player *pPlayer ) CHL2MPPlayerAnimState::CHL2MPPlayerAnimState() { m_pHL2MPPlayer = NULL; +#ifdef NEO + m_iReloadGestureSequence = -1; + m_flReloadGestureStartCycle = 0.0f; + m_flReloadGestureEndCycle = 1.0f; +#endif // Don't initialize HL2MP specific variables here. Init them in InitHL2MPAnimState() } @@ -93,6 +98,11 @@ CHL2MPPlayerAnimState::CHL2MPPlayerAnimState( CBasePlayer *pPlayer, MultiPlayerM : CMultiPlayerAnimState( pPlayer, movementData ) { m_pHL2MPPlayer = NULL; +#ifdef NEO + m_iReloadGestureSequence = -1; + m_flReloadGestureStartCycle = 0.0f; + m_flReloadGestureEndCycle = 1.0f; +#endif // Don't initialize HL2MP specific variables here. Init them in InitHL2MPAnimState() } @@ -182,6 +192,7 @@ void CHL2MPPlayerAnimState::ComputeSequences(CStudioHdr* pStudioHdr) // The groundspeed interpolator uses the main sequence info. UpdateInterpolators(); ComputeGestureSequence(pStudioHdr); + UpdateReloadGesture(); } #endif //NEO @@ -343,11 +354,7 @@ void CHL2MPPlayerAnimState::DoAnimationEvent( PlayerAnimEvent_t event, int nData { #ifdef NEO AddToGestureSlot(GESTURE_SLOT_ATTACK_AND_RELOAD, CalcReloadSequence(), true); - // a resumed reload starts the gesture where the reload resumes: nData is that cycle x 1000 - if (nData > 0) - { - SetGestureSlotCycle(GESTURE_SLOT_ATTACK_AND_RELOAD, nData / 1000.0f); - } + StartReloadGesture(nData); #else // Weapon reload. if ( GetBasePlayer()->GetFlags() & FL_DUCKING ) @@ -1038,4 +1045,95 @@ void CHL2MPPlayerAnimState::SetGestureSlotCycle(int iGestureSlot, float flCycle) } #endif } + +// The reload event's data: the fit in the low bit, the first-person length in ms above it +static constexpr int RELOAD_GESTURE_KEEP_END_BIT = 1; +static constexpr int RELOAD_GESTURE_FIT_BITS = 1; +static constexpr float RELOAD_GESTURE_MS_PER_SECOND = 1000.0f; + +// The player models' reload gestures have no blend of their own, so a gesture started or ended part way +// blends in or out over this long to hide the jump in pose +static constexpr float RELOAD_GESTURE_BLEND_TIME = 0.2f; + +int CHL2MPPlayerAnimState::PackReloadGestureData(ReloadGestureFit_t fit, float flDuration) +{ + const int iMs = static_cast(Max(flDuration, 0.0f) * RELOAD_GESTURE_MS_PER_SECOND); + return (iMs << RELOAD_GESTURE_FIT_BITS) | ((fit == RELOAD_GESTURE_KEEP_END) ? RELOAD_GESTURE_KEEP_END_BIT : 0); +} + +// Fit the reload gesture just added to a shorter first-person reload: play only its start or only its end, for as +// long as that reload lasts. An event without data plays the whole gesture +void CHL2MPPlayerAnimState::StartReloadGesture(int nData) +{ + m_iReloadGestureSequence = -1; + + CBasePlayer *pPlayer = GetBasePlayer(); + const GestureSlot_t &slot = m_aGestureSlots[GESTURE_SLOT_ATTACK_AND_RELOAD]; + if (nData == 0 || !pPlayer || !slot.m_bActive || !slot.m_pAnimLayer) + { + return; + } + + // A reload resumed by the draw starts with the weapon change, which would otherwise clear the gesture + m_hActiveWeapon = pPlayer->GetActiveWeapon(); + + const int iSequence = slot.m_pAnimLayer->m_nSequence; + const float flDuration = (nData >> RELOAD_GESTURE_FIT_BITS) / RELOAD_GESTURE_MS_PER_SECOND; + const float flCycles = flDuration * pPlayer->GetSequenceCycleRate(pPlayer->GetModelPtr(), iSequence); + if (flDuration <= 0.0f || flCycles >= 1.0f) + { + return; + } + + const bool bKeepEnd = (nData & RELOAD_GESTURE_KEEP_END_BIT) != 0; + m_flReloadGestureStartCycle = bKeepEnd ? 1.0f - flCycles : 0.0f; + m_flReloadGestureEndCycle = bKeepEnd ? 1.0f : flCycles; + m_iReloadGestureSequence = iSequence; + SetGestureSlotCycle(GESTURE_SLOT_ATTACK_AND_RELOAD, m_flReloadGestureStartCycle); +} + +// Blend a fitted reload gesture in from its start cycle and out to its end cycle, then end it there +void CHL2MPPlayerAnimState::UpdateReloadGesture() +{ + if (m_iReloadGestureSequence < 0) + { + return; + } + + CBasePlayer *pPlayer = GetBasePlayer(); + GestureSlot_t &slot = m_aGestureSlots[GESTURE_SLOT_ATTACK_AND_RELOAD]; + if (!pPlayer || !slot.m_bActive || !slot.m_pAnimLayer || slot.m_pAnimLayer->m_nSequence != m_iReloadGestureSequence) + { + // a new gesture took the slot, or the reload gesture ended + m_iReloadGestureSequence = -1; + return; + } + + const float flCycle = slot.m_pAnimLayer->m_flCycle; + if (m_flReloadGestureEndCycle < 1.0f && flCycle >= m_flReloadGestureEndCycle) + { + ResetGestureSlot(GESTURE_SLOT_ATTACK_AND_RELOAD); + m_iReloadGestureSequence = -1; + return; + } + + const float flBlendCycles = RELOAD_GESTURE_BLEND_TIME * pPlayer->GetSequenceCycleRate(pPlayer->GetModelPtr(), m_iReloadGestureSequence); + if (flBlendCycles <= 0.0f) + { + return; + } + + float flWeight = 1.0f; + if (m_flReloadGestureStartCycle > 0.0f) + { + flWeight = Min(flWeight, (flCycle - m_flReloadGestureStartCycle) / flBlendCycles); + } + + if (m_flReloadGestureEndCycle < 1.0f) + { + flWeight = Min(flWeight, (m_flReloadGestureEndCycle - flCycle) / flBlendCycles); + } + + slot.m_pAnimLayer->m_flWeight = clamp(flWeight, 0.0f, 1.0f); +} #endif // NEO diff --git a/src/game/shared/hl2mp/hl2mp_playeranimstate.h b/src/game/shared/hl2mp/hl2mp_playeranimstate.h index 0ef11f0281..0ffaa2a624 100644 --- a/src/game/shared/hl2mp/hl2mp_playeranimstate.h +++ b/src/game/shared/hl2mp/hl2mp_playeranimstate.h @@ -16,6 +16,15 @@ class C_HL2MP_Player; class CHL2MP_Player; #endif +#ifdef NEO +// The part of the third-person reload gesture that a shorter first-person reload shows +enum ReloadGestureFit_t +{ + RELOAD_GESTURE_KEEP_START, // a reload from the start: the gesture ends early + RELOAD_GESTURE_KEEP_END, // a resumed reload: the gesture starts late +}; +#endif + // ------------------------------------------------------------------------------------------------ // // CPlayerAnimState declaration. // ------------------------------------------------------------------------------------------------ // @@ -47,6 +56,9 @@ class CHL2MPPlayerAnimState : public CMultiPlayerAnimState virtual float GetCurrentMaxGroundSpeed(); #ifdef NEO virtual void ComputeSequences(CStudioHdr* pStudioHdr); + + // A reload event's data: how long the first-person reload lasts, and which part of a longer gesture it shows + static int PackReloadGestureData(ReloadGestureFit_t fit, float flDuration); #endif void DebugShowAnimStateFull(int iStartLine); @@ -65,9 +77,17 @@ class CHL2MPPlayerAnimState : public CMultiPlayerAnimState #ifdef NEO bool IsLeaning(CStudioHdr *pStudioHdr); void SetGestureSlotCycle(int iGestureSlot, float flCycle); + void StartReloadGesture(int nData); + void UpdateReloadGesture(); #endif // NEO CHL2MP_Player *m_pHL2MPPlayer; +#ifdef NEO + // The playing reload gesture's sequence (-1: none) and the cycles it blends in from and out to + int m_iReloadGestureSequence; + float m_flReloadGestureStartCycle; + float m_flReloadGestureEndCycle; +#endif #ifndef NEO bool m_bInAirWalk; float m_flHoldDeployedPoseUntilTime; diff --git a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp index eb3e144e59..99023416aa 100644 --- a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp +++ b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp @@ -459,7 +459,7 @@ bool CNEOBaseCombatWeapon::Reload( void ) { static constexpr const char *VM_SEQ_RELOAD_DRY = "reload"; const int iTable = GetNEOWpnData().FindReloadTable(VM_SEQ_RELOAD_DRY); - if (iTable < 0 || !PlayReloadSequence(VM_SEQ_RELOAD_DRY, iTable, 0.0f)) + if (iTable < 0 || !PlayReloadSequence(VM_SEQ_RELOAD_DRY, iTable, RELOAD_GESTURE_KEEP_START)) { return false; } @@ -657,9 +657,6 @@ bool CNEOBaseCombatWeapon::ResumeReload() return false; } - // read from the interrupted table before PlayReloadSequence replaces it - const float flGestureCycle = ResumeGestureCycle(); - // After the unload the old magazine is lost, but a chambered round stays. // After the load the fresh magazine is already in. if (m_nReloadPhase == RELOAD_PHASE_UNLOADED) @@ -667,7 +664,7 @@ bool CNEOBaseCombatWeapon::ResumeReload() m_iClip1 = IsRoundChambered() ? 1 : 0; } - return PlayReloadSequence(pszName, iTable, flGestureCycle); + return PlayReloadSequence(pszName, iTable, RELOAD_GESTURE_KEEP_END); } // The tactical sequence has no activity; ACT_VM_RELOAD selects the dry reload. @@ -691,11 +688,11 @@ bool CNEOBaseCombatWeapon::StartPartialReload() } m_nReloadPhase = RELOAD_PHASE_NONE; - return PlayReloadSequence(VM_SEQ_RELOAD_PARTIAL, iTable, 0.0f); + return PlayReloadSequence(VM_SEQ_RELOAD_PARTIAL, iTable, RELOAD_GESTURE_KEEP_START); } // Named sequences carry no activity, so time their reload phases and gesture explicitly. -bool CNEOBaseCombatWeapon::PlayReloadSequence(const char *pszName, int iTable, float flGestureCycle) +bool CNEOBaseCombatWeapon::PlayReloadSequence(const char *pszName, int iTable, ReloadGestureFit_t gestureFit) { auto *pOwner = ToHL2MPPlayer(GetOwner()); const int iSequence = LookupReloadSequence(pszName); @@ -707,11 +704,12 @@ bool CNEOBaseCombatWeapon::PlayReloadSequence(const char *pszName, int iTable, f SetSequence(iSequence); SendViewModelAnim(iSequence); - // the gesture event carries the start cycle in thousandths (CHL2MPPlayerAnimState::DoAnimationEvent) - pOwner->DoAnimationEvent(PLAYERANIMEVENT_RELOAD, static_cast(flGestureCycle * 1000.0f)); + // the third-person reload gesture lasts no longer than this sequence + const float flDuration = ReloadViewModel()->SequenceDuration(iSequence); + pOwner->DoAnimationEvent(PLAYERANIMEVENT_RELOAD, CHL2MPPlayerAnimState::PackReloadGestureData(gestureFit, flDuration)); // the clip end is the fire point: no ReloadReadyBeforeEnd on this path - const float flEnd = gpGlobals->curtime + ReloadViewModel()->SequenceDuration(iSequence); + const float flEnd = gpGlobals->curtime + flDuration; GetOwner()->SetNextAttack(flEnd); m_flNextPrimaryAttack = m_flNextSecondaryAttack = flEnd; SetWeaponIdleTime(flEnd); @@ -723,35 +721,6 @@ bool CNEOBaseCombatWeapon::PlayReloadSequence(const char *pszName, int iTable, f return true; } -// Where the third-person reload gesture starts for a resume: the interrupted table's ammo time of the last finished -// phase, as a fraction of that table's sequence (0 for anything else) -// NEO TODO (sunzenshen): Map a resume interrupted before its first phase back to the original gesture cycle. -float CNEOBaseCombatWeapon::ResumeGestureCycle() const -{ - if (m_nReloadPhase == RELOAD_PHASE_NONE || m_nReloadTable < 0) - { - return 0.0f; - } - - const ReloadPhaseTable_t &table = GetNEOWpnData().m_reloadTables[m_nReloadTable]; - const int iSequence = LookupReloadSequence(table.szSequence); - CBaseViewModel *pVM = ReloadViewModel(); - const float flDuration = (pVM && iSequence >= 0) ? pVM->SequenceDuration(iSequence) : 0.0f; - if (flDuration <= 0.0f) - { - return 0.0f; - } - - for (int i = 0; i < table.iNumRows; ++i) - { - if (table.rows[i].phase == m_nReloadPhase) - { - return clamp(table.rows[i].flAmmo / flDuration, 0.0f, 1.0f); - } - } - return 0.0f; -} - bool CNEOBaseCombatWeapon::HasChamberSlot() const { return IsReloadPhaseSystemEnabled() && GetNEOWpnData().m_bChamberedRound; diff --git a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h index d3aecd2fe6..b2d56a4826 100644 --- a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h +++ b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h @@ -322,9 +322,8 @@ class CNEOBaseCombatWeapon : public CBaseHL2MPCombatWeapon void FinishReloadPhase(ReloadPhase_t phase); const char *FindResumeSequence() const; bool ResumeReload(); - bool PlayReloadSequence(const char *pszName, int iTable, float flGestureCycle); + bool PlayReloadSequence(const char *pszName, int iTable, ReloadGestureFit_t gestureFit); bool StartPartialReload(); - float ResumeGestureCycle() const; void StopReloadSoundPieces(); void EmitReloadSoundPiece(const char *pszSound); CBaseViewModel *ReloadViewModel() const; From d5e243ff801960481fff3e32a1c451b45a42df7e Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sun, 8 Nov 2026 09:12:34 -0700 Subject: [PATCH 23/55] Keep viewmodel sequences off the world model PlayReloadSequence set the weapon entity's sequence to the viewmodel's index. A client that draws the weapon's world model (third person) then asserts in studio.cpp on every partial or resumed reload. Set the weapon's own sequence only when its model has the named sequence. --- src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp index 99023416aa..0ecaceabac 100644 --- a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp +++ b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp @@ -701,7 +701,12 @@ bool CNEOBaseCombatWeapon::PlayReloadSequence(const char *pszName, int iTable, R return false; } - SetSequence(iSequence); + // The weapon entity draws its world model in third person, which has none of the viewmodel's sequences + const int iOwnSequence = LookupSequence(pszName); + if (iOwnSequence >= 0) + { + SetSequence(iOwnSequence); + } SendViewModelAnim(iSequence); // the third-person reload gesture lasts no longer than this sequence From a69ace3b7bcac5a0a194dbc8b7a5d2c31ba737a4 Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sun, 8 Nov 2026 09:49:39 -0700 Subject: [PATCH 24/55] Keep the reload gesture through a resume The draw that resumes a reload changes the active weapon, and the weapon-change reset then cleared the third-person reload gesture after one frame, so others saw no reload. The reload event now adopts the active weapon. It also carries the resume's length: a gesture longer than the resume plays only its end, blending in over 0.2 s. --- .../shared/hl2mp/hl2mp_playeranimstate.cpp | 98 +++++++++++++++++++ src/game/shared/hl2mp/hl2mp_playeranimstate.h | 11 +++ .../weapons/weapon_neobasecombatweapon.cpp | 7 +- 3 files changed, 113 insertions(+), 3 deletions(-) diff --git a/src/game/shared/hl2mp/hl2mp_playeranimstate.cpp b/src/game/shared/hl2mp/hl2mp_playeranimstate.cpp index 9e441acd87..fab73546c2 100644 --- a/src/game/shared/hl2mp/hl2mp_playeranimstate.cpp +++ b/src/game/shared/hl2mp/hl2mp_playeranimstate.cpp @@ -80,6 +80,10 @@ CHL2MPPlayerAnimState* CreateHL2MPPlayerAnimState( CHL2MP_Player *pPlayer ) CHL2MPPlayerAnimState::CHL2MPPlayerAnimState() { m_pHL2MPPlayer = NULL; +#ifdef NEO + m_iReloadGestureSequence = -1; + m_flReloadGestureStartCycle = 0.0f; +#endif // Don't initialize HL2MP specific variables here. Init them in InitHL2MPAnimState() } @@ -93,6 +97,10 @@ CHL2MPPlayerAnimState::CHL2MPPlayerAnimState( CBasePlayer *pPlayer, MultiPlayerM : CMultiPlayerAnimState( pPlayer, movementData ) { m_pHL2MPPlayer = NULL; +#ifdef NEO + m_iReloadGestureSequence = -1; + m_flReloadGestureStartCycle = 0.0f; +#endif // Don't initialize HL2MP specific variables here. Init them in InitHL2MPAnimState() } @@ -182,6 +190,7 @@ void CHL2MPPlayerAnimState::ComputeSequences(CStudioHdr* pStudioHdr) // The groundspeed interpolator uses the main sequence info. UpdateInterpolators(); ComputeGestureSequence(pStudioHdr); + UpdateReloadGesture(); } #endif //NEO @@ -343,6 +352,7 @@ void CHL2MPPlayerAnimState::DoAnimationEvent( PlayerAnimEvent_t event, int nData { #ifdef NEO AddToGestureSlot(GESTURE_SLOT_ATTACK_AND_RELOAD, CalcReloadSequence(), true); + StartReloadGesture(nData); #else // Weapon reload. if ( GetBasePlayer()->GetFlags() & FL_DUCKING ) @@ -1013,3 +1023,91 @@ void CHL2MPPlayerAnimState::DebugShowAnimStateFull(int iStartLine) AnimStateLog("--------------------------------------------\n\n"); } + +#ifdef NEO +// Start a gesture part way through its sequence, as AddVCDSequenceToGestureSlot does for scene gestures +void CHL2MPPlayerAnimState::SetGestureSlotCycle(int iGestureSlot, float flCycle) +{ + GestureSlot_t &slot = m_aGestureSlots[iGestureSlot]; + if (!slot.m_pAnimLayer) + { + return; + } + + slot.m_pAnimLayer->m_flCycle = flCycle; + slot.m_pAnimLayer->m_flPrevCycle = flCycle; +#ifdef CLIENT_DLL + if (CBasePlayer *pPlayer = GetBasePlayer()) + { + pPlayer->m_flOverlayPrevEventCycle[iGestureSlot] = flCycle; + } +#endif +} + +static constexpr float RELOAD_GESTURE_MS_PER_SECOND = 1000.0f; + +// The player models' reload gestures have no blend of their own, so a gesture started part way +// blends in over this long to hide the jump in pose +static constexpr float RELOAD_GESTURE_BLEND_TIME = 0.2f; + +int CHL2MPPlayerAnimState::ResumedReloadGestureData(float flDuration) +{ + return static_cast(Max(flDuration, 0.0f) * RELOAD_GESTURE_MS_PER_SECOND); +} + +// Fit the reload gesture just added to a resumed reload shorter than the gesture: play only the gesture's end, for as +// long as the resume lasts. An event without data plays the whole gesture +void CHL2MPPlayerAnimState::StartReloadGesture(int nData) +{ + m_iReloadGestureSequence = -1; + + CBasePlayer *pPlayer = GetBasePlayer(); + const GestureSlot_t &slot = m_aGestureSlots[GESTURE_SLOT_ATTACK_AND_RELOAD]; + if (nData <= 0 || !pPlayer || !slot.m_bActive || !slot.m_pAnimLayer) + { + return; + } + + // A reload resumed by the draw starts with the weapon change, which would otherwise clear the gesture + m_hActiveWeapon = pPlayer->GetActiveWeapon(); + + const int iSequence = slot.m_pAnimLayer->m_nSequence; + const float flDuration = nData / RELOAD_GESTURE_MS_PER_SECOND; + const float flCycles = flDuration * pPlayer->GetSequenceCycleRate(pPlayer->GetModelPtr(), iSequence); + if (flCycles >= 1.0f) + { + return; + } + + m_flReloadGestureStartCycle = 1.0f - flCycles; + m_iReloadGestureSequence = iSequence; + SetGestureSlotCycle(GESTURE_SLOT_ATTACK_AND_RELOAD, m_flReloadGestureStartCycle); +} + +// Blend a late-started reload gesture in from its start cycle +void CHL2MPPlayerAnimState::UpdateReloadGesture() +{ + if (m_iReloadGestureSequence < 0) + { + return; + } + + CBasePlayer *pPlayer = GetBasePlayer(); + GestureSlot_t &slot = m_aGestureSlots[GESTURE_SLOT_ATTACK_AND_RELOAD]; + if (!pPlayer || !slot.m_bActive || !slot.m_pAnimLayer || slot.m_pAnimLayer->m_nSequence != m_iReloadGestureSequence) + { + // a new gesture took the slot, or the reload gesture ended + m_iReloadGestureSequence = -1; + return; + } + + const float flBlendCycles = RELOAD_GESTURE_BLEND_TIME * pPlayer->GetSequenceCycleRate(pPlayer->GetModelPtr(), m_iReloadGestureSequence); + if (flBlendCycles <= 0.0f) + { + return; + } + + const float flWeight = (slot.m_pAnimLayer->m_flCycle - m_flReloadGestureStartCycle) / flBlendCycles; + slot.m_pAnimLayer->m_flWeight = clamp(flWeight, 0.0f, 1.0f); +} +#endif // NEO diff --git a/src/game/shared/hl2mp/hl2mp_playeranimstate.h b/src/game/shared/hl2mp/hl2mp_playeranimstate.h index 9a05125539..b32af4f9f7 100644 --- a/src/game/shared/hl2mp/hl2mp_playeranimstate.h +++ b/src/game/shared/hl2mp/hl2mp_playeranimstate.h @@ -47,6 +47,9 @@ class CHL2MPPlayerAnimState : public CMultiPlayerAnimState virtual float GetCurrentMaxGroundSpeed(); #ifdef NEO virtual void ComputeSequences(CStudioHdr* pStudioHdr); + + // A resumed reload's event data: how long the first-person resume lasts + static int ResumedReloadGestureData(float flDuration); #endif void DebugShowAnimStateFull(int iStartLine); @@ -64,9 +67,17 @@ class CHL2MPPlayerAnimState : public CMultiPlayerAnimState #ifdef NEO bool IsLeaning(CStudioHdr *pStudioHdr); + void SetGestureSlotCycle(int iGestureSlot, float flCycle); + void StartReloadGesture(int nData); + void UpdateReloadGesture(); #endif // NEO CHL2MP_Player *m_pHL2MPPlayer; +#ifdef NEO + // The playing late-started reload gesture's sequence (-1: none) and the cycle it blends in from + int m_iReloadGestureSequence; + float m_flReloadGestureStartCycle; +#endif #ifndef NEO bool m_bInAirWalk; float m_flHoldDeployedPoseUntilTime; diff --git a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp index 0a944ab5dd..3af713f0a7 100644 --- a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp +++ b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp @@ -621,10 +621,11 @@ bool CNEOBaseCombatWeapon::ResumeReload() SetSequence(iSequence); SendViewModelAnim(iSequence); - // the draw is part of the motion: the full reload gesture fits the resume - ToHL2MPPlayer(GetOwner())->DoAnimationEvent(PLAYERANIMEVENT_RELOAD); + // the third-person reload gesture lasts no longer than the resume + const float flDuration = ReloadViewModel()->SequenceDuration(iSequence); + ToHL2MPPlayer(GetOwner())->DoAnimationEvent(PLAYERANIMEVENT_RELOAD, CHL2MPPlayerAnimState::ResumedReloadGestureData(flDuration)); - const float flEnd = gpGlobals->curtime + ReloadViewModel()->SequenceDuration(iSequence); + const float flEnd = gpGlobals->curtime + flDuration; GetOwner()->SetNextAttack(flEnd); m_flNextPrimaryAttack = m_flNextSecondaryAttack = flEnd; SetWeaponIdleTime(flEnd); From eeb264cf1609c23ae819ca83982ea9bbc673c2fe Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sun, 8 Nov 2026 09:49:39 -0700 Subject: [PATCH 25/55] Keep viewmodel sequences off the world model ResumeReload set the weapon entity's sequence to the viewmodel's index. A client that draws the weapon's world model (third person) then asserts in studio.cpp on every resumed reload. Set the weapon's own sequence only when its model has the named sequence. --- src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp index 3af713f0a7..9e3ded0fbf 100644 --- a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp +++ b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp @@ -618,7 +618,12 @@ bool CNEOBaseCombatWeapon::ResumeReload() // the old magazine and its rounds are gone, as when a reload loads at its ready time m_iClip1 = 0; - SetSequence(iSequence); + // The weapon entity draws its world model in third person, which has none of the viewmodel's sequences + const int iOwnSequence = LookupSequence(pszName); + if (iOwnSequence >= 0) + { + SetSequence(iOwnSequence); + } SendViewModelAnim(iSequence); // the third-person reload gesture lasts no longer than the resume From dc97144140fdac7c4bdfac1aaea27280c8d66d33 Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sun, 8 Nov 2026 02:40:14 -0700 Subject: [PATCH 26/55] Enable partial reloads for the M41 family Point the M41, M41S and M41L scripts at their reload phases files from neoAssets and give them a chambered round, the same data the ZR68C uses. Add the four reload sound pieces the phases rows name. No code change: the family uses the base weapon's reload. --- game/neo/scripts/game_sounds_weapons.txt | 38 ++++++++++++++++++++++++ game/neo/scripts/weapon_m41.txt | 7 +++++ game/neo/scripts/weapon_m41l.txt | 7 +++++ game/neo/scripts/weapon_m41s.txt | 7 +++++ 4 files changed, 59 insertions(+) diff --git a/game/neo/scripts/game_sounds_weapons.txt b/game/neo/scripts/game_sounds_weapons.txt index e1d43d8695..efe79307c5 100644 --- a/game/neo/scripts/game_sounds_weapons.txt +++ b/game/neo/scripts/game_sounds_weapons.txt @@ -586,6 +586,44 @@ "wave" "weapons/m41/m41_reload.wav" } +// M41 reload in per-step pieces (sv_neo_reload_experimental). + +"weapon_m41.reload_1_unload" +{ + "channel" "CHAN_ITEM" + "soundlevel" "SNDLVL_NORM" + "volume" "1.0" + "pitch" "PITCH_NORM" + "wave" ")weapons/m41/m41_reload_1_unload.wav" +} + +"weapon_m41.reload_2_load" +{ + "channel" "CHAN_ITEM" + "soundlevel" "SNDLVL_NORM" + "volume" "1.0" + "pitch" "PITCH_NORM" + "wave" ")weapons/m41/m41_reload_2_load.wav" +} + +"weapon_m41.reload_2_load_2" +{ + "channel" "CHAN_ITEM" + "soundlevel" "SNDLVL_NORM" + "volume" "1.0" + "pitch" "PITCH_NORM" + "wave" ")weapons/m41/m41_reload_2_load_2.wav" +} + +"weapon_m41.reload_3_cycle" +{ + "channel" "CHAN_ITEM" + "soundlevel" "SNDLVL_NORM" + "volume" "1.0" + "pitch" "PITCH_NORM" + "wave" ")weapons/m41/m41_reload_3_cycle.wav" +} + //------------------- "weapon_m41.npc_reload" diff --git a/game/neo/scripts/weapon_m41.txt b/game/neo/scripts/weapon_m41.txt index b3d02a4cfb..14749a11e2 100644 --- a/game/neo/scripts/weapon_m41.txt +++ b/game/neo/scripts/weapon_m41.txt @@ -1,3 +1,5 @@ +#base "weapon_mosok41_reload_phases.txt" + // M41 WeaponData @@ -16,6 +18,11 @@ WeaponData "Penetration" "32.0" "CycleTime" "0.166666" // time between shots "ReloadReadyBeforeEnd" "0.393" // the reload is done at the last reload click, this long before its animation ends + + // Reload phases (sv_neo_reload_experimental): the rows come from neoAssets, timed from its Blender markers + "ReloadPhases" {} + // Chamber capacity is gameplay data; the phase timing comes from neoAssets. + "ChamberedRound" "1" "TPMuzzleFlashScale" "0.5" diff --git a/game/neo/scripts/weapon_m41l.txt b/game/neo/scripts/weapon_m41l.txt index b98a05166c..e35f62023b 100644 --- a/game/neo/scripts/weapon_m41l.txt +++ b/game/neo/scripts/weapon_m41l.txt @@ -1,3 +1,5 @@ +#base "weapon_mosok41l_reload_phases.txt" + // M41 WeaponData @@ -16,6 +18,11 @@ WeaponData "Penetration" "32.0" "CycleTime" "0.5" // time between shots "ReloadReadyBeforeEnd" "0.333" // the reload is done at the last reload click, this long before its animation ends + + // Reload phases (sv_neo_reload_experimental): the rows come from neoAssets, timed from its Blender markers + "ReloadPhases" {} + // Chamber capacity is gameplay data; the phase timing comes from neoAssets. + "ChamberedRound" "1" "TPMuzzleFlashScale" "0.25" diff --git a/game/neo/scripts/weapon_m41s.txt b/game/neo/scripts/weapon_m41s.txt index a4cb54cf5e..fda1853da6 100644 --- a/game/neo/scripts/weapon_m41s.txt +++ b/game/neo/scripts/weapon_m41s.txt @@ -1,3 +1,5 @@ +#base "weapon_mosok41s_reload_phases.txt" + // M41 WeaponData @@ -16,6 +18,11 @@ WeaponData "Penetration" "20.0" "CycleTime" "0.166666" // time between shots "ReloadReadyBeforeEnd" "0.393" // the reload is done at the last reload click, this long before its animation ends + + // Reload phases (sv_neo_reload_experimental): the rows come from neoAssets, timed from its Blender markers + "ReloadPhases" {} + // Chamber capacity is gameplay data; the phase timing comes from neoAssets. + "ChamberedRound" "1" "TPMuzzleFlashScale" "0.5" From e8b3bd2a990fe4c527cf25fff4c19681b9313bf5 Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sun, 8 Nov 2026 02:47:44 -0700 Subject: [PATCH 27/55] Enable partial reloads for the MPN45 family Point both MPN45 scripts at their reload phases files from neoAssets and give them a chambered round, as for the ZR68C and M41. Add the three reload sound pieces; the MPN45 has no separate tap. No code change. --- game/neo/scripts/game_sounds_weapons.txt | 29 ++++++++++++++++++++++ game/neo/scripts/weapon_mpn.txt | 7 ++++++ game/neo/scripts/weapon_mpn_unsilenced.txt | 7 ++++++ 3 files changed, 43 insertions(+) diff --git a/game/neo/scripts/game_sounds_weapons.txt b/game/neo/scripts/game_sounds_weapons.txt index efe79307c5..ed393c212f 100644 --- a/game/neo/scripts/game_sounds_weapons.txt +++ b/game/neo/scripts/game_sounds_weapons.txt @@ -343,6 +343,35 @@ "wave" "weapons/mpn45/mpn45_reload.wav" } +// MPN45 reload in per-step pieces (sv_neo_reload_experimental). + +"weapon_mpn45.reload_1_unload" +{ + "channel" "CHAN_ITEM" + "soundlevel" "SNDLVL_NORM" + "volume" "1.0" + "pitch" "PITCH_NORM" + "wave" ")weapons/mpn45/mpn45_reload_1_unload.wav" +} + +"weapon_mpn45.reload_2_load" +{ + "channel" "CHAN_ITEM" + "soundlevel" "SNDLVL_NORM" + "volume" "1.0" + "pitch" "PITCH_NORM" + "wave" ")weapons/mpn45/mpn45_reload_2_load.wav" +} + +"weapon_mpn45.reload_3_cycle" +{ + "channel" "CHAN_ITEM" + "soundlevel" "SNDLVL_NORM" + "volume" "1.0" + "pitch" "PITCH_NORM" + "wave" ")weapons/mpn45/mpn45_reload_3_cycle.wav" +} + //------------------- "weapon_mpn45.npc_reload" diff --git a/game/neo/scripts/weapon_mpn.txt b/game/neo/scripts/weapon_mpn.txt index e61bce9774..6aa9b1490d 100644 --- a/game/neo/scripts/weapon_mpn.txt +++ b/game/neo/scripts/weapon_mpn.txt @@ -1,3 +1,5 @@ +#base "weapon_mpn_s_reload_phases.txt" + WeaponData { // Weapon data is loaded by both the Game and Client DLLs. @@ -15,6 +17,11 @@ WeaponData "CycleTime" "0.075757" // time between shots "ReloadReadyBeforeEnd" "0.500" // the reload is done at the last reload click, this long before its animation ends // the charging handle is home 0.400 before the end, the alternative value + + // Reload phases (sv_neo_reload_experimental): the rows come from neoAssets, timed from its Blender markers + "ReloadPhases" {} + // Chamber capacity is gameplay data; the phase timing comes from neoAssets. + "ChamberedRound" "1" "TPMuzzleFlashScale" "0.5" diff --git a/game/neo/scripts/weapon_mpn_unsilenced.txt b/game/neo/scripts/weapon_mpn_unsilenced.txt index 4cc79578cb..a4ed9f5e68 100644 --- a/game/neo/scripts/weapon_mpn_unsilenced.txt +++ b/game/neo/scripts/weapon_mpn_unsilenced.txt @@ -1,3 +1,5 @@ +#base "weapon_mpn_reload_phases.txt" + WeaponData { // Weapon data is loaded by both the Game and Client DLLs. @@ -15,6 +17,11 @@ WeaponData "CycleTime" "0.075757" // time between shots "ReloadReadyBeforeEnd" "0.500" // the reload is done at the last reload click, this long before its animation ends // the charging handle is home 0.400 before the end, the alternative value + + // Reload phases (sv_neo_reload_experimental): the rows come from neoAssets, timed from its Blender markers + "ReloadPhases" {} + // Chamber capacity is gameplay data; the phase timing comes from neoAssets. + "ChamberedRound" "1" "TPMuzzleFlashScale" "0.5" From 93244ead6f0ff1084df32f944df1a212321bf7f9 Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sun, 8 Nov 2026 02:55:02 -0700 Subject: [PATCH 28/55] Enable partial reloads for the MX family Point both MX scripts at their reload phases files from neoAssets and give them a chambered round, as for the other closed-bolt rifles. Add the three reload sound pieces. No code change. --- game/neo/scripts/game_sounds_weapons.txt | 29 ++++++++++++++++++++++++ game/neo/scripts/weapon_mx.txt | 7 ++++++ game/neo/scripts/weapon_mx_silenced.txt | 7 ++++++ 3 files changed, 43 insertions(+) diff --git a/game/neo/scripts/game_sounds_weapons.txt b/game/neo/scripts/game_sounds_weapons.txt index ed393c212f..69ed01ca2c 100644 --- a/game/neo/scripts/game_sounds_weapons.txt +++ b/game/neo/scripts/game_sounds_weapons.txt @@ -998,6 +998,35 @@ "wave" "weapons/mx/mx_reload.wav" } +// MX reload in per-step pieces (sv_neo_reload_experimental). + +"weapon_mx.reload_1_unload" +{ + "channel" "CHAN_ITEM" + "soundlevel" "SNDLVL_NORM" + "volume" "1.0" + "pitch" "PITCH_NORM" + "wave" ")weapons/mx/mx_reload_1_unload.wav" +} + +"weapon_mx.reload_2_load" +{ + "channel" "CHAN_ITEM" + "soundlevel" "SNDLVL_NORM" + "volume" "1.0" + "pitch" "PITCH_NORM" + "wave" ")weapons/mx/mx_reload_2_load.wav" +} + +"weapon_mx.reload_3_cycle" +{ + "channel" "CHAN_ITEM" + "soundlevel" "SNDLVL_NORM" + "volume" "1.0" + "pitch" "PITCH_NORM" + "wave" ")weapons/mx/mx_reload_3_cycle.wav" +} + //------------------- "weapon_mx.npc_reload" diff --git a/game/neo/scripts/weapon_mx.txt b/game/neo/scripts/weapon_mx.txt index 953c278462..75efa39c89 100644 --- a/game/neo/scripts/weapon_mx.txt +++ b/game/neo/scripts/weapon_mx.txt @@ -1,3 +1,5 @@ +#base "weapon_mx_reload_phases.txt" + // MX WeaponData @@ -17,6 +19,11 @@ WeaponData "CycleTime" "0.106060" // time between shots "ReloadReadyBeforeEnd" "0.417" // the reload is done at the last reload click, this long before its animation ends + // Reload phases (sv_neo_reload_experimental): the rows come from neoAssets, timed from its Blender markers + "ReloadPhases" {} + // Chamber capacity is gameplay data; the phase timing comes from neoAssets. + "ChamberedRound" "1" + "TPMuzzleFlashScale" "0.3" "clip_size" "30" diff --git a/game/neo/scripts/weapon_mx_silenced.txt b/game/neo/scripts/weapon_mx_silenced.txt index 918e953662..33387ecf06 100644 --- a/game/neo/scripts/weapon_mx_silenced.txt +++ b/game/neo/scripts/weapon_mx_silenced.txt @@ -1,3 +1,5 @@ +#base "weapon_mxs_reload_phases.txt" + WeaponData { // Weapon data is loaded by both the Game and Client DLLs. @@ -15,6 +17,11 @@ WeaponData "CycleTime" "0.106060" // time between shots "ReloadReadyBeforeEnd" "0.427" // the reload is done at the last reload click, this long before its animation ends + // Reload phases (sv_neo_reload_experimental): the rows come from neoAssets, timed from its Blender markers + "ReloadPhases" {} + // Chamber capacity is gameplay data; the phase timing comes from neoAssets. + "ChamberedRound" "1" + "TPMuzzleFlashScale" "0.3" "clip_size" "30" From a92f32740a87531267e6cb261f9df6371b502a45 Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sun, 8 Nov 2026 03:54:12 -0700 Subject: [PATCH 29/55] Enable partial reloads for the ZR68-S Point the ZR68-S script at its reload phases file from neoAssets and give it a chambered round, as for the ZR68C. The ZR68-S reuses the ZR68C's reload sound pieces, so it adds no sound entries. --- game/neo/scripts/weapon_zr68s.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/game/neo/scripts/weapon_zr68s.txt b/game/neo/scripts/weapon_zr68s.txt index 87019630a5..857d84320f 100644 --- a/game/neo/scripts/weapon_zr68s.txt +++ b/game/neo/scripts/weapon_zr68s.txt @@ -1,3 +1,5 @@ +#base "weapon_zr68s_reload_phases.txt" + // ZR68S WeaponData @@ -18,6 +20,11 @@ WeaponData "Penetration" "18.0" "CycleTime" "0.106060" // time between shots "ReloadReadyBeforeEnd" "0.483" // the reload is done at the last reload click, this long before its animation ends + + // Reload phases (sv_neo_reload_experimental): the rows come from neoAssets, timed from its Blender markers + "ReloadPhases" {} + // Chamber capacity is gameplay data; the phase timing comes from neoAssets. + "ChamberedRound" "1" "TPMuzzleFlashScale" "0.5" From 55ab3b27da481526bfdc0f2ceddf6f3480b17b6f Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sun, 8 Nov 2026 03:54:19 -0700 Subject: [PATCH 30/55] Enable partial reloads for the ZR68-L Point the ZR68-L script at its reload phases file from neoAssets and give it a chambered round, as for the ZR68C. Add the four reload sound pieces the phases rows name, after the ZR68C's pieces. --- game/neo/scripts/game_sounds_weapons.txt | 38 ++++++++++++++++++++++++ game/neo/scripts/weapon_zr68l.txt | 7 +++++ 2 files changed, 45 insertions(+) diff --git a/game/neo/scripts/game_sounds_weapons.txt b/game/neo/scripts/game_sounds_weapons.txt index 69ed01ca2c..6ceeacea6e 100644 --- a/game/neo/scripts/game_sounds_weapons.txt +++ b/game/neo/scripts/game_sounds_weapons.txt @@ -865,6 +865,44 @@ "wave" ")weapons/zr68/zr68_reload_3_cycle.wav" } +// ZR68L reload in per-step pieces (sv_neo_reload_experimental). + +"weapon_zr68l.reload_1_unload" +{ + "channel" "CHAN_ITEM" + "soundlevel" "SNDLVL_NORM" + "volume" "1.0" + "pitch" "PITCH_NORM" + "wave" ")weapons/zr68l/zr68l_reload_1_unload.wav" +} + +"weapon_zr68l.reload_2_load" +{ + "channel" "CHAN_ITEM" + "soundlevel" "SNDLVL_NORM" + "volume" "1.0" + "pitch" "PITCH_NORM" + "wave" ")weapons/zr68l/zr68l_reload_2_load.wav" +} + +"weapon_zr68l.reload_2_load_2" +{ + "channel" "CHAN_ITEM" + "soundlevel" "SNDLVL_NORM" + "volume" "1.0" + "pitch" "PITCH_NORM" + "wave" ")weapons/zr68l/zr68l_reload_2_load_2.wav" +} + +"weapon_zr68l.reload_3_cycle" +{ + "channel" "CHAN_ITEM" + "soundlevel" "SNDLVL_NORM" + "volume" "1.0" + "pitch" "PITCH_NORM" + "wave" ")weapons/zr68l/zr68l_reload_3_cycle.wav" +} + //------------------- "weapon_zr68.npc_reload" diff --git a/game/neo/scripts/weapon_zr68l.txt b/game/neo/scripts/weapon_zr68l.txt index 147c324305..7cb3220f00 100644 --- a/game/neo/scripts/weapon_zr68l.txt +++ b/game/neo/scripts/weapon_zr68l.txt @@ -1,3 +1,5 @@ +#base "weapon_zr68l_reload_phases.txt" + // ZR68L WeaponData @@ -16,6 +18,11 @@ WeaponData "Penetration" "32.0" "CycleTime" "0.5" // time between shots "ReloadReadyBeforeEnd" "0.367" // the reload is done at the last reload click, this long before its animation ends + + // Reload phases (sv_neo_reload_experimental): the rows come from neoAssets, timed from its Blender markers + "ReloadPhases" {} + // Chamber capacity is gameplay data; the phase timing comes from neoAssets. + "ChamberedRound" "1" "TPMuzzleFlashScale" "0.5" From c49b6dce1409dc03be0ac98b47ab4d59f3664290 Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sun, 8 Nov 2026 03:54:24 -0700 Subject: [PATCH 31/55] Enable partial reloads for the Jitte family Point the Jitte and scoped Jitte scripts at their reload phases files from neoAssets and give them a chambered round, as for the M41. Add the three reload sound pieces the phases rows name. --- game/neo/scripts/game_sounds_weapons.txt | 29 ++++++++++++++++++++++++ game/neo/scripts/weapon_jitte.txt | 7 ++++++ game/neo/scripts/weapon_jittescoped.txt | 7 ++++++ 3 files changed, 43 insertions(+) diff --git a/game/neo/scripts/game_sounds_weapons.txt b/game/neo/scripts/game_sounds_weapons.txt index 6ceeacea6e..2a076bfb18 100644 --- a/game/neo/scripts/game_sounds_weapons.txt +++ b/game/neo/scripts/game_sounds_weapons.txt @@ -531,6 +531,35 @@ "wave" "weapons/jitte/jitte_reload.wav" } +// Jitte reload in per-step pieces (sv_neo_reload_experimental). + +"weapon_jitte.reload_1_unload" +{ + "channel" "CHAN_ITEM" + "soundlevel" "SNDLVL_NORM" + "volume" "1.0" + "pitch" "PITCH_NORM" + "wave" ")weapons/jitte/jitte_reload_1_unload.wav" +} + +"weapon_jitte.reload_2_load" +{ + "channel" "CHAN_ITEM" + "soundlevel" "SNDLVL_NORM" + "volume" "1.0" + "pitch" "PITCH_NORM" + "wave" ")weapons/jitte/jitte_reload_2_load.wav" +} + +"weapon_jitte.reload_3_cycle" +{ + "channel" "CHAN_ITEM" + "soundlevel" "SNDLVL_NORM" + "volume" "1.0" + "pitch" "PITCH_NORM" + "wave" ")weapons/jitte/jitte_reload_3_cycle.wav" +} + //------------------- "weapon_jitte.npc_reload" diff --git a/game/neo/scripts/weapon_jitte.txt b/game/neo/scripts/weapon_jitte.txt index e148f2aecf..7dbb7b5348 100644 --- a/game/neo/scripts/weapon_jitte.txt +++ b/game/neo/scripts/weapon_jitte.txt @@ -1,3 +1,5 @@ +#base "weapon_jitte_reload_phases.txt" + WeaponData { // Weapon data is loaded by both the Game and Client DLLs. @@ -15,6 +17,11 @@ WeaponData "CycleTime" "0.090909" // time between shots "ReloadReadyBeforeEnd" "0.455" // the reload is done at the last reload click, this long before its animation ends // the charging handle is home 0.400 before the end, the alternative value + + // Reload phases (sv_neo_reload_experimental): the rows come from neoAssets, timed from its Blender markers + "ReloadPhases" {} + // Chamber capacity is gameplay data; the phase timing comes from neoAssets. + "ChamberedRound" "1" "TPMuzzleFlashScale" "0.5" diff --git a/game/neo/scripts/weapon_jittescoped.txt b/game/neo/scripts/weapon_jittescoped.txt index 9671a3c8c1..f01c736cce 100644 --- a/game/neo/scripts/weapon_jittescoped.txt +++ b/game/neo/scripts/weapon_jittescoped.txt @@ -1,3 +1,5 @@ +#base "weapon_jittes_reload_phases.txt" + WeaponData { // Weapon data is loaded by both the Game and Client DLLs. @@ -15,6 +17,11 @@ WeaponData "CycleTime" "0.090909" // time between shots "ReloadReadyBeforeEnd" "0.455" // the reload is done at the last reload click, this long before its animation ends // the charging handle is home 0.400 before the end, the alternative value + + // Reload phases (sv_neo_reload_experimental): the rows come from neoAssets, timed from its Blender markers + "ReloadPhases" {} + // Chamber capacity is gameplay data; the phase timing comes from neoAssets. + "ChamberedRound" "1" "TPMuzzleFlashScale" "0.5" From 38d90dbc5dc522fa27b6b1b22dee24635e89f702 Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sun, 8 Nov 2026 03:54:38 -0700 Subject: [PATCH 32/55] Enable partial reloads for the SRM family Point the SRM and SRM-S scripts at their reload phases files from neoAssets and give them a chambered round, as for the M41. Add the three reload sound pieces the phases rows name. --- game/neo/scripts/game_sounds_weapons.txt | 29 ++++++++++++++++++++++++ game/neo/scripts/weapon_srm.txt | 7 ++++++ game/neo/scripts/weapon_srm_s.txt | 7 ++++++ 3 files changed, 43 insertions(+) diff --git a/game/neo/scripts/game_sounds_weapons.txt b/game/neo/scripts/game_sounds_weapons.txt index 2a076bfb18..b6112a667c 100644 --- a/game/neo/scripts/game_sounds_weapons.txt +++ b/game/neo/scripts/game_sounds_weapons.txt @@ -446,6 +446,35 @@ "wave" "weapons/srm/srm_reload.wav" } +// SRM reload in per-step pieces (sv_neo_reload_experimental). + +"weapon_srm.reload_1_unload" +{ + "channel" "CHAN_ITEM" + "soundlevel" "SNDLVL_NORM" + "volume" "1.0" + "pitch" "PITCH_NORM" + "wave" ")weapons/srm/srm_reload_1_unload.wav" +} + +"weapon_srm.reload_2_load" +{ + "channel" "CHAN_ITEM" + "soundlevel" "SNDLVL_NORM" + "volume" "1.0" + "pitch" "PITCH_NORM" + "wave" ")weapons/srm/srm_reload_2_load.wav" +} + +"weapon_srm.reload_3_cycle" +{ + "channel" "CHAN_ITEM" + "soundlevel" "SNDLVL_NORM" + "volume" "1.0" + "pitch" "PITCH_NORM" + "wave" ")weapons/srm/srm_reload_3_cycle.wav" +} + //------------------- "weapon_srm.npc_reload" diff --git a/game/neo/scripts/weapon_srm.txt b/game/neo/scripts/weapon_srm.txt index 2d2170338f..08dc084b1a 100644 --- a/game/neo/scripts/weapon_srm.txt +++ b/game/neo/scripts/weapon_srm.txt @@ -1,3 +1,5 @@ +#base "weapon_srm_reload_phases.txt" + WeaponData { // Weapon data is loaded by both the Game and Client DLLs. @@ -15,6 +17,11 @@ WeaponData "CycleTime" "0.060606" // time between shots "ReloadReadyBeforeEnd" "0.233" // the reload is done at the last reload click, this long before its animation ends // the charging handle is home 0.167 before the end, the alternative value + + // Reload phases (sv_neo_reload_experimental): the rows come from neoAssets, timed from its Blender markers + "ReloadPhases" {} + // Chamber capacity is gameplay data; the phase timing comes from neoAssets. + "ChamberedRound" "1" "TPMuzzleFlashScale" "0.5" diff --git a/game/neo/scripts/weapon_srm_s.txt b/game/neo/scripts/weapon_srm_s.txt index e8fb6146d3..a1f6422e20 100644 --- a/game/neo/scripts/weapon_srm_s.txt +++ b/game/neo/scripts/weapon_srm_s.txt @@ -1,3 +1,5 @@ +#base "weapon_srm_s_reload_phases.txt" + WeaponData { // Weapon data is loaded by both the Game and Client DLLs. @@ -15,6 +17,11 @@ WeaponData "CycleTime" "0.090909" // time between shots "ReloadReadyBeforeEnd" "0.233" // the reload is done at the last reload click, this long before its animation ends // the charging handle is home 0.167 before the end, the alternative value + + // Reload phases (sv_neo_reload_experimental): the rows come from neoAssets, timed from its Blender markers + "ReloadPhases" {} + // Chamber capacity is gameplay data; the phase timing comes from neoAssets. + "ChamberedRound" "1" "TPMuzzleFlashScale" "0.5" From bb58039e401e7a783a739246dda93472120851d6 Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sun, 8 Nov 2026 03:54:43 -0700 Subject: [PATCH 33/55] Enable partial reloads for the SRS Point the SRS script at its reload phases file from neoAssets and give it a chambered round. The bolt-action rifle chambers a round after each shot, so a tactical reload keeps it. Add the three reload sound pieces the phases rows name. --- game/neo/scripts/game_sounds_weapons.txt | 29 ++++++++++++++++++++++++ game/neo/scripts/weapon_srs.txt | 7 ++++++ 2 files changed, 36 insertions(+) diff --git a/game/neo/scripts/game_sounds_weapons.txt b/game/neo/scripts/game_sounds_weapons.txt index b6112a667c..1cd3b55236 100644 --- a/game/neo/scripts/game_sounds_weapons.txt +++ b/game/neo/scripts/game_sounds_weapons.txt @@ -802,6 +802,35 @@ "wave" "weapons/srs/srs_reload.wav" } +// SRS reload in per-step pieces (sv_neo_reload_experimental). + +"weapon_srs.reload_1_unload" +{ + "channel" "CHAN_ITEM" + "soundlevel" "SNDLVL_NORM" + "volume" "1.0" + "pitch" "PITCH_NORM" + "wave" ")weapons/srs/srs_reload_1_unload.wav" +} + +"weapon_srs.reload_2_load" +{ + "channel" "CHAN_ITEM" + "soundlevel" "SNDLVL_NORM" + "volume" "1.0" + "pitch" "PITCH_NORM" + "wave" ")weapons/srs/srs_reload_2_load.wav" +} + +"weapon_srs.reload_3_cycle" +{ + "channel" "CHAN_ITEM" + "soundlevel" "SNDLVL_NORM" + "volume" "1.0" + "pitch" "PITCH_NORM" + "wave" ")weapons/srs/srs_reload_3_cycle.wav" +} + //------------------- "weapon_srs.npc_reload" diff --git a/game/neo/scripts/weapon_srs.txt b/game/neo/scripts/weapon_srs.txt index 3538bca8ef..9a20b07450 100644 --- a/game/neo/scripts/weapon_srs.txt +++ b/game/neo/scripts/weapon_srs.txt @@ -1,3 +1,5 @@ +#base "weapon_srs_reload_phases.txt" + // SRS WeaponData @@ -16,6 +18,11 @@ WeaponData "Penetration" "65.0" "CycleTime" "1.4" "ReloadReadyBeforeEnd" "0.583" // the reload is done at the last reload click, this long before its animation ends + + // Reload phases (sv_neo_reload_experimental): the rows come from neoAssets, timed from its Blender markers + "ReloadPhases" {} + // Chamber capacity is gameplay data; the phase timing comes from neoAssets. + "ChamberedRound" "1" "TPMuzzleFlashScale" "0.25" From e028a852187ae88cea627d21b376b2a54f59f2f1 Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sun, 8 Nov 2026 05:22:27 -0700 Subject: [PATCH 34/55] Enable partial reloads for the AA13 Point the AA13 script at its reload phases file from neoAssets and give it a chambered round, as for the M41. Add the four reload sound pieces the phases rows name. --- game/neo/scripts/game_sounds_weapons.txt | 38 ++++++++++++++++++++++++ game/neo/scripts/weapon_aa13.txt | 7 +++++ 2 files changed, 45 insertions(+) diff --git a/game/neo/scripts/game_sounds_weapons.txt b/game/neo/scripts/game_sounds_weapons.txt index 1cd3b55236..434601d285 100644 --- a/game/neo/scripts/game_sounds_weapons.txt +++ b/game/neo/scripts/game_sounds_weapons.txt @@ -193,6 +193,44 @@ "wave" "weapons/aa13/aa13_reload.wav" } +// AA13 reload in per-step pieces (sv_neo_reload_experimental). + +"weapon_aa13.reload_1_unload" +{ + "channel" "CHAN_ITEM" + "soundlevel" "SNDLVL_NORM" + "volume" "1.0" + "pitch" "PITCH_NORM" + "wave" ")weapons/aa13/aa13_reload_1_unload.wav" +} + +"weapon_aa13.reload_1_unload_2" +{ + "channel" "CHAN_ITEM" + "soundlevel" "SNDLVL_NORM" + "volume" "1.0" + "pitch" "PITCH_NORM" + "wave" ")weapons/aa13/aa13_reload_1_unload_2.wav" +} + +"weapon_aa13.reload_2_load" +{ + "channel" "CHAN_ITEM" + "soundlevel" "SNDLVL_NORM" + "volume" "1.0" + "pitch" "PITCH_NORM" + "wave" ")weapons/aa13/aa13_reload_2_load.wav" +} + +"weapon_aa13.reload_3_cycle" +{ + "channel" "CHAN_ITEM" + "soundlevel" "SNDLVL_NORM" + "volume" "1.0" + "pitch" "PITCH_NORM" + "wave" ")weapons/aa13/aa13_reload_3_cycle.wav" +} + //------------------ "weapon_aa13.npc_reload" diff --git a/game/neo/scripts/weapon_aa13.txt b/game/neo/scripts/weapon_aa13.txt index ab2ba7f116..7c688cf38c 100644 --- a/game/neo/scripts/weapon_aa13.txt +++ b/game/neo/scripts/weapon_aa13.txt @@ -1,3 +1,5 @@ +#base "weapon_aa13_reload_phases.txt" + //AA13 WeaponData @@ -8,6 +10,11 @@ WeaponData "CycleTime" "0.333" "ReloadReadyBeforeEnd" "0.395" // the reload is done at the last reload click, this long before its animation ends // the charging handle is home 0.333 before the end, the alternative value + + // Reload phases (sv_neo_reload_experimental): the rows come from neoAssets, timed from its Blender markers + "ReloadPhases" {} + // Chamber capacity is gameplay data; the phase timing comes from neoAssets. + "ChamberedRound" "1" // Weapon data is loaded by both the Game and Client DLLs. "printname" "AA13" From ce52bb58e23f6dc36d6925ea567de78b64dba101 Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sun, 8 Nov 2026 05:22:32 -0700 Subject: [PATCH 35/55] Enable partial reloads for the PZ252 Point the PZ252 script at its reload phases file from neoAssets and give it a chambered round, as for the M41. The belt-fed gun cycles its bolt at the end of the reload, so a tactical reload keeps the chambered round. Add the six reload sound pieces the phases rows name. --- game/neo/scripts/game_sounds_weapons.txt | 56 ++++++++++++++++++++++++ game/neo/scripts/weapon_pz.txt | 7 +++ 2 files changed, 63 insertions(+) diff --git a/game/neo/scripts/game_sounds_weapons.txt b/game/neo/scripts/game_sounds_weapons.txt index 434601d285..c79abaf110 100644 --- a/game/neo/scripts/game_sounds_weapons.txt +++ b/game/neo/scripts/game_sounds_weapons.txt @@ -1273,6 +1273,62 @@ "wave" "weapons/pz/pz_reload.wav" } +// PZ252 reload in per-step pieces (sv_neo_reload_experimental). + +"weapon_pz.reload_1_unload" +{ + "channel" "CHAN_ITEM" + "soundlevel" "SNDLVL_NORM" + "volume" "1.0" + "pitch" "PITCH_NORM" + "wave" ")weapons/pz/pz_reload_1_unload.wav" +} + +"weapon_pz.reload_1_unload_2" +{ + "channel" "CHAN_ITEM" + "soundlevel" "SNDLVL_NORM" + "volume" "1.0" + "pitch" "PITCH_NORM" + "wave" ")weapons/pz/pz_reload_1_unload_2.wav" +} + +"weapon_pz.reload_2_load" +{ + "channel" "CHAN_ITEM" + "soundlevel" "SNDLVL_NORM" + "volume" "1.0" + "pitch" "PITCH_NORM" + "wave" ")weapons/pz/pz_reload_2_load.wav" +} + +"weapon_pz.reload_2_load_2" +{ + "channel" "CHAN_ITEM" + "soundlevel" "SNDLVL_NORM" + "volume" "1.0" + "pitch" "PITCH_NORM" + "wave" ")weapons/pz/pz_reload_2_load_2.wav" +} + +"weapon_pz.reload_2_load_3" +{ + "channel" "CHAN_ITEM" + "soundlevel" "SNDLVL_NORM" + "volume" "1.0" + "pitch" "PITCH_NORM" + "wave" ")weapons/pz/pz_reload_2_load_3.wav" +} + +"weapon_pz.reload_3_cycle" +{ + "channel" "CHAN_ITEM" + "soundlevel" "SNDLVL_NORM" + "volume" "1.0" + "pitch" "PITCH_NORM" + "wave" ")weapons/pz/pz_reload_3_cycle.wav" +} + //------------------- "weapon_pz.npc_reload" diff --git a/game/neo/scripts/weapon_pz.txt b/game/neo/scripts/weapon_pz.txt index d00b403867..df741ab382 100644 --- a/game/neo/scripts/weapon_pz.txt +++ b/game/neo/scripts/weapon_pz.txt @@ -1,3 +1,5 @@ +#base "weapon_pz_reload_phases.txt" + // ZR68S WeaponData @@ -17,6 +19,11 @@ WeaponData "CycleTime" "0.090909" // time between shots "ReloadReadyBeforeEnd" "0.543" // the reload is done at the last reload click, this long before its animation ends // the charging handle is home 0.400 before the end, the alternative value + + // Reload phases (sv_neo_reload_experimental): the rows come from neoAssets, timed from its Blender markers + "ReloadPhases" {} + // Chamber capacity is gameplay data; the phase timing comes from neoAssets. + "ChamberedRound" "1" "TPMuzzleFlashScale" "0.3" From 9f31093f83fd059ec69e02441740bcec9e76a14b Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sun, 8 Nov 2026 06:52:26 -0700 Subject: [PATCH 36/55] Track a chambered round on the MilSO and Tachi Tactical reloads keep the chambered round. The original reload animations and sounds play unchanged. --- game/neo/scripts/weapon_milso.txt | 6 ++++++ game/neo/scripts/weapon_tachi.txt | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/game/neo/scripts/weapon_milso.txt b/game/neo/scripts/weapon_milso.txt index 5e220ac1f1..08c12c2f21 100644 --- a/game/neo/scripts/weapon_milso.txt +++ b/game/neo/scripts/weapon_milso.txt @@ -1,3 +1,5 @@ +#base "weapon_milso_reload_phases.txt" + // Milso WeaponData { @@ -14,6 +16,10 @@ WeaponData "Penetration" "12.0" "CycleTime" "0.212121" "ReloadReadyBeforeEnd" "0.467" // the reload is done at the last reload click, this long before its animation ends + // Reload phases (sv_neo_reload_experimental): the rows come from neoAssets, timed from its Blender markers + "ReloadPhases" {} + // Chamber capacity is gameplay data; the phase timing comes from neoAssets. + "ChamberedRound" "1" "TPMuzzleFlashScale" "0.5" diff --git a/game/neo/scripts/weapon_tachi.txt b/game/neo/scripts/weapon_tachi.txt index 89d0bf13c1..76387eb5e4 100644 --- a/game/neo/scripts/weapon_tachi.txt +++ b/game/neo/scripts/weapon_tachi.txt @@ -1,3 +1,5 @@ +#base "weapon_tachi_reload_phases.txt" + // Tachi WeaponData @@ -33,6 +35,10 @@ WeaponData "Penetration" "19.0" "CycleTime" "0.121212" "ReloadReadyBeforeEnd" "0.400" // the reload is done at the last reload click, this long before its animation ends + // Reload phases (sv_neo_reload_experimental): the rows come from neoAssets, timed from its Blender markers + "ReloadPhases" {} + // Chamber capacity is gameplay data; the phase timing comes from neoAssets. + "ChamberedRound" "1" "ViewModelOffset" { From a4ce7bfc2276f6a3030949b503231c5cc4f7ce5f Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sun, 8 Nov 2026 10:06:22 -0700 Subject: [PATCH 37/55] Let weapons override the chamber hooks The Supa-7 keeps its rounds in a tube beside the chamber, so it needs its own answers for the chamber and magazine counts that the HUD and the reload code read. Make the four hooks virtual. --- src/game/shared/neo/weapons/weapon_neobasecombatweapon.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h index b2d56a4826..4bd6ba6aa7 100644 --- a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h +++ b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h @@ -267,10 +267,10 @@ class CNEOBaseCombatWeapon : public CBaseHL2MPCombatWeapon void StopReloadOnDrop(); // Clip1 includes the chambered round; the magazine can hold GetMaxClip1() more. - bool HasChamberSlot() const; - bool IsRoundChambered() const; - int RoundsInMagazine() const; - int MagazineCapacity() const; + virtual bool HasChamberSlot() const; + virtual bool IsRoundChambered() const; + virtual int RoundsInMagazine() const; + virtual int MagazineCapacity() const; #ifdef CLIENT_DLL float m_flTemperature; int m_spawnflags; From 9558acf889705930ace083cd659769016baab5a7 Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sun, 8 Nov 2026 10:06:22 -0700 Subject: [PATCH 38/55] Model the Supa-7 tube and chamber With sv_neo_reload_experimental, the Supa-7 holds six rounds in a tube and one in the chamber, seven in all as before. The tube and the chamber are networked and predicted, and the HUD shows the tube count and the chambered round. Reload input, the shell cadence, slugs and early fire stay as they were. Each round enters the tube at the reloadinsert frame where the hatch closes behind it, so a switch or a shot before then leaves it in the reserve. A slug loaded on a live shell goes into the tube. With no live round chambered, the gun plays the reloadend rack before it can fire, and the round is fed when the pump is home. A switch or a drop cancels a rack or an insert that has not reached that point. With the cvar at 0 the weapon behaves as before. --- src/game/shared/neo/weapons/weapon_supa7.cpp | 345 ++++++++++++++++++- src/game/shared/neo/weapons/weapon_supa7.h | 48 +++ 2 files changed, 385 insertions(+), 8 deletions(-) diff --git a/src/game/shared/neo/weapons/weapon_supa7.cpp b/src/game/shared/neo/weapons/weapon_supa7.cpp index d3ca85d258..00e1e90287 100644 --- a/src/game/shared/neo/weapons/weapon_supa7.cpp +++ b/src/game/shared/neo/weapons/weapon_supa7.cpp @@ -1,5 +1,6 @@ #include "cbase.h" #include "weapon_supa7.h" +#include "neo_gamerules.h" // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" @@ -12,12 +13,24 @@ BEGIN_NETWORK_TABLE(CWeaponSupa7, DT_WeaponSupa7) RecvPropBool(RECVINFO(m_bWeaponRaised)), RecvPropBool(RECVINFO(m_bShellInChamber)), RecvPropFloat(RECVINFO(m_flNextReload)), + RecvPropInt(RECVINFO(m_nTubeCount)), + RecvPropInt(RECVINFO(m_nTubeSlugs)), + RecvPropInt(RECVINFO(m_nChamber)), + RecvPropInt(RECVINFO(m_nInsert)), + RecvPropTime(RECVINFO(m_flInsertCreditTime)), + RecvPropTime(RECVINFO(m_flRackFeedTime)), #else SendPropBool(SENDINFO(m_bSlugDelayed)), SendPropBool(SENDINFO(m_bSlugLoaded)), SendPropBool(SENDINFO(m_bWeaponRaised)), SendPropBool(SENDINFO(m_bShellInChamber)), SendPropFloat(SENDINFO(m_flNextReload)), + SendPropInt(SENDINFO(m_nTubeCount), 4, SPROP_UNSIGNED), + SendPropInt(SENDINFO(m_nTubeSlugs), 8, SPROP_UNSIGNED), + SendPropInt(SENDINFO(m_nChamber), 2, SPROP_UNSIGNED), + SendPropInt(SENDINFO(m_nInsert), 2, SPROP_UNSIGNED), + SendPropTime(SENDINFO(m_flInsertCreditTime)), + SendPropTime(SENDINFO(m_flRackFeedTime)), #endif END_NETWORK_TABLE() @@ -28,6 +41,12 @@ BEGIN_PREDICTION_DATA(CWeaponSupa7) DEFINE_PRED_FIELD(m_bWeaponRaised, FIELD_BOOLEAN, FTYPEDESC_INSENDTABLE), DEFINE_PRED_FIELD(m_bShellInChamber, FIELD_BOOLEAN, FTYPEDESC_INSENDTABLE), DEFINE_PRED_FIELD(m_flNextReload, FIELD_FLOAT, FTYPEDESC_INSENDTABLE), + DEFINE_PRED_FIELD(m_nTubeCount, FIELD_INTEGER, FTYPEDESC_INSENDTABLE), + DEFINE_PRED_FIELD(m_nTubeSlugs, FIELD_INTEGER, FTYPEDESC_INSENDTABLE), + DEFINE_PRED_FIELD(m_nChamber, FIELD_INTEGER, FTYPEDESC_INSENDTABLE), + DEFINE_PRED_FIELD(m_nInsert, FIELD_INTEGER, FTYPEDESC_INSENDTABLE), + DEFINE_PRED_FIELD(m_flInsertCreditTime, FIELD_FLOAT, FTYPEDESC_INSENDTABLE), + DEFINE_PRED_FIELD(m_flRackFeedTime, FIELD_FLOAT, FTYPEDESC_INSENDTABLE), END_PREDICTION_DATA() #endif @@ -42,6 +61,12 @@ BEGIN_DATADESC(CWeaponSupa7) DEFINE_FIELD(m_bWeaponRaised, FIELD_BOOLEAN), DEFINE_FIELD(m_bShellInChamber, FIELD_BOOLEAN), DEFINE_FIELD(m_flNextReload, FIELD_FLOAT), + DEFINE_FIELD(m_nTubeCount, FIELD_INTEGER), + DEFINE_FIELD(m_nTubeSlugs, FIELD_INTEGER), + DEFINE_FIELD(m_nChamber, FIELD_INTEGER), + DEFINE_FIELD(m_nInsert, FIELD_INTEGER), + DEFINE_FIELD(m_flInsertCreditTime, FIELD_TIME), + DEFINE_FIELD(m_flRackFeedTime, FIELD_TIME), END_DATADESC() #endif @@ -65,6 +90,13 @@ IMPLEMENT_ACTTABLE(CWeaponSupa7); #endif #endif +// Viewmodel frames of the shipped team models, which play at this rate +static constexpr float VM_FRAMES_PER_SECOND = 30.0f; +// reloadinsert: the hatch closes behind the round, which is then in the tube +static constexpr float INSERT_ROUND_IN_TUBE_TIME = 12.0f / VM_FRAMES_PER_SECOND; +// reloadend: the pump is forward again with the next round chambered +static constexpr float RACK_PUMP_HOME_TIME = 21.0f / VM_FRAMES_PER_SECOND; + CWeaponSupa7::CWeaponSupa7(void) { m_bReloadsSingly = true; @@ -73,6 +105,12 @@ CWeaponSupa7::CWeaponSupa7(void) m_bWeaponRaised = false; m_bShellInChamber = true; m_flNextReload = 0.0f; + m_nTubeCount = 0; + m_nTubeSlugs = 0; + m_nChamber = SUPA7_CHAMBER_EMPTY; + m_nInsert = SUPA7_INSERT_NONE; + m_flInsertCreditTime = 0.0f; + m_flRackFeedTime = 0.0f; m_fMinRange1 = 0.0; m_fMaxRange1 = 500; @@ -90,7 +128,8 @@ CWeaponSupa7::CWeaponSupa7(void) // Purpose: Override so only reload one shell at a time bool CWeaponSupa7::StartReload(void) { - if (m_bSlugLoaded) + // the tube takes shells behind a chambered slug + if (m_bSlugLoaded && !IsTubeEnabled()) return false; CBaseCombatCharacter* pOwner = GetOwner(); @@ -116,6 +155,16 @@ bool CWeaponSupa7::StartReload(void) if (m_iClip1 >= GetMaxClip1()) return false; + if (IsTubeEnabled()) + { + SyncTube(); + if (m_nTubeCount >= TubeCapacity()) + { + return false; + } + m_nInsert = SUPA7_INSERT_NONE; + } + SendWeaponAnim(ACT_SHOTGUN_RELOAD_START); SetShotgunShellVisible(true); @@ -147,6 +196,15 @@ bool CWeaponSupa7::StartReloadSlug(void) if (m_iClip1 >= GetMaxClip1()) return false; + if (IsTubeEnabled()) + { + SyncTube(); + if (m_nTubeCount >= TubeCapacity()) + { + return false; + } + } + if (!m_bInReload) { SendWeaponAnim(ACT_SHOTGUN_RELOAD_START); @@ -185,10 +243,14 @@ bool CWeaponSupa7::Reload(void) if (m_iClip1 >= GetMaxClip1()) return false; + if (IsTubeEnabled() && m_nTubeCount >= TubeCapacity()) + return false; + // Play reload on different channel as otherwise steals channel away from fire sound WeaponSound(SPECIAL1); SendWeaponAnim(ACT_VM_RELOAD); pOwner->DoAnimationEvent(PLAYERANIMEVENT_RELOAD); + StartInsert(SUPA7_INSERT_SHELL); pOwner->m_flNextAttack = gpGlobals->curtime; constexpr float TIME_BETWEEN_SHELLS_LOADED = 0.5f; @@ -222,13 +284,22 @@ bool CWeaponSupa7::ReloadSlug(void) if (m_iClip1 >= GetMaxClip1()) return false; - FillClipSlug(); - m_bShellInChamber = false; + if (IsTubeEnabled()) + { + if (m_nTubeCount >= TubeCapacity()) + return false; + } + else + { + FillClipSlug(); + m_bShellInChamber = false; + } // Play reload on different channel as otherwise steals channel away from fire sound WeaponSound(SPECIAL1); SendWeaponAnim(ACT_VM_RELOAD); pOwner->DoAnimationEvent(PLAYERANIMEVENT_RELOAD); + StartInsert(SUPA7_INSERT_SLUG); pOwner->m_flNextAttack = gpGlobals->curtime; // ProposeNextAttack(gpGlobals->curtime + SequenceDuration()); @@ -249,6 +320,23 @@ void CWeaponSupa7::FinishReload(void) m_bInReload = false; + if (IsTubeEnabled()) + { + // A round still in the hand goes back to the reserve; an empty chamber is racked before the next shot + CancelInsert(); + SyncTube(); + if (!IsChamberLive() && m_nTubeCount > 0) + { + StartRack(); + } + else + { + SendWeaponAnim(ACT_SHOTGUN_RELOAD_FINISH); + } + pOwner->m_flNextAttack = gpGlobals->curtime; + return; + } + // Finish reload animation if (!m_bShellInChamber) { @@ -317,6 +405,15 @@ void CWeaponSupa7::PrimaryAttack(void) return; } + if (IsTubeEnabled()) + { + SyncTube(); + if (!IsChamberLive()) + { + return; + } + } + int numBullets = GetNEOWpnData().m_iBullets; Vector bulletSpread = GetBulletSpread(); int ammoType = m_iPrimaryAmmoType; @@ -352,14 +449,23 @@ void CWeaponSupa7::PrimaryAttack(void) pPlayer->DoMuzzleFlash(); SendWeaponAnim(m_bSlugLoaded ? ACT_VM_PRIMARYATTACK : ACT_VM_SECONDARYATTACK); - m_bSlugLoaded = false; // Don't fire again until fire animation has completed ProposeNextAttack(gpGlobals->curtime + GetFireRate()); - m_iClip1 -= 1; - if (m_iClip1 == 0) + if (IsTubeEnabled()) { - m_bShellInChamber = false; + // the fire animation's pump ejects the hull and feeds the tube's last-loaded round + m_nChamber = SUPA7_CHAMBER_HULL; + FeedChamber(); + } + else + { + m_bSlugLoaded = false; + m_iClip1 -= 1; + if (m_iClip1 == 0) + { + m_bShellInChamber = false; + } } // player "shoot" animation @@ -401,6 +507,10 @@ void CWeaponSupa7::ClearDelayedInputs(void) // for not having to do a larger rewrite. m_bInReload.GetForModify() = false; + // a rack or insert cut off by the drop does nothing for the next owner + CancelInsert(); + m_flRackFeedTime = 0.0f; + SetShotgunShellVisible(false); } @@ -413,6 +523,12 @@ void CWeaponSupa7::ItemPostFrame(void) return; } ProcessAnimationEvents(); + if (IsTubeEnabled()) + { + SyncTube(); + RunInsert(); + RunRack(); + } if (m_bInReload) { @@ -433,6 +549,16 @@ void CWeaponSupa7::ItemPostFrame(void) m_bSlugDelayed.GetForModify() = false; } } + else if (IsTubeEnabled()) + { + // a slug insert ends the reload, as it does without the tube + const bool bSlugInserted = (m_nInsert == SUPA7_INSERT_SLUG); + m_nInsert = SUPA7_INSERT_NONE; + if (m_iPrimaryAmmoCount <= 0 || bSlugInserted || m_nTubeCount >= TubeCapacity() || !Reload()) + { + FinishReload(); + } + } else { // If out of ammo end reload @@ -475,6 +601,11 @@ void CWeaponSupa7::ItemPostFrame(void) { DryFire(); } + // rounds in the tube and none in the chamber: the trigger racks one up first + else if (IsTubeEnabled() && !IsChamberLive()) + { + StartRack(); + } // Fire underwater? else if (pOwner->GetWaterLevel() == WL_Eyes && !m_bFiresUnderwater) { @@ -497,7 +628,11 @@ void CWeaponSupa7::ItemPostFrame(void) if (!(pOwner->m_nButtons & IN_ATTACK) && m_flNextPrimaryAttack <= gpGlobals->curtime && pOwner->m_nButtons & IN_RELOAD && UsesClipsForAmmo1() && !m_bInReload) { // reload when reload is pressed, or if no buttons are down and weapon is empty. - StartReload(); + // With nothing to load, a press racks up a round for an empty chamber + if (!StartReload() && IsTubeEnabled() && (pOwner->m_afButtonPressed & IN_RELOAD) && !IsChamberLive() && m_nTubeCount > 0) + { + StartRack(); + } } else if (!(pOwner->m_nButtons & IN_ATTACK) && m_flNextPrimaryAttack <= gpGlobals->curtime && pOwner->m_nButtons & IN_ATTACK2 && UsesClipsForAmmo1() && !m_bInReload) { @@ -525,6 +660,200 @@ void CWeaponSupa7::ItemPostFrame(void) } } +bool CWeaponSupa7::IsTubeEnabled() const +{ + return NEORules() && NEORules()->IsReloadExperimental(); +} + +// Rebuild the tube from the clip count when something set the count directly (a new or picked-up gun, a give): +// a live round in the chamber, shells in the tube +void CWeaponSupa7::SyncTube() +{ + if (IsTubeSynced()) + { + return; + } + + const int iClip = Clamp(m_iClip1.Get(), 0, GetMaxClip1()); + m_nChamber = (iClip > 0) ? (m_bSlugLoaded ? SUPA7_CHAMBER_SLUG : SUPA7_CHAMBER_SHELL) : SUPA7_CHAMBER_EMPTY; + m_nTubeCount = Max(0, iClip - SUPA7_CHAMBER_ROUNDS); + m_nTubeSlugs = 0; + UpdateClipFromTube(); +} + +void CWeaponSupa7::TubePush(Supa7Insert_t round) +{ + if (m_nTubeCount >= TubeCapacity()) + { + return; + } + + if (round == SUPA7_INSERT_SLUG) + { + m_nTubeSlugs |= (1 << m_nTubeCount); + } + else + { + m_nTubeSlugs &= ~(1 << m_nTubeCount); + } + m_nTubeCount += 1; + UpdateClipFromTube(); +} + +// The pump ejects a hull and feeds the tube's last-loaded round; a live round stays where it is +void CWeaponSupa7::FeedChamber() +{ + if (IsChamberLive()) + { + return; + } + + if (m_nTubeCount <= 0) + { + m_nChamber = SUPA7_CHAMBER_EMPTY; + UpdateClipFromTube(); + return; + } + + m_nTubeCount -= 1; + const bool bSlug = (m_nTubeSlugs & (1 << m_nTubeCount)) != 0; + m_nTubeSlugs &= ~(1 << m_nTubeCount); + m_nChamber = bSlug ? SUPA7_CHAMBER_SLUG : SUPA7_CHAMBER_SHELL; + UpdateClipFromTube(); +} + +// The counts the rest of the game reads: live rounds in the gun, and the chambered round's type +void CWeaponSupa7::UpdateClipFromTube() +{ + m_iClip1 = m_nTubeCount + (IsChamberLive() ? 1 : 0); + m_bSlugLoaded = (m_nChamber == SUPA7_CHAMBER_SLUG); + m_bShellInChamber = IsChamberLive(); +} + +// The reserve gives up the round only when it is in the tube, so an insert cut off before then costs nothing +void CWeaponSupa7::StartInsert(Supa7Insert_t round) +{ + if (!IsTubeEnabled()) + { + return; + } + + m_nInsert = round; + m_flInsertCreditTime = gpGlobals->curtime + INSERT_ROUND_IN_TUBE_TIME; +} + +void CWeaponSupa7::RunInsert() +{ + if (m_flInsertCreditTime <= 0.0f || gpGlobals->curtime < m_flInsertCreditTime) + { + return; + } + + m_flInsertCreditTime = 0.0f; + if (m_nTubeCount >= TubeCapacity()) + { + return; + } + + if (m_nInsert == SUPA7_INSERT_SLUG && m_iSecondaryAmmoCount > 0) + { + TubePush(SUPA7_INSERT_SLUG); + m_iSecondaryAmmoCount -= 1; + } + else if (m_nInsert == SUPA7_INSERT_SHELL && m_iPrimaryAmmoCount > 0) + { + TubePush(SUPA7_INSERT_SHELL); + m_iPrimaryAmmoCount -= 1; + } +} + +void CWeaponSupa7::CancelInsert() +{ + m_nInsert = SUPA7_INSERT_NONE; + m_flInsertCreditTime = 0.0f; +} + +// The shipped reload's finishing rack, also played alone: the gun fires only once it ends +void CWeaponSupa7::StartRack() +{ + CBaseCombatCharacter *pOwner = GetOwner(); + if (!pOwner) + { + return; + } + + SendWeaponAnim(ACT_SHOTGUN_PUMP); + WeaponSound(SPECIAL2); + + const float flDuration = ViewModelSequenceDuration(); + m_flRackFeedTime = gpGlobals->curtime + Min(RACK_PUMP_HOME_TIME, flDuration); + pOwner->m_flNextAttack = gpGlobals->curtime; + ProposeNextAttack(gpGlobals->curtime + flDuration); + SetWeaponIdleTime(gpGlobals->curtime + flDuration); +} + +void CWeaponSupa7::RunRack() +{ + if (m_flRackFeedTime <= 0.0f || gpGlobals->curtime < m_flRackFeedTime) + { + return; + } + + m_flRackFeedTime = 0.0f; + FeedChamber(); +} + +// The viewmodel plays the sequence; the weapon entity can carry the world model on the client +float CWeaponSupa7::ViewModelSequenceDuration() const +{ + CBasePlayer *pOwner = ToBasePlayer(GetOwner()); + CBaseViewModel *pVM = pOwner ? pOwner->GetViewModel(m_nViewModelIndex) : nullptr; + return pVM ? pVM->SequenceDuration() : 0.0f; +} + +bool CWeaponSupa7::Holster(CBaseCombatWeapon *pSwitchingTo) +{ + // Credited rounds stay in the tube; a round still in the hand and a rack before its pump is home do nothing + if (IsTubeEnabled()) + { + CancelInsert(); + m_flRackFeedTime = 0.0f; + m_bSlugDelayed = false; + } + return BaseClass::Holster(pSwitchingTo); +} + +bool CWeaponSupa7::HasChamberSlot() const +{ + return IsTubeEnabled() || BaseClass::HasChamberSlot(); +} + +bool CWeaponSupa7::IsRoundChambered() const +{ + if (!IsTubeEnabled()) + { + return BaseClass::IsRoundChambered(); + } + + // before the first update rebuilds the tube from a new clip count, a loaded gun has a round chambered + return IsTubeSynced() ? IsChamberLive() : (m_iClip1 > 0); +} + +int CWeaponSupa7::RoundsInMagazine() const +{ + if (!IsTubeEnabled()) + { + return BaseClass::RoundsInMagazine(); + } + + return IsTubeSynced() ? m_nTubeCount.Get() : Max(0, m_iClip1 - SUPA7_CHAMBER_ROUNDS); +} + +int CWeaponSupa7::MagazineCapacity() const +{ + return IsTubeEnabled() ? TubeCapacity() : BaseClass::MagazineCapacity(); +} + const WeaponSpreadInfo_t &CWeaponSupa7::GetSpreadInfo() { Assert(m_weaponHandling.weaponID & GetNeoWepBits()); diff --git a/src/game/shared/neo/weapons/weapon_supa7.h b/src/game/shared/neo/weapons/weapon_supa7.h index f585f15803..3a463b846b 100644 --- a/src/game/shared/neo/weapons/weapon_supa7.h +++ b/src/game/shared/neo/weapons/weapon_supa7.h @@ -63,6 +63,30 @@ class CWeaponSupa7 : public CNEOBaseCombatWeapon void ClearDelayedInputs(void); bool CanBePickedUpByClass(int classId) OVERRIDE; + bool Holster(CBaseCombatWeapon *pSwitchingTo) OVERRIDE; + + // Clip1 stays the live rounds in the gun: the tube plus the chambered round + bool HasChamberSlot() const OVERRIDE; + bool IsRoundChambered() const OVERRIDE; + int RoundsInMagazine() const OVERRIDE; + int MagazineCapacity() const OVERRIDE; + + // What sits in the chamber: a live shell or slug, the hull of a fired one, or nothing + enum Supa7Chamber_t + { + SUPA7_CHAMBER_EMPTY = 0, + SUPA7_CHAMBER_SHELL, + SUPA7_CHAMBER_SLUG, + SUPA7_CHAMBER_HULL, + }; + + // The round in the hand of the insert that is playing + enum Supa7Insert_t + { + SUPA7_INSERT_NONE = 0, + SUPA7_INSERT_SHELL, + SUPA7_INSERT_SLUG, + }; protected: virtual float GetFastestDryRefireTime() const OVERRIDE { return 0.2f; } @@ -77,6 +101,21 @@ class CWeaponSupa7 : public CNEOBaseCombatWeapon } } + bool IsTubeEnabled() const; + bool IsChamberLive() const { return m_nChamber == SUPA7_CHAMBER_SHELL || m_nChamber == SUPA7_CHAMBER_SLUG; } + bool IsTubeSynced() const { return m_nTubeCount + (IsChamberLive() ? 1 : 0) == m_iClip1; } + int TubeCapacity() const { return GetMaxClip1() - SUPA7_CHAMBER_ROUNDS; } + void SyncTube(); + void TubePush(Supa7Insert_t round); + void FeedChamber(); + void UpdateClipFromTube(); + void StartInsert(Supa7Insert_t round); + void RunInsert(); + void CancelInsert(); + void StartRack(); + void RunRack(); + float ViewModelSequenceDuration() const; + void SetShotgunShellVisible(bool is_visible) { const int bodygroup_shell = 1; @@ -91,6 +130,15 @@ class CWeaponSupa7 : public CNEOBaseCombatWeapon CNetworkVar(bool, m_bShellInChamber); // Slug currently loaded in chamber CNetworkVar(float, m_flNextReload); // Time to load the next shell + // sv_neo_reload_experimental: the tube is a stack, the last round loaded is the first fed + static constexpr int SUPA7_CHAMBER_ROUNDS = 1; + CNetworkVar(int, m_nTubeCount); // rounds in the tube + CNetworkVar(int, m_nTubeSlugs); // bit i: the round at tube position i (0 = loaded first) is a slug + CNetworkVar(int, m_nChamber); // Supa7Chamber_t + CNetworkVar(int, m_nInsert); // Supa7Insert_t + CNetworkVar(float, m_flInsertCreditTime); // when the inserted round enters the tube, 0 none + CNetworkVar(float, m_flRackFeedTime); // when the rack's pump is home with the next round, 0 none + private: CWeaponSupa7(const CWeaponSupa7 &other); }; From e42b2ee627d7af187bcc96e99e2a959fa862d2f3 Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sun, 8 Nov 2026 12:50:12 -0700 Subject: [PATCH 39/55] Load one Supa-7 slug per alt-fire request With the tube, a slug insert leaves the shell in the chamber, so the chambered-slug check no longer stops a held alt-fire from asking again. The repeat queued a second slug and pushed the attack and reload deadlines out, which also blocked early fire. Refuse a slug request while one is queued or being inserted. Confirmed in client runs g1 (two slugs from one hold) and g2 (one). --- src/game/shared/neo/weapons/weapon_supa7.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/game/shared/neo/weapons/weapon_supa7.cpp b/src/game/shared/neo/weapons/weapon_supa7.cpp index 00e1e90287..126e1bb0f2 100644 --- a/src/game/shared/neo/weapons/weapon_supa7.cpp +++ b/src/game/shared/neo/weapons/weapon_supa7.cpp @@ -198,6 +198,12 @@ bool CWeaponSupa7::StartReloadSlug(void) if (IsTubeEnabled()) { + // One slug per request: a held alt-fire neither queues another nor delays the shot + if (m_bSlugDelayed || m_nInsert == SUPA7_INSERT_SLUG) + { + return false; + } + SyncTube(); if (m_nTubeCount >= TubeCapacity()) { From ebeb627fd23542e05c75e30f11bfb1529950ca57 Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sun, 8 Nov 2026 13:50:25 -0700 Subject: [PATCH 40/55] Chamber the SRS round when the bolt is home With reload phases a shot leaves the chamber empty until the bolt closes, so the HUD chamber lights and the magazine row drops then, not at the shot. The moment is the charge table's 3_cycle row. A switch before bolt home resumes the bolt after the next draw; a reload cancels the bolt and keeps the round. Fire timing is unchanged. --- src/game/shared/neo/weapons/weapon_srs.cpp | 70 ++++++++++++++++++++-- src/game/shared/neo/weapons/weapon_srs.h | 9 +++ 2 files changed, 75 insertions(+), 4 deletions(-) diff --git a/src/game/shared/neo/weapons/weapon_srs.cpp b/src/game/shared/neo/weapons/weapon_srs.cpp index ae21ebf7ee..cb1e9ed20c 100644 --- a/src/game/shared/neo/weapons/weapon_srs.cpp +++ b/src/game/shared/neo/weapons/weapon_srs.cpp @@ -10,8 +10,12 @@ BEGIN_NETWORK_TABLE(CWeaponSRS, DT_WeaponSRS) DEFINE_NEO_BASE_WEP_NETWORK_TABLE #ifdef CLIENT_DLL RecvPropBool(RECVINFO(m_bNeedsBolting)), + RecvPropTime(RECVINFO(m_flBoltHomeTime)), + RecvPropTime(RECVINFO(m_flBoltStartTime)), #else SendPropBool(SENDINFO(m_bNeedsBolting)), + SendPropTime(SENDINFO(m_flBoltHomeTime)), + SendPropTime(SENDINFO(m_flBoltStartTime)), #endif END_NETWORK_TABLE() @@ -19,6 +23,8 @@ END_NETWORK_TABLE() BEGIN_PREDICTION_DATA(CWeaponSRS) DEFINE_NEO_BASE_WEP_PREDICTION DEFINE_PRED_FIELD(m_bNeedsBolting, FIELD_BOOLEAN, FTYPEDESC_INSENDTABLE), + DEFINE_PRED_FIELD(m_flBoltHomeTime, FIELD_FLOAT, FTYPEDESC_INSENDTABLE), + DEFINE_PRED_FIELD(m_flBoltStartTime, FIELD_FLOAT, FTYPEDESC_INSENDTABLE), END_PREDICTION_DATA() #endif @@ -28,6 +34,9 @@ LINK_ENTITY_TO_CLASS(weapon_srs, CWeaponSRS); PRECACHE_WEAPON_REGISTER(weapon_srs); +// The bolt cycle after a shot; the 3_cycle row of its phase table gives when the bolt is home with the next round +static constexpr const char *VM_SEQ_CHARGE = "charge"; + CWeaponSRS::CWeaponSRS() { m_flSoonestAttack = gpGlobals->curtime; @@ -35,6 +44,8 @@ CWeaponSRS::CWeaponSRS() m_nNumShotsFired = 0; m_bNeedsBolting = false; + m_flBoltHomeTime = 0.0f; + m_flBoltStartTime = 0.0f; m_weaponSeeds = { "srspx", @@ -60,6 +71,8 @@ void CWeaponSRS::PrimaryAttack() } m_bNeedsBolting = true; + m_flBoltHomeTime = 0.0f; + m_flBoltStartTime = 0.0f; BaseClass::PrimaryAttack(); } @@ -70,7 +83,7 @@ void CWeaponSRS::ItemPreFrame() return BaseClass::ItemPreFrame(); } - if (m_flLastAttackTime + 0.08f <= gpGlobals->curtime) + if (m_flLastAttackTime + 0.08f <= gpGlobals->curtime && m_flBoltStartTime <= gpGlobals->curtime) { // Primary attack animation finished, begin chambering a round if (auto* pOwner = ToNEOPlayer(GetOwner())) { if (pOwner->m_nButtons & IN_ATTACK) @@ -83,6 +96,17 @@ void CWeaponSRS::ItemPreFrame() SendWeaponAnim(ACT_VM_PULLBACK); WeaponSound(SPECIAL1); m_bNeedsBolting = false; + + if (IsReloadPhaseSystemEnabled()) + { + // The round counts as chambered once the bolt is home + const CNEOWeaponInfo &info = GetNEOWpnData(); + const int iTable = info.FindReloadTable(VM_SEQ_CHARGE); + if (iTable >= 0 && info.m_reloadTables[iTable].iNumRows > 0) + { + m_flBoltHomeTime = gpGlobals->curtime + info.m_reloadTables[iTable].rows[0].flAmmo; + } + } } BaseClass::ItemPreFrame(); @@ -91,10 +115,20 @@ void CWeaponSRS::ItemPreFrame() bool CWeaponSRS::Deploy() { // This is on purpose; the player is allowed to cancel the bolting animation - // with a quick-switch input. - m_bNeedsBolting = false; + // with a quick-switch input. With reload phases the round does not count as + // chambered before the bolt is home, so a cut-short cycle resumes after the draw. + const bool bResumeBolt = IsReloadPhaseSystemEnabled() && m_bNeedsBolting; + m_bNeedsBolting = bResumeBolt; + m_flBoltHomeTime = 0.0f; + m_flBoltStartTime = 0.0f; + + const bool bDeployed = BaseClass::Deploy(); + if (bResumeBolt) + { + m_flBoltStartTime = m_flNextPrimaryAttack; + } - return BaseClass::Deploy(); + return bDeployed; } bool CWeaponSRS::Reload() @@ -102,10 +136,38 @@ bool CWeaponSRS::Reload() // The reloading animation already contains the bolting motion; // we don't want to bolt twice. m_bNeedsBolting = false; + m_flBoltHomeTime = 0.0f; return BaseClass::Reload(); } +bool CWeaponSRS::IsBoltPending() const +{ + return m_bNeedsBolting || gpGlobals->curtime < m_flBoltHomeTime; +} + +bool CWeaponSRS::Holster(CBaseCombatWeapon *pSwitchingTo) +{ + // Time passes while holstered, so note that the bolt is not home for the next draw + if (IsReloadPhaseSystemEnabled() && IsBoltPending()) + { + m_bNeedsBolting = true; + m_flBoltHomeTime = 0.0f; + } + + return BaseClass::Holster(pSwitchingTo); +} + +bool CWeaponSRS::IsRoundChambered() const +{ + if (HasChamberSlot() && IsBoltPending()) + { + return false; + } + + return BaseClass::IsRoundChambered(); +} + bool CWeaponSRS::CanBePickedUpByClass(int classId) { return classId != NEO_CLASS_JUGGERNAUT; diff --git a/src/game/shared/neo/weapons/weapon_srs.h b/src/game/shared/neo/weapons/weapon_srs.h index b6c632f153..2248417b5c 100644 --- a/src/game/shared/neo/weapons/weapon_srs.h +++ b/src/game/shared/neo/weapons/weapon_srs.h @@ -37,6 +37,8 @@ class CWeaponSRS : public CNEOBaseCombatWeapon virtual bool Deploy() override; virtual void PrimaryAttack() override; virtual bool Reload(void) OVERRIDE; + virtual bool Holster(CBaseCombatWeapon *pSwitchingTo) OVERRIDE; + bool IsRoundChambered() const OVERRIDE; NEO_WEP_BITS_UNDERLYING_TYPE WeaponIndex() const override { return NEO_WIDX_SRS; } virtual NEO_WEP_BITS_UNDERLYING_TYPE GetNeoWepBits(void) const override { return NEO_WEP_SRS | NEO_WEP_SCOPEDWEAPON | NEO_WEP_FIREARM; } @@ -53,7 +55,14 @@ class CWeaponSRS : public CNEOBaseCombatWeapon private: CWeaponSRS(const CWeaponSRS &other); + // Whether the bolt cycle after a shot has not finished yet + bool IsBoltPending() const; + CNetworkVar(bool, m_bNeedsBolting); + // The bolt is home, and a round chambered, at this time; 0: no bolt cycle is running + CNetworkVar(float, m_flBoltHomeTime); + // A bolt cycle resumed by a draw starts no earlier than this time + CNetworkVar(float, m_flBoltStartTime); }; #endif // NEO_WEAPON_SRS_H From 070f5b210347b221e5fb7e39ec250bd68b98751a Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sun, 8 Nov 2026 14:04:20 -0700 Subject: [PATCH 41/55] Hold the SRS shot until the bolt is home An unchambered SRS completes its bolt cycle before it can fire, as the Supa-7 racks first. A press while the round is not chambered is ignored. --- src/game/shared/neo/weapons/weapon_srs.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/game/shared/neo/weapons/weapon_srs.cpp b/src/game/shared/neo/weapons/weapon_srs.cpp index cb1e9ed20c..93e603a4fc 100644 --- a/src/game/shared/neo/weapons/weapon_srs.cpp +++ b/src/game/shared/neo/weapons/weapon_srs.cpp @@ -63,6 +63,12 @@ void CWeaponSRS::PrimaryAttack() return BaseClass::PrimaryAttack(); } + // An unchambered gun completes its bolt cycle before it can fire; the press is ignored + if (HasChamberSlot() && IsBoltPending()) + { + return; + } + const bool tryingToShootTooFast = (gpGlobals->curtime < m_flLastAttackTime + GetFireRate()); if (tryingToShootTooFast) From 93ce87752a07c10c43a0d26209b130c247819290 Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sun, 8 Nov 2026 16:25:08 -0700 Subject: [PATCH 42/55] Cut the reload gesture change to the resume fix Only the weapon adoption in the reload event matters in this PR. A reload resumed in the draw raises its event after the weapon change, and the anim state then clears the attack and reload slot on its next update, so others saw no reload during the resume. The event now carries a named resume marker; with it, the anim state adopts the active weapon so the gesture survives. A plain reload event (data 0) runs master's code. The gesture fit (start part way, blend in) never runs here: the ZR68C resume (2.70 s) outlasts every Reload_ZR68C gesture (2.47-2.67 s). It moves to the full reload-phases change, whose partials and short resumes need it. --- .../shared/hl2mp/hl2mp_playeranimstate.cpp | 103 +----------------- src/game/shared/hl2mp/hl2mp_playeranimstate.h | 12 +- .../weapons/weapon_neobasecombatweapon.cpp | 4 +- 3 files changed, 9 insertions(+), 110 deletions(-) diff --git a/src/game/shared/hl2mp/hl2mp_playeranimstate.cpp b/src/game/shared/hl2mp/hl2mp_playeranimstate.cpp index fab73546c2..3d12e77d44 100644 --- a/src/game/shared/hl2mp/hl2mp_playeranimstate.cpp +++ b/src/game/shared/hl2mp/hl2mp_playeranimstate.cpp @@ -80,10 +80,6 @@ CHL2MPPlayerAnimState* CreateHL2MPPlayerAnimState( CHL2MP_Player *pPlayer ) CHL2MPPlayerAnimState::CHL2MPPlayerAnimState() { m_pHL2MPPlayer = NULL; -#ifdef NEO - m_iReloadGestureSequence = -1; - m_flReloadGestureStartCycle = 0.0f; -#endif // Don't initialize HL2MP specific variables here. Init them in InitHL2MPAnimState() } @@ -97,10 +93,6 @@ CHL2MPPlayerAnimState::CHL2MPPlayerAnimState( CBasePlayer *pPlayer, MultiPlayerM : CMultiPlayerAnimState( pPlayer, movementData ) { m_pHL2MPPlayer = NULL; -#ifdef NEO - m_iReloadGestureSequence = -1; - m_flReloadGestureStartCycle = 0.0f; -#endif // Don't initialize HL2MP specific variables here. Init them in InitHL2MPAnimState() } @@ -190,7 +182,6 @@ void CHL2MPPlayerAnimState::ComputeSequences(CStudioHdr* pStudioHdr) // The groundspeed interpolator uses the main sequence info. UpdateInterpolators(); ComputeGestureSequence(pStudioHdr); - UpdateReloadGesture(); } #endif //NEO @@ -352,7 +343,11 @@ void CHL2MPPlayerAnimState::DoAnimationEvent( PlayerAnimEvent_t event, int nData { #ifdef NEO AddToGestureSlot(GESTURE_SLOT_ATTACK_AND_RELOAD, CalcReloadSequence(), true); - StartReloadGesture(nData); + if (nData == RELOAD_EVENT_RESUMED) + { + // A reload resumed by the draw starts with the weapon change, which would otherwise clear the gesture + m_hActiveWeapon = GetBasePlayer()->GetActiveWeapon(); + } #else // Weapon reload. if ( GetBasePlayer()->GetFlags() & FL_DUCKING ) @@ -1023,91 +1018,3 @@ void CHL2MPPlayerAnimState::DebugShowAnimStateFull(int iStartLine) AnimStateLog("--------------------------------------------\n\n"); } - -#ifdef NEO -// Start a gesture part way through its sequence, as AddVCDSequenceToGestureSlot does for scene gestures -void CHL2MPPlayerAnimState::SetGestureSlotCycle(int iGestureSlot, float flCycle) -{ - GestureSlot_t &slot = m_aGestureSlots[iGestureSlot]; - if (!slot.m_pAnimLayer) - { - return; - } - - slot.m_pAnimLayer->m_flCycle = flCycle; - slot.m_pAnimLayer->m_flPrevCycle = flCycle; -#ifdef CLIENT_DLL - if (CBasePlayer *pPlayer = GetBasePlayer()) - { - pPlayer->m_flOverlayPrevEventCycle[iGestureSlot] = flCycle; - } -#endif -} - -static constexpr float RELOAD_GESTURE_MS_PER_SECOND = 1000.0f; - -// The player models' reload gestures have no blend of their own, so a gesture started part way -// blends in over this long to hide the jump in pose -static constexpr float RELOAD_GESTURE_BLEND_TIME = 0.2f; - -int CHL2MPPlayerAnimState::ResumedReloadGestureData(float flDuration) -{ - return static_cast(Max(flDuration, 0.0f) * RELOAD_GESTURE_MS_PER_SECOND); -} - -// Fit the reload gesture just added to a resumed reload shorter than the gesture: play only the gesture's end, for as -// long as the resume lasts. An event without data plays the whole gesture -void CHL2MPPlayerAnimState::StartReloadGesture(int nData) -{ - m_iReloadGestureSequence = -1; - - CBasePlayer *pPlayer = GetBasePlayer(); - const GestureSlot_t &slot = m_aGestureSlots[GESTURE_SLOT_ATTACK_AND_RELOAD]; - if (nData <= 0 || !pPlayer || !slot.m_bActive || !slot.m_pAnimLayer) - { - return; - } - - // A reload resumed by the draw starts with the weapon change, which would otherwise clear the gesture - m_hActiveWeapon = pPlayer->GetActiveWeapon(); - - const int iSequence = slot.m_pAnimLayer->m_nSequence; - const float flDuration = nData / RELOAD_GESTURE_MS_PER_SECOND; - const float flCycles = flDuration * pPlayer->GetSequenceCycleRate(pPlayer->GetModelPtr(), iSequence); - if (flCycles >= 1.0f) - { - return; - } - - m_flReloadGestureStartCycle = 1.0f - flCycles; - m_iReloadGestureSequence = iSequence; - SetGestureSlotCycle(GESTURE_SLOT_ATTACK_AND_RELOAD, m_flReloadGestureStartCycle); -} - -// Blend a late-started reload gesture in from its start cycle -void CHL2MPPlayerAnimState::UpdateReloadGesture() -{ - if (m_iReloadGestureSequence < 0) - { - return; - } - - CBasePlayer *pPlayer = GetBasePlayer(); - GestureSlot_t &slot = m_aGestureSlots[GESTURE_SLOT_ATTACK_AND_RELOAD]; - if (!pPlayer || !slot.m_bActive || !slot.m_pAnimLayer || slot.m_pAnimLayer->m_nSequence != m_iReloadGestureSequence) - { - // a new gesture took the slot, or the reload gesture ended - m_iReloadGestureSequence = -1; - return; - } - - const float flBlendCycles = RELOAD_GESTURE_BLEND_TIME * pPlayer->GetSequenceCycleRate(pPlayer->GetModelPtr(), m_iReloadGestureSequence); - if (flBlendCycles <= 0.0f) - { - return; - } - - const float flWeight = (slot.m_pAnimLayer->m_flCycle - m_flReloadGestureStartCycle) / flBlendCycles; - slot.m_pAnimLayer->m_flWeight = clamp(flWeight, 0.0f, 1.0f); -} -#endif // NEO diff --git a/src/game/shared/hl2mp/hl2mp_playeranimstate.h b/src/game/shared/hl2mp/hl2mp_playeranimstate.h index b32af4f9f7..6b59010f62 100644 --- a/src/game/shared/hl2mp/hl2mp_playeranimstate.h +++ b/src/game/shared/hl2mp/hl2mp_playeranimstate.h @@ -48,8 +48,8 @@ class CHL2MPPlayerAnimState : public CMultiPlayerAnimState #ifdef NEO virtual void ComputeSequences(CStudioHdr* pStudioHdr); - // A resumed reload's event data: how long the first-person resume lasts - static int ResumedReloadGestureData(float flDuration); + // Reload event data: the draw resumes an interrupted reload + static constexpr int RELOAD_EVENT_RESUMED = 1; #endif void DebugShowAnimStateFull(int iStartLine); @@ -67,17 +67,9 @@ class CHL2MPPlayerAnimState : public CMultiPlayerAnimState #ifdef NEO bool IsLeaning(CStudioHdr *pStudioHdr); - void SetGestureSlotCycle(int iGestureSlot, float flCycle); - void StartReloadGesture(int nData); - void UpdateReloadGesture(); #endif // NEO CHL2MP_Player *m_pHL2MPPlayer; -#ifdef NEO - // The playing late-started reload gesture's sequence (-1: none) and the cycle it blends in from - int m_iReloadGestureSequence; - float m_flReloadGestureStartCycle; -#endif #ifndef NEO bool m_bInAirWalk; float m_flHoldDeployedPoseUntilTime; diff --git a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp index 9e3ded0fbf..8d0d327d65 100644 --- a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp +++ b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp @@ -626,9 +626,9 @@ bool CNEOBaseCombatWeapon::ResumeReload() } SendViewModelAnim(iSequence); - // the third-person reload gesture lasts no longer than the resume + ToHL2MPPlayer(GetOwner())->DoAnimationEvent(PLAYERANIMEVENT_RELOAD, CHL2MPPlayerAnimState::RELOAD_EVENT_RESUMED); + const float flDuration = ReloadViewModel()->SequenceDuration(iSequence); - ToHL2MPPlayer(GetOwner())->DoAnimationEvent(PLAYERANIMEVENT_RELOAD, CHL2MPPlayerAnimState::ResumedReloadGestureData(flDuration)); const float flEnd = gpGlobals->curtime + flDuration; GetOwner()->SetNextAttack(flEnd); From 7435ba272804116ff41389297fd86024dc8d5390 Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sun, 8 Nov 2026 16:25:48 -0700 Subject: [PATCH 43/55] Call the reload phases through one-line hooks Master's Reload, FinishReload, Deploy, Holster and ItemBusyFrame now gain one hook call each, and each hook checks the reload-phase gate itself. A reviewer can confirm the flag-off path by reading the early returns, and Deploy no longer chains the gate, a state test and the resume in one master expression. The header additions move into one commented block. Behavior is unchanged with the flag on and off. --- .../weapons/weapon_neobasecombatweapon.cpp | 94 +++++++++++++------ .../neo/weapons/weapon_neobasecombatweapon.h | 24 +++-- 2 files changed, 84 insertions(+), 34 deletions(-) diff --git a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp index 8d0d327d65..7d100292a3 100644 --- a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp +++ b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp @@ -464,13 +464,7 @@ bool CNEOBaseCombatWeapon::Reload( void ) // the animation and the wait to fire still run to the end m_flReloadReadyTime = Max(gpGlobals->curtime, m_flNextPrimaryAttack - GetNEOWpnData().m_flReloadReadyBeforeEnd); - if (IsReloadPhaseSystemEnabled()) - { - // the phases are those of the sequence the reload plays, such as reload or reloadempty - CBaseViewModel *pVM = ReloadViewModel(); - m_nReloadPhase = RELOAD_PHASE_NONE; - StartReloadPhases(pVM ? GetNEOWpnData().FindReloadTable(pVM->GetSequenceName(pVM->GetSequence())) : -1); - } + ReloadPhasesOnReload(); return true; @@ -510,6 +504,67 @@ bool CNEOBaseCombatWeapon::IsReloadPhaseSystemEnabled() const return NEORules() && NEORules()->IsReloadExperimental() && !GetNEOWpnData().m_reloadTables.IsEmpty(); } +// The phases are those of the sequence the reload plays, such as reload or reloadempty +void CNEOBaseCombatWeapon::ReloadPhasesOnReload() +{ + if (!IsReloadPhaseSystemEnabled()) + { + return; + } + + CBaseViewModel *pVM = ReloadViewModel(); + m_nReloadPhase = RELOAD_PHASE_NONE; + StartReloadPhases(pVM ? GetNEOWpnData().FindReloadTable(pVM->GetSequenceName(pVM->GetSequence())) : -1); +} + +// The magazine is in: the phases up to the load are done, and a switch from here leaves nothing to resume +void CNEOBaseCombatWeapon::ReloadPhasesOnFinish() +{ + if (!IsReloadPhaseSystemEnabled()) + { + return; + } + + m_nReloadPhase = Max(static_cast(m_nReloadPhase.Get()), RELOAD_PHASE_LOADED); +} + +// A reload interrupted by a switch goes on in the draw; returns whether it resumed +bool CNEOBaseCombatWeapon::ReloadPhasesOnDeploy() +{ + if (!IsReloadPhaseSystemEnabled() || m_nReloadPhase == RELOAD_PHASE_NONE) + { + return false; + } + + return ResumeReload(); +} + +// Only a phase that a sequence resumes from outlasts the switch, with the table that names the resume +void CNEOBaseCombatWeapon::ReloadPhasesOnHolster() +{ + if (!IsReloadPhaseSystemEnabled()) + { + return; + } + + StopReloadSoundPieces(); + if (!FindResumeSequence()) + { + m_nReloadPhase = RELOAD_PHASE_NONE; + m_nReloadTable = -1; + } +} + +void CNEOBaseCombatWeapon::ReloadPhasesOnBusyFrame() +{ + if (!IsReloadPhaseSystemEnabled()) + { + return; + } + + RunReloadPhases(); +} + // The viewmodel sequence that resumes the reload interrupted now, from the phase table of the playing sequence; // nullptr: none (resume sequences carry no activity, so they are picked by name) const char *CNEOBaseCombatWeapon::FindResumeSequence() const @@ -729,11 +784,7 @@ void CNEOBaseCombatWeapon::FinishReload(void) } m_flReloadReadyTime = 0.0f; - // the magazine is in: the phases up to the load are done, and a switch from here leaves nothing to resume - if (IsReloadPhaseSystemEnabled()) - { - m_nReloadPhase = Max(static_cast(m_nReloadPhase.Get()), RELOAD_PHASE_LOADED); - } + ReloadPhasesOnFinish(); CBaseCombatCharacter* pOwner = GetOwner(); @@ -784,8 +835,7 @@ bool CNEOBaseCombatWeapon::Deploy(void) // An empty weapon draws with its slide held back where the model has that draw, // which carries no activity, so it is picked by name static constexpr const char *VM_SEQ_DRAW_EMPTY = "drawempty"; - // a reload interrupted by a switch goes on in the draw - const bool bResumed = IsReloadPhaseSystemEnabled() && m_nReloadPhase != RELOAD_PHASE_NONE && ResumeReload(); + const bool bResumed = ReloadPhasesOnDeploy(); const int iDrawEmpty = (!bResumed && UsesClipsForAmmo1() && m_iClip1 <= 0) ? LookupSequence(VM_SEQ_DRAW_EMPTY) : ACTIVITY_NOT_AVAILABLE; if (iDrawEmpty != ACTIVITY_NOT_AVAILABLE) { @@ -853,16 +903,7 @@ float CNEOBaseCombatWeapon::GetPenetration() const bool CNEOBaseCombatWeapon::Holster(CBaseCombatWeapon* pSwitchingTo) { - // Only a phase that a sequence resumes from outlasts the switch, with the table that names the resume - if (IsReloadPhaseSystemEnabled()) - { - StopReloadSoundPieces(); - if (!FindResumeSequence()) - { - m_nReloadPhase = RELOAD_PHASE_NONE; - m_nReloadTable = -1; - } - } + ReloadPhasesOnHolster(); return BaseClass::Holster(pSwitchingTo); } @@ -919,10 +960,7 @@ void CNEOBaseCombatWeapon::ItemBusyFrame(void) BaseClass::ItemBusyFrame(); UpdateInaccuracy(); - if (IsReloadPhaseSystemEnabled()) - { - RunReloadPhases(); - } + ReloadPhasesOnBusyFrame(); // The owner stays busy until the reload animation ends, but the magazine loads at the reload's ready time if (m_bInReload && m_flReloadReadyTime > 0.0f && gpGlobals->curtime >= m_flReloadReadyTime) diff --git a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h index 9c1bdd2ee7..a197043f2e 100644 --- a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h +++ b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h @@ -264,7 +264,6 @@ class CNEOBaseCombatWeapon : public CBaseHL2MPCombatWeapon virtual float GetFireRate() override final; float GetPenetration() const; - void StopReloadOnDrop(); #ifdef CLIENT_DLL float m_flTemperature; int m_spawnflags; @@ -283,7 +282,6 @@ class CNEOBaseCombatWeapon : public CBaseHL2MPCombatWeapon virtual float GetMaxAccuracyPenalty() const { return 1.0; } virtual float GetAccuracyPenaltyDecay(); virtual float GetFastestDryRefireTime() const { Assert(false); return 0; } // Should never call this base class; implement in children. - bool IsReloadPhaseSystemEnabled() const; protected: CNetworkVar(float, m_flSoonestAttack); @@ -296,7 +294,19 @@ class CNEOBaseCombatWeapon : public CBaseHL2MPCombatWeapon // When the reload in progress loads the magazine, 0 once it is loaded CNetworkVar(float, m_flReloadReadyTime); - // Reload phases (weapons whose script has a ReloadPhases block): the last phase finished, kept across a switch +private: + CNEOBaseCombatWeapon(const CNEOBaseCombatWeapon &other); + bool HasEmptyIdle(); + + // Reload phases (sv_neo_reload_experimental, weapons whose script has a ReloadPhases block). + // Each hook checks IsReloadPhaseSystemEnabled itself, so with the flag off a hook call does nothing +public: + void StopReloadOnDrop(); + +protected: + bool IsReloadPhaseSystemEnabled() const; + + // the last phase finished, kept across a switch CNetworkVar(int, m_nReloadPhase); // the phase table of the reload sequence started last, -1 none CNetworkVar(int, m_nReloadTable); @@ -306,8 +316,11 @@ class CNEOBaseCombatWeapon : public CBaseHL2MPCombatWeapon CNetworkVar(int, m_nReloadSoundsDone); private: - CNEOBaseCombatWeapon(const CNEOBaseCombatWeapon &other); - bool HasEmptyIdle(); + void ReloadPhasesOnReload(); + void ReloadPhasesOnFinish(); + bool ReloadPhasesOnDeploy(); + void ReloadPhasesOnHolster(); + void ReloadPhasesOnBusyFrame(); void StartReloadPhases(int iTable); void RunReloadPhases(); @@ -318,7 +331,6 @@ class CNEOBaseCombatWeapon : public CBaseHL2MPCombatWeapon void EmitReloadSoundPiece(const char *pszSound); CBaseViewModel *ReloadViewModel() const; int LookupReloadSequence(const char *pszName) const; - }; #endif // WEAPON_NEO_BASECOMBATWEAPON_SHARED_H From 00aade087531af3dbe3a571cb61a9b1a5a1e9648 Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sun, 8 Nov 2026 16:26:06 -0700 Subject: [PATCH 44/55] Rename the ZR68 reload sound pieces by step The piece names put the step number and the piece number side by side: reload_2_load_2 read as "step 2, again". Name each piece reload_, and a step's later pieces _part2, _part3: reload_load, reload_load_part2, reload_cycle. The wav files and the phases-file keys are renamed to match in neoAssets. The ) prefix stays: the pieces are stereo, and NEO plays the reload through RELOAD_NPC, whose ZR68 entry uses it. --- game/neo/scripts/game_sounds_weapons.txt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/game/neo/scripts/game_sounds_weapons.txt b/game/neo/scripts/game_sounds_weapons.txt index 4d0cfc3a15..f07bfa6586 100644 --- a/game/neo/scripts/game_sounds_weapons.txt +++ b/game/neo/scripts/game_sounds_weapons.txt @@ -759,34 +759,34 @@ "wave" "weapons/zr68/zr68_reload.wav" } -// ZR68 reload in per-step pieces (sv_neo_reload_experimental), named after the step; _2 is a step's second sound. +// ZR68 reload in per-step pieces (sv_neo_reload_experimental), named reload_; a step's later sounds add _part2, _part3. // Each file starts just before its first transient -"weapon_zr68.reload_2_load" +"weapon_zr68.reload_load" { "channel" "CHAN_ITEM" "soundlevel" "SNDLVL_NORM" "volume" "1.0" "pitch" "PITCH_NORM" - "wave" ")weapons/zr68/zr68_reload_2_load.wav" + "wave" ")weapons/zr68/zr68_reload_load.wav" } -"weapon_zr68.reload_2_load_2" +"weapon_zr68.reload_load_part2" { "channel" "CHAN_ITEM" "soundlevel" "SNDLVL_NORM" "volume" "1.0" "pitch" "PITCH_NORM" - "wave" ")weapons/zr68/zr68_reload_2_load_2.wav" + "wave" ")weapons/zr68/zr68_reload_load_part2.wav" } -"weapon_zr68.reload_3_cycle" +"weapon_zr68.reload_cycle" { "channel" "CHAN_ITEM" "soundlevel" "SNDLVL_NORM" "volume" "1.0" "pitch" "PITCH_NORM" - "wave" ")weapons/zr68/zr68_reload_3_cycle.wav" + "wave" ")weapons/zr68/zr68_reload_cycle.wav" } //------------------- From 4b53af44f56218e46e7d9ae9ff9947d2edbbd55c Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sun, 8 Nov 2026 17:21:54 -0700 Subject: [PATCH 45/55] Call the reload phases through one-line hooks Master's Reload, FinishReload, Deploy, Holster and ItemBusyFrame gain one hook call each, as in #2285, and each hook checks the reload-phase gate itself. The slice's chamber, dry-chamber and reload_skipcycle starts move into ReloadPhasesOnRequest, and the chambered round kept through a magazine change comes back from ReloadPhasesOnFinish, so master's clip arithmetic keeps GetMaxClip1. The header additions move into one commented block. Behavior is unchanged with the flag on and off. --- .../weapons/weapon_neobasecombatweapon.cpp | 161 ++++++++++++------ .../neo/weapons/weapon_neobasecombatweapon.h | 45 +++-- 2 files changed, 138 insertions(+), 68 deletions(-) diff --git a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp index 0ecaceabac..1b40de58fd 100644 --- a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp +++ b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp @@ -454,31 +454,10 @@ bool CNEOBaseCombatWeapon::Reload( void ) return false; } - // A lost resume must still allow chambering the loaded magazine, even without spare ammo. - if (HasChamberSlot() && m_bChamberEmpty && m_iClip1 > 0) + const ReloadRequest_t request = ReloadPhasesOnRequest(); + if (request != RELOAD_REQUEST_DEFAULT) { - static constexpr const char *VM_SEQ_RELOAD_DRY = "reload"; - const int iTable = GetNEOWpnData().FindReloadTable(VM_SEQ_RELOAD_DRY); - if (iTable < 0 || !PlayReloadSequence(VM_SEQ_RELOAD_DRY, iTable, RELOAD_GESTURE_KEEP_START)) - { - return false; - } - - // Keep the loaded magazine's ammo; only the cycle phase still needs credit. - m_nReloadPhase = RELOAD_PHASE_LOADED; - CBaseCombatWeapon::WeaponSound(RELOAD_NPC); - return true; - } - - if (HasChamberSlot() && RoundsInMagazine() >= MagazineCapacity()) - { - return false; - } - - // The tactical sequence omits the bolt cycle and retains the chambered round. - if (StartPartialReload()) - { - return true; + return request == RELOAD_REQUEST_STARTED; } const bool bEmptyReload = UsesClipsForAmmo1() && m_iClip1 <= 0 && @@ -502,13 +481,7 @@ bool CNEOBaseCombatWeapon::Reload( void ) // the animation and the wait to fire still run to the end m_flReloadReadyTime = Max(gpGlobals->curtime, m_flNextPrimaryAttack - GetNEOWpnData().m_flReloadReadyBeforeEnd); - if (IsReloadPhaseSystemEnabled()) - { - // the phases are those of the sequence the reload plays, such as reload or reloadempty - CBaseViewModel *pVM = ReloadViewModel(); - m_nReloadPhase = RELOAD_PHASE_NONE; - StartReloadPhases(pVM ? GetNEOWpnData().FindReloadTable(pVM->GetSequenceName(pVM->GetSequence())) : -1); - } + ReloadPhasesOnReload(); return true; @@ -548,6 +521,102 @@ bool CNEOBaseCombatWeapon::IsReloadPhaseSystemEnabled() const return NEORules() && NEORules()->IsReloadExperimental() && !GetNEOWpnData().m_reloadTables.IsEmpty(); } +CNEOBaseCombatWeapon::ReloadRequest_t CNEOBaseCombatWeapon::ReloadPhasesOnRequest() +{ + if (!IsReloadPhaseSystemEnabled()) + { + return RELOAD_REQUEST_DEFAULT; + } + + // A lost resume must still allow chambering the loaded magazine, even without spare ammo. + if (HasChamberSlot() && m_bChamberEmpty && m_iClip1 > 0) + { + static constexpr const char *VM_SEQ_RELOAD_DRY = "reload"; + const int iTable = GetNEOWpnData().FindReloadTable(VM_SEQ_RELOAD_DRY); + if (iTable < 0 || !PlayReloadSequence(VM_SEQ_RELOAD_DRY, iTable, RELOAD_GESTURE_KEEP_START)) + { + return RELOAD_REQUEST_REFUSED; + } + + // Keep the loaded magazine's ammo; only the cycle phase still needs credit. + m_nReloadPhase = RELOAD_PHASE_LOADED; + CBaseCombatWeapon::WeaponSound(RELOAD_NPC); + return RELOAD_REQUEST_STARTED; + } + + if (HasChamberSlot() && RoundsInMagazine() >= MagazineCapacity()) + { + return RELOAD_REQUEST_REFUSED; + } + + // The tactical sequence omits the bolt cycle and retains the chambered round. + return StartPartialReload() ? RELOAD_REQUEST_STARTED : RELOAD_REQUEST_DEFAULT; +} + +// The phases are those of the sequence the reload plays, such as reload or reloadempty +void CNEOBaseCombatWeapon::ReloadPhasesOnReload() +{ + if (!IsReloadPhaseSystemEnabled()) + { + return; + } + + CBaseViewModel *pVM = ReloadViewModel(); + m_nReloadPhase = RELOAD_PHASE_NONE; + StartReloadPhases(pVM ? GetNEOWpnData().FindReloadTable(pVM->GetSequenceName(pVM->GetSequence())) : -1); +} + +// The magazine is in: the phases up to the load are done, and a switch from here leaves nothing to resume. +// Returns the rounds the chamber keeps through the magazine change +int CNEOBaseCombatWeapon::ReloadPhasesOnFinish() +{ + if (!IsReloadPhaseSystemEnabled()) + { + return 0; + } + + m_nReloadPhase = Max(static_cast(m_nReloadPhase.Get()), RELOAD_PHASE_LOADED); + return IsRoundChambered() ? 1 : 0; +} + +// A reload interrupted by a switch goes on in the draw; returns whether it resumed +bool CNEOBaseCombatWeapon::ReloadPhasesOnDeploy() +{ + if (!IsReloadPhaseSystemEnabled() || m_nReloadPhase == RELOAD_PHASE_NONE) + { + return false; + } + + return ResumeReload(); +} + +// Only a phase that a sequence resumes from outlasts the switch, with the table that names the resume +void CNEOBaseCombatWeapon::ReloadPhasesOnHolster() +{ + // NEO TODO (sunzenshen): Decide whether RELOAD_END should stop the gesture on a switch. + if (!IsReloadPhaseSystemEnabled()) + { + return; + } + + StopReloadSoundPieces(); + if (!FindResumeSequence()) + { + m_nReloadPhase = RELOAD_PHASE_NONE; + m_nReloadTable = -1; + } +} + +void CNEOBaseCombatWeapon::ReloadPhasesOnBusyFrame() +{ + if (!IsReloadPhaseSystemEnabled()) + { + return; + } + + RunReloadPhases(); +} + // The viewmodel sequence that resumes the reload interrupted now, from the phase table of the playing sequence; // nullptr: none (resume sequences carry no activity, so they are picked by name) const char *CNEOBaseCombatWeapon::FindResumeSequence() const @@ -841,11 +910,7 @@ void CNEOBaseCombatWeapon::FinishReload(void) } m_flReloadReadyTime = 0.0f; - // the magazine is in: the phases up to the load are done, and a switch from here leaves nothing to resume - if (IsReloadPhaseSystemEnabled()) - { - m_nReloadPhase = Max(static_cast(m_nReloadPhase.Get()), RELOAD_PHASE_LOADED); - } + const int iChambered = ReloadPhasesOnFinish(); CBaseCombatCharacter* pOwner = GetOwner(); @@ -854,9 +919,7 @@ void CNEOBaseCombatWeapon::FinishReload(void) // If I use primary clips, reload primary if (UsesClipsForAmmo1()) { - // Replacing the magazine retains a round already in the chamber. - const int iChambered = IsRoundChambered() ? 1 : 0; - int primary = MIN(MagazineCapacity(), m_iPrimaryAmmoCount); + int primary = MIN(GetMaxClip1(), m_iPrimaryAmmoCount); m_iClip1 = iChambered + primary; m_iPrimaryAmmoCount -= primary; } @@ -898,8 +961,7 @@ bool CNEOBaseCombatWeapon::Deploy(void) // An empty weapon draws with its slide held back where the model has that draw, // which carries no activity, so it is picked by name static constexpr const char *VM_SEQ_DRAW_EMPTY = "drawempty"; - // a reload interrupted by a switch goes on in the draw - const bool bResumed = IsReloadPhaseSystemEnabled() && m_nReloadPhase != RELOAD_PHASE_NONE && ResumeReload(); + const bool bResumed = ReloadPhasesOnDeploy(); const int iDrawEmpty = (!bResumed && UsesClipsForAmmo1() && m_iClip1 <= 0) ? LookupSequence(VM_SEQ_DRAW_EMPTY) : ACTIVITY_NOT_AVAILABLE; if (iDrawEmpty != ACTIVITY_NOT_AVAILABLE) { @@ -967,17 +1029,7 @@ float CNEOBaseCombatWeapon::GetPenetration() const bool CNEOBaseCombatWeapon::Holster(CBaseCombatWeapon* pSwitchingTo) { - // NEO TODO (sunzenshen): Decide whether RELOAD_END should stop the gesture on a switch. - // Only a phase that a sequence resumes from outlasts the switch, with the table that names the resume - if (IsReloadPhaseSystemEnabled()) - { - StopReloadSoundPieces(); - if (!FindResumeSequence()) - { - m_nReloadPhase = RELOAD_PHASE_NONE; - m_nReloadTable = -1; - } - } + ReloadPhasesOnHolster(); return BaseClass::Holster(pSwitchingTo); } @@ -1034,10 +1086,7 @@ void CNEOBaseCombatWeapon::ItemBusyFrame(void) BaseClass::ItemBusyFrame(); UpdateInaccuracy(); - if (IsReloadPhaseSystemEnabled()) - { - RunReloadPhases(); - } + ReloadPhasesOnBusyFrame(); // The owner stays busy until the reload animation ends, but the magazine loads at the reload's ready time if (m_bInReload && m_flReloadReadyTime > 0.0f && gpGlobals->curtime >= m_flReloadReadyTime) diff --git a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h index b2d56a4826..ad14fbd88b 100644 --- a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h +++ b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h @@ -264,13 +264,6 @@ class CNEOBaseCombatWeapon : public CBaseHL2MPCombatWeapon virtual float GetFireRate() override final; float GetPenetration() const; - void StopReloadOnDrop(); - - // Clip1 includes the chambered round; the magazine can hold GetMaxClip1() more. - bool HasChamberSlot() const; - bool IsRoundChambered() const; - int RoundsInMagazine() const; - int MagazineCapacity() const; #ifdef CLIENT_DLL float m_flTemperature; int m_spawnflags; @@ -289,7 +282,6 @@ class CNEOBaseCombatWeapon : public CBaseHL2MPCombatWeapon virtual float GetMaxAccuracyPenalty() const { return 1.0; } virtual float GetAccuracyPenaltyDecay(); virtual float GetFastestDryRefireTime() const { Assert(false); return 0; } // Should never call this base class; implement in children. - bool IsReloadPhaseSystemEnabled() const; protected: CNetworkVar(float, m_flSoonestAttack); @@ -302,7 +294,25 @@ class CNEOBaseCombatWeapon : public CBaseHL2MPCombatWeapon // When the reload in progress loads the magazine, 0 once it is loaded CNetworkVar(float, m_flReloadReadyTime); - // Reload phases (weapons whose script has a ReloadPhases block): the last phase finished, kept across a switch +private: + CNEOBaseCombatWeapon(const CNEOBaseCombatWeapon &other); + bool HasEmptyIdle(); + + // Reload phases (sv_neo_reload_experimental, weapons whose script has a ReloadPhases block). + // Each hook checks IsReloadPhaseSystemEnabled itself, so with the flag off a hook call does nothing +public: + void StopReloadOnDrop(); + + // Clip1 includes the chambered round; the magazine can hold GetMaxClip1() more. + bool HasChamberSlot() const; + bool IsRoundChambered() const; + int RoundsInMagazine() const; + int MagazineCapacity() const; + +protected: + bool IsReloadPhaseSystemEnabled() const; + + // the last phase finished, kept across a switch CNetworkVar(int, m_nReloadPhase); // the phase table of the reload sequence started last, -1 none CNetworkVar(int, m_nReloadTable); @@ -314,8 +324,20 @@ class CNEOBaseCombatWeapon : public CBaseHL2MPCombatWeapon CNetworkVar(bool, m_bChamberEmpty); private: - CNEOBaseCombatWeapon(const CNEOBaseCombatWeapon &other); - bool HasEmptyIdle(); + // What a reload request does before the default reload: run it, or answer for the phases + enum ReloadRequest_t + { + RELOAD_REQUEST_DEFAULT, // the default reload runs + RELOAD_REQUEST_STARTED, // the phases started their own reload + RELOAD_REQUEST_REFUSED, // no reload starts + }; + + ReloadRequest_t ReloadPhasesOnRequest(); + void ReloadPhasesOnReload(); + int ReloadPhasesOnFinish(); + bool ReloadPhasesOnDeploy(); + void ReloadPhasesOnHolster(); + void ReloadPhasesOnBusyFrame(); void StartReloadPhases(int iTable); void RunReloadPhases(); @@ -328,7 +350,6 @@ class CNEOBaseCombatWeapon : public CBaseHL2MPCombatWeapon void EmitReloadSoundPiece(const char *pszSound); CBaseViewModel *ReloadViewModel() const; int LookupReloadSequence(const char *pszName) const; - }; #endif // WEAPON_NEO_BASECOMBATWEAPON_SHARED_H From c0704590be6f3167696f870013a5e7a909244913 Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sun, 8 Nov 2026 17:22:52 -0700 Subject: [PATCH 46/55] Rename the ZR68 reload sound pieces by step Name each piece reload_, and a step's later pieces _part2, as in #2285: reload_unload, reload_load, reload_load_part2, reload_cycle. The wav files and the phases-file keys are renamed to match in neoAssets. The ) prefix stays. --- game/neo/scripts/game_sounds_weapons.txt | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/game/neo/scripts/game_sounds_weapons.txt b/game/neo/scripts/game_sounds_weapons.txt index e1d43d8695..b8b6f6689f 100644 --- a/game/neo/scripts/game_sounds_weapons.txt +++ b/game/neo/scripts/game_sounds_weapons.txt @@ -759,43 +759,43 @@ "wave" "weapons/zr68/zr68_reload.wav" } -// ZR68 reload in per-step pieces (sv_neo_reload_experimental), named after the step; _2 is a step's second sound. +// ZR68 reload in per-step pieces (sv_neo_reload_experimental), named reload_; a step's later sounds add _part2, _part3. // Each file starts just before its first transient -"weapon_zr68.reload_1_unload" +"weapon_zr68.reload_unload" { "channel" "CHAN_ITEM" "soundlevel" "SNDLVL_NORM" "volume" "1.0" "pitch" "PITCH_NORM" - "wave" ")weapons/zr68/zr68_reload_1_unload.wav" + "wave" ")weapons/zr68/zr68_reload_unload.wav" } -"weapon_zr68.reload_2_load" +"weapon_zr68.reload_load" { "channel" "CHAN_ITEM" "soundlevel" "SNDLVL_NORM" "volume" "1.0" "pitch" "PITCH_NORM" - "wave" ")weapons/zr68/zr68_reload_2_load.wav" + "wave" ")weapons/zr68/zr68_reload_load.wav" } -"weapon_zr68.reload_2_load_2" +"weapon_zr68.reload_load_part2" { "channel" "CHAN_ITEM" "soundlevel" "SNDLVL_NORM" "volume" "1.0" "pitch" "PITCH_NORM" - "wave" ")weapons/zr68/zr68_reload_2_load_2.wav" + "wave" ")weapons/zr68/zr68_reload_load_part2.wav" } -"weapon_zr68.reload_3_cycle" +"weapon_zr68.reload_cycle" { "channel" "CHAN_ITEM" "soundlevel" "SNDLVL_NORM" "volume" "1.0" "pitch" "PITCH_NORM" - "wave" ")weapons/zr68/zr68_reload_3_cycle.wav" + "wave" ")weapons/zr68/zr68_reload_cycle.wav" } //------------------- From 2e3fa243b0004cd78e4ade5763973493a3b135c7 Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sun, 8 Nov 2026 17:25:45 -0700 Subject: [PATCH 47/55] Refuse a phase reload during a reload under the flag The in-reload guard sat at the top of Reload, so with the reload experiment off a weapon refused a Reload call that master accepts. The guard protects the phase paths, which bypass DefaultReload; move it into ReloadPhasesOnRequest so the flag-off path matches master. --- .../shared/neo/weapons/weapon_neobasecombatweapon.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp index 1b40de58fd..ca4c999a0d 100644 --- a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp +++ b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp @@ -449,11 +449,6 @@ void CNEOBaseCombatWeapon::Equip(CBaseCombatCharacter* pOwner) bool CNEOBaseCombatWeapon::Reload( void ) { - if (m_bInReload) - { - return false; - } - const ReloadRequest_t request = ReloadPhasesOnRequest(); if (request != RELOAD_REQUEST_DEFAULT) { @@ -528,6 +523,12 @@ CNEOBaseCombatWeapon::ReloadRequest_t CNEOBaseCombatWeapon::ReloadPhasesOnReques return RELOAD_REQUEST_DEFAULT; } + // The phase paths below bypass DefaultReload, so a call during a reload must not restart it. + if (m_bInReload) + { + return RELOAD_REQUEST_REFUSED; + } + // A lost resume must still allow chambering the loaded magazine, even without spare ammo. if (HasChamberSlot() && m_bChamberEmpty && m_iClip1 > 0) { From da395b2d00b6385977a4b2a7e56d5ad84770c1d3 Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sun, 8 Nov 2026 17:28:28 -0700 Subject: [PATCH 48/55] Rename every reload sound piece by step Name each primary's reload sound pieces reload_, and a step's later pieces _part2 and _part3, as the ZR68 entries already are. The wav files and the phases files' sound names are renamed to match in neoAssets. Each entry's ) prefix stays. --- game/neo/scripts/game_sounds_weapons.txt | 132 +++++++++++------------ 1 file changed, 66 insertions(+), 66 deletions(-) diff --git a/game/neo/scripts/game_sounds_weapons.txt b/game/neo/scripts/game_sounds_weapons.txt index 16d5cce3e4..ecd4285a92 100644 --- a/game/neo/scripts/game_sounds_weapons.txt +++ b/game/neo/scripts/game_sounds_weapons.txt @@ -195,40 +195,40 @@ // AA13 reload in per-step pieces (sv_neo_reload_experimental). -"weapon_aa13.reload_1_unload" +"weapon_aa13.reload_unload" { "channel" "CHAN_ITEM" "soundlevel" "SNDLVL_NORM" "volume" "1.0" "pitch" "PITCH_NORM" - "wave" ")weapons/aa13/aa13_reload_1_unload.wav" + "wave" ")weapons/aa13/aa13_reload_unload.wav" } -"weapon_aa13.reload_1_unload_2" +"weapon_aa13.reload_unload_part2" { "channel" "CHAN_ITEM" "soundlevel" "SNDLVL_NORM" "volume" "1.0" "pitch" "PITCH_NORM" - "wave" ")weapons/aa13/aa13_reload_1_unload_2.wav" + "wave" ")weapons/aa13/aa13_reload_unload_part2.wav" } -"weapon_aa13.reload_2_load" +"weapon_aa13.reload_load" { "channel" "CHAN_ITEM" "soundlevel" "SNDLVL_NORM" "volume" "1.0" "pitch" "PITCH_NORM" - "wave" ")weapons/aa13/aa13_reload_2_load.wav" + "wave" ")weapons/aa13/aa13_reload_load.wav" } -"weapon_aa13.reload_3_cycle" +"weapon_aa13.reload_cycle" { "channel" "CHAN_ITEM" "soundlevel" "SNDLVL_NORM" "volume" "1.0" "pitch" "PITCH_NORM" - "wave" ")weapons/aa13/aa13_reload_3_cycle.wav" + "wave" ")weapons/aa13/aa13_reload_cycle.wav" } //------------------ @@ -383,31 +383,31 @@ // MPN45 reload in per-step pieces (sv_neo_reload_experimental). -"weapon_mpn45.reload_1_unload" +"weapon_mpn45.reload_unload" { "channel" "CHAN_ITEM" "soundlevel" "SNDLVL_NORM" "volume" "1.0" "pitch" "PITCH_NORM" - "wave" ")weapons/mpn45/mpn45_reload_1_unload.wav" + "wave" ")weapons/mpn45/mpn45_reload_unload.wav" } -"weapon_mpn45.reload_2_load" +"weapon_mpn45.reload_load" { "channel" "CHAN_ITEM" "soundlevel" "SNDLVL_NORM" "volume" "1.0" "pitch" "PITCH_NORM" - "wave" ")weapons/mpn45/mpn45_reload_2_load.wav" + "wave" ")weapons/mpn45/mpn45_reload_load.wav" } -"weapon_mpn45.reload_3_cycle" +"weapon_mpn45.reload_cycle" { "channel" "CHAN_ITEM" "soundlevel" "SNDLVL_NORM" "volume" "1.0" "pitch" "PITCH_NORM" - "wave" ")weapons/mpn45/mpn45_reload_3_cycle.wav" + "wave" ")weapons/mpn45/mpn45_reload_cycle.wav" } //------------------- @@ -486,31 +486,31 @@ // SRM reload in per-step pieces (sv_neo_reload_experimental). -"weapon_srm.reload_1_unload" +"weapon_srm.reload_unload" { "channel" "CHAN_ITEM" "soundlevel" "SNDLVL_NORM" "volume" "1.0" "pitch" "PITCH_NORM" - "wave" ")weapons/srm/srm_reload_1_unload.wav" + "wave" ")weapons/srm/srm_reload_unload.wav" } -"weapon_srm.reload_2_load" +"weapon_srm.reload_load" { "channel" "CHAN_ITEM" "soundlevel" "SNDLVL_NORM" "volume" "1.0" "pitch" "PITCH_NORM" - "wave" ")weapons/srm/srm_reload_2_load.wav" + "wave" ")weapons/srm/srm_reload_load.wav" } -"weapon_srm.reload_3_cycle" +"weapon_srm.reload_cycle" { "channel" "CHAN_ITEM" "soundlevel" "SNDLVL_NORM" "volume" "1.0" "pitch" "PITCH_NORM" - "wave" ")weapons/srm/srm_reload_3_cycle.wav" + "wave" ")weapons/srm/srm_reload_cycle.wav" } //------------------- @@ -600,31 +600,31 @@ // Jitte reload in per-step pieces (sv_neo_reload_experimental). -"weapon_jitte.reload_1_unload" +"weapon_jitte.reload_unload" { "channel" "CHAN_ITEM" "soundlevel" "SNDLVL_NORM" "volume" "1.0" "pitch" "PITCH_NORM" - "wave" ")weapons/jitte/jitte_reload_1_unload.wav" + "wave" ")weapons/jitte/jitte_reload_unload.wav" } -"weapon_jitte.reload_2_load" +"weapon_jitte.reload_load" { "channel" "CHAN_ITEM" "soundlevel" "SNDLVL_NORM" "volume" "1.0" "pitch" "PITCH_NORM" - "wave" ")weapons/jitte/jitte_reload_2_load.wav" + "wave" ")weapons/jitte/jitte_reload_load.wav" } -"weapon_jitte.reload_3_cycle" +"weapon_jitte.reload_cycle" { "channel" "CHAN_ITEM" "soundlevel" "SNDLVL_NORM" "volume" "1.0" "pitch" "PITCH_NORM" - "wave" ")weapons/jitte/jitte_reload_3_cycle.wav" + "wave" ")weapons/jitte/jitte_reload_cycle.wav" } //------------------- @@ -713,40 +713,40 @@ // M41 reload in per-step pieces (sv_neo_reload_experimental). -"weapon_m41.reload_1_unload" +"weapon_m41.reload_unload" { "channel" "CHAN_ITEM" "soundlevel" "SNDLVL_NORM" "volume" "1.0" "pitch" "PITCH_NORM" - "wave" ")weapons/m41/m41_reload_1_unload.wav" + "wave" ")weapons/m41/m41_reload_unload.wav" } -"weapon_m41.reload_2_load" +"weapon_m41.reload_load" { "channel" "CHAN_ITEM" "soundlevel" "SNDLVL_NORM" "volume" "1.0" "pitch" "PITCH_NORM" - "wave" ")weapons/m41/m41_reload_2_load.wav" + "wave" ")weapons/m41/m41_reload_load.wav" } -"weapon_m41.reload_2_load_2" +"weapon_m41.reload_load_part2" { "channel" "CHAN_ITEM" "soundlevel" "SNDLVL_NORM" "volume" "1.0" "pitch" "PITCH_NORM" - "wave" ")weapons/m41/m41_reload_2_load_2.wav" + "wave" ")weapons/m41/m41_reload_load_part2.wav" } -"weapon_m41.reload_3_cycle" +"weapon_m41.reload_cycle" { "channel" "CHAN_ITEM" "soundlevel" "SNDLVL_NORM" "volume" "1.0" "pitch" "PITCH_NORM" - "wave" ")weapons/m41/m41_reload_3_cycle.wav" + "wave" ")weapons/m41/m41_reload_cycle.wav" } //------------------- @@ -842,31 +842,31 @@ // SRS reload in per-step pieces (sv_neo_reload_experimental). -"weapon_srs.reload_1_unload" +"weapon_srs.reload_unload" { "channel" "CHAN_ITEM" "soundlevel" "SNDLVL_NORM" "volume" "1.0" "pitch" "PITCH_NORM" - "wave" ")weapons/srs/srs_reload_1_unload.wav" + "wave" ")weapons/srs/srs_reload_unload.wav" } -"weapon_srs.reload_2_load" +"weapon_srs.reload_load" { "channel" "CHAN_ITEM" "soundlevel" "SNDLVL_NORM" "volume" "1.0" "pitch" "PITCH_NORM" - "wave" ")weapons/srs/srs_reload_2_load.wav" + "wave" ")weapons/srs/srs_reload_load.wav" } -"weapon_srs.reload_3_cycle" +"weapon_srs.reload_cycle" { "channel" "CHAN_ITEM" "soundlevel" "SNDLVL_NORM" "volume" "1.0" "pitch" "PITCH_NORM" - "wave" ")weapons/srs/srs_reload_3_cycle.wav" + "wave" ")weapons/srs/srs_reload_cycle.wav" } //------------------- @@ -992,40 +992,40 @@ // ZR68L reload in per-step pieces (sv_neo_reload_experimental). -"weapon_zr68l.reload_1_unload" +"weapon_zr68l.reload_unload" { "channel" "CHAN_ITEM" "soundlevel" "SNDLVL_NORM" "volume" "1.0" "pitch" "PITCH_NORM" - "wave" ")weapons/zr68l/zr68l_reload_1_unload.wav" + "wave" ")weapons/zr68l/zr68l_reload_unload.wav" } -"weapon_zr68l.reload_2_load" +"weapon_zr68l.reload_load" { "channel" "CHAN_ITEM" "soundlevel" "SNDLVL_NORM" "volume" "1.0" "pitch" "PITCH_NORM" - "wave" ")weapons/zr68l/zr68l_reload_2_load.wav" + "wave" ")weapons/zr68l/zr68l_reload_load.wav" } -"weapon_zr68l.reload_2_load_2" +"weapon_zr68l.reload_load_part2" { "channel" "CHAN_ITEM" "soundlevel" "SNDLVL_NORM" "volume" "1.0" "pitch" "PITCH_NORM" - "wave" ")weapons/zr68l/zr68l_reload_2_load_2.wav" + "wave" ")weapons/zr68l/zr68l_reload_load_part2.wav" } -"weapon_zr68l.reload_3_cycle" +"weapon_zr68l.reload_cycle" { "channel" "CHAN_ITEM" "soundlevel" "SNDLVL_NORM" "volume" "1.0" "pitch" "PITCH_NORM" - "wave" ")weapons/zr68l/zr68l_reload_3_cycle.wav" + "wave" ")weapons/zr68l/zr68l_reload_cycle.wav" } //------------------- @@ -1163,31 +1163,31 @@ // MX reload in per-step pieces (sv_neo_reload_experimental). -"weapon_mx.reload_1_unload" +"weapon_mx.reload_unload" { "channel" "CHAN_ITEM" "soundlevel" "SNDLVL_NORM" "volume" "1.0" "pitch" "PITCH_NORM" - "wave" ")weapons/mx/mx_reload_1_unload.wav" + "wave" ")weapons/mx/mx_reload_unload.wav" } -"weapon_mx.reload_2_load" +"weapon_mx.reload_load" { "channel" "CHAN_ITEM" "soundlevel" "SNDLVL_NORM" "volume" "1.0" "pitch" "PITCH_NORM" - "wave" ")weapons/mx/mx_reload_2_load.wav" + "wave" ")weapons/mx/mx_reload_load.wav" } -"weapon_mx.reload_3_cycle" +"weapon_mx.reload_cycle" { "channel" "CHAN_ITEM" "soundlevel" "SNDLVL_NORM" "volume" "1.0" "pitch" "PITCH_NORM" - "wave" ")weapons/mx/mx_reload_3_cycle.wav" + "wave" ")weapons/mx/mx_reload_cycle.wav" } //------------------- @@ -1275,58 +1275,58 @@ // PZ252 reload in per-step pieces (sv_neo_reload_experimental). -"weapon_pz.reload_1_unload" +"weapon_pz.reload_unload" { "channel" "CHAN_ITEM" "soundlevel" "SNDLVL_NORM" "volume" "1.0" "pitch" "PITCH_NORM" - "wave" ")weapons/pz/pz_reload_1_unload.wav" + "wave" ")weapons/pz/pz_reload_unload.wav" } -"weapon_pz.reload_1_unload_2" +"weapon_pz.reload_unload_part2" { "channel" "CHAN_ITEM" "soundlevel" "SNDLVL_NORM" "volume" "1.0" "pitch" "PITCH_NORM" - "wave" ")weapons/pz/pz_reload_1_unload_2.wav" + "wave" ")weapons/pz/pz_reload_unload_part2.wav" } -"weapon_pz.reload_2_load" +"weapon_pz.reload_load" { "channel" "CHAN_ITEM" "soundlevel" "SNDLVL_NORM" "volume" "1.0" "pitch" "PITCH_NORM" - "wave" ")weapons/pz/pz_reload_2_load.wav" + "wave" ")weapons/pz/pz_reload_load.wav" } -"weapon_pz.reload_2_load_2" +"weapon_pz.reload_load_part2" { "channel" "CHAN_ITEM" "soundlevel" "SNDLVL_NORM" "volume" "1.0" "pitch" "PITCH_NORM" - "wave" ")weapons/pz/pz_reload_2_load_2.wav" + "wave" ")weapons/pz/pz_reload_load_part2.wav" } -"weapon_pz.reload_2_load_3" +"weapon_pz.reload_load_part3" { "channel" "CHAN_ITEM" "soundlevel" "SNDLVL_NORM" "volume" "1.0" "pitch" "PITCH_NORM" - "wave" ")weapons/pz/pz_reload_2_load_3.wav" + "wave" ")weapons/pz/pz_reload_load_part3.wav" } -"weapon_pz.reload_3_cycle" +"weapon_pz.reload_cycle" { "channel" "CHAN_ITEM" "soundlevel" "SNDLVL_NORM" "volume" "1.0" "pitch" "PITCH_NORM" - "wave" ")weapons/pz/pz_reload_3_cycle.wav" + "wave" ")weapons/pz/pz_reload_cycle.wav" } //------------------- From fefb991e4ae8ffae94d2bcdb5cd6b72d5844ffb3 Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sun, 8 Nov 2026 17:29:27 -0700 Subject: [PATCH 49/55] Call the SRS bolt phases through hooks Move the SRS bolt-home logic out of master's PrimaryAttack, ItemPreFrame, Deploy and Reload into BoltPhasesOn* hooks, so each master function gains only one-line calls, as the reload phases do in the weapon base. Each hook checks the flag itself; behavior is unchanged. --- src/game/shared/neo/weapons/weapon_srs.cpp | 134 +++++++++++++++------ src/game/shared/neo/weapons/weapon_srs.h | 10 ++ 2 files changed, 109 insertions(+), 35 deletions(-) diff --git a/src/game/shared/neo/weapons/weapon_srs.cpp b/src/game/shared/neo/weapons/weapon_srs.cpp index 93e603a4fc..6bf5ec4a98 100644 --- a/src/game/shared/neo/weapons/weapon_srs.cpp +++ b/src/game/shared/neo/weapons/weapon_srs.cpp @@ -63,8 +63,7 @@ void CWeaponSRS::PrimaryAttack() return BaseClass::PrimaryAttack(); } - // An unchambered gun completes its bolt cycle before it can fire; the press is ignored - if (HasChamberSlot() && IsBoltPending()) + if (BoltPhasesBlockShot()) { return; } @@ -77,8 +76,7 @@ void CWeaponSRS::PrimaryAttack() } m_bNeedsBolting = true; - m_flBoltHomeTime = 0.0f; - m_flBoltStartTime = 0.0f; + BoltPhasesOnShot(); BaseClass::PrimaryAttack(); } @@ -89,7 +87,12 @@ void CWeaponSRS::ItemPreFrame() return BaseClass::ItemPreFrame(); } - if (m_flLastAttackTime + 0.08f <= gpGlobals->curtime && m_flBoltStartTime <= gpGlobals->curtime) + if (BoltPhasesDelayCycle()) + { + return BaseClass::ItemPreFrame(); + } + + if (m_flLastAttackTime + 0.08f <= gpGlobals->curtime) { // Primary attack animation finished, begin chambering a round if (auto* pOwner = ToNEOPlayer(GetOwner())) { if (pOwner->m_nButtons & IN_ATTACK) @@ -102,17 +105,7 @@ void CWeaponSRS::ItemPreFrame() SendWeaponAnim(ACT_VM_PULLBACK); WeaponSound(SPECIAL1); m_bNeedsBolting = false; - - if (IsReloadPhaseSystemEnabled()) - { - // The round counts as chambered once the bolt is home - const CNEOWeaponInfo &info = GetNEOWpnData(); - const int iTable = info.FindReloadTable(VM_SEQ_CHARGE); - if (iTable >= 0 && info.m_reloadTables[iTable].iNumRows > 0) - { - m_flBoltHomeTime = gpGlobals->curtime + info.m_reloadTables[iTable].rows[0].flAmmo; - } - } + BoltPhasesOnCycle(); } BaseClass::ItemPreFrame(); @@ -121,19 +114,11 @@ void CWeaponSRS::ItemPreFrame() bool CWeaponSRS::Deploy() { // This is on purpose; the player is allowed to cancel the bolting animation - // with a quick-switch input. With reload phases the round does not count as - // chambered before the bolt is home, so a cut-short cycle resumes after the draw. - const bool bResumeBolt = IsReloadPhaseSystemEnabled() && m_bNeedsBolting; - m_bNeedsBolting = bResumeBolt; - m_flBoltHomeTime = 0.0f; - m_flBoltStartTime = 0.0f; + // with a quick-switch input. + m_bNeedsBolting = BoltPhasesKeepCycle(); const bool bDeployed = BaseClass::Deploy(); - if (bResumeBolt) - { - m_flBoltStartTime = m_flNextPrimaryAttack; - } - + BoltPhasesOnDeploy(); return bDeployed; } @@ -142,7 +127,7 @@ bool CWeaponSRS::Reload() // The reloading animation already contains the bolting motion; // we don't want to bolt twice. m_bNeedsBolting = false; - m_flBoltHomeTime = 0.0f; + BoltPhasesOnReload(); return BaseClass::Reload(); } @@ -154,13 +139,7 @@ bool CWeaponSRS::IsBoltPending() const bool CWeaponSRS::Holster(CBaseCombatWeapon *pSwitchingTo) { - // Time passes while holstered, so note that the bolt is not home for the next draw - if (IsReloadPhaseSystemEnabled() && IsBoltPending()) - { - m_bNeedsBolting = true; - m_flBoltHomeTime = 0.0f; - } - + BoltPhasesOnHolster(); return BaseClass::Holster(pSwitchingTo); } @@ -174,6 +153,91 @@ bool CWeaponSRS::IsRoundChambered() const return BaseClass::IsRoundChambered(); } +// An unchambered gun completes its bolt cycle before it can fire; the press is ignored +bool CWeaponSRS::BoltPhasesBlockShot() const +{ + return HasChamberSlot() && IsBoltPending(); +} + +void CWeaponSRS::BoltPhasesOnShot() +{ + if (!IsReloadPhaseSystemEnabled()) + { + return; + } + + m_flBoltHomeTime = 0.0f; + m_flBoltStartTime = 0.0f; +} + +// A bolt cycle resumed by a draw waits for the draw to end +bool CWeaponSRS::BoltPhasesDelayCycle() const +{ + return IsReloadPhaseSystemEnabled() && m_flBoltStartTime > gpGlobals->curtime; +} + +// The round counts as chambered once the bolt is home +void CWeaponSRS::BoltPhasesOnCycle() +{ + if (!IsReloadPhaseSystemEnabled()) + { + return; + } + + const CNEOWeaponInfo &info = GetNEOWpnData(); + const int iTable = info.FindReloadTable(VM_SEQ_CHARGE); + if (iTable >= 0 && info.m_reloadTables[iTable].iNumRows > 0) + { + m_flBoltHomeTime = gpGlobals->curtime + info.m_reloadTables[iTable].rows[0].flAmmo; + } +} + +// The round does not count as chambered before the bolt is home, so a cut-short cycle resumes after the draw. +// Returns whether the draw keeps the cycle +bool CWeaponSRS::BoltPhasesKeepCycle() +{ + if (!IsReloadPhaseSystemEnabled()) + { + return false; + } + + m_flBoltHomeTime = 0.0f; + m_flBoltStartTime = 0.0f; + return m_bNeedsBolting; +} + +void CWeaponSRS::BoltPhasesOnDeploy() +{ + if (!IsReloadPhaseSystemEnabled() || !m_bNeedsBolting) + { + return; + } + + m_flBoltStartTime = m_flNextPrimaryAttack; +} + +void CWeaponSRS::BoltPhasesOnReload() +{ + if (!IsReloadPhaseSystemEnabled()) + { + return; + } + + m_flBoltHomeTime = 0.0f; +} + +// Time passes while holstered, so note that the bolt is not home for the next draw +void CWeaponSRS::BoltPhasesOnHolster() +{ + if (!IsReloadPhaseSystemEnabled() || !IsBoltPending()) + { + return; + } + + m_bNeedsBolting = true; + m_flBoltHomeTime = 0.0f; +} + bool CWeaponSRS::CanBePickedUpByClass(int classId) { return classId != NEO_CLASS_JUGGERNAUT; diff --git a/src/game/shared/neo/weapons/weapon_srs.h b/src/game/shared/neo/weapons/weapon_srs.h index 2248417b5c..c73439a99e 100644 --- a/src/game/shared/neo/weapons/weapon_srs.h +++ b/src/game/shared/neo/weapons/weapon_srs.h @@ -58,6 +58,16 @@ class CWeaponSRS : public CNEOBaseCombatWeapon // Whether the bolt cycle after a shot has not finished yet bool IsBoltPending() const; + // Bolt phases (sv_neo_reload_experimental); each hook does nothing with the flag off + bool BoltPhasesBlockShot() const; + void BoltPhasesOnShot(); + bool BoltPhasesDelayCycle() const; + void BoltPhasesOnCycle(); + bool BoltPhasesKeepCycle(); + void BoltPhasesOnDeploy(); + void BoltPhasesOnReload(); + void BoltPhasesOnHolster(); + CNetworkVar(bool, m_bNeedsBolting); // The bolt is home, and a round chambered, at this time; 0: no bolt cycle is running CNetworkVar(float, m_flBoltHomeTime); From d5fd9a672563ec2132ec38f9f80f5c0c27c2bb53 Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sun, 8 Nov 2026 17:31:14 -0700 Subject: [PATCH 50/55] Call the Supa-7 tube phases through hooks Move the Supa-7 tube logic out of master's reload, fire, drop and frame functions into TubePhasesOn* hooks, so each master function gains one-line calls. Master's shot bookkeeping runs again ahead of the tube hook, which then sets the clip from the tube. Each hook checks the flag itself; behavior is unchanged. --- src/game/shared/neo/weapons/weapon_supa7.cpp | 278 +++++++++++++------ src/game/shared/neo/weapons/weapon_supa7.h | 15 + 2 files changed, 205 insertions(+), 88 deletions(-) diff --git a/src/game/shared/neo/weapons/weapon_supa7.cpp b/src/game/shared/neo/weapons/weapon_supa7.cpp index 126e1bb0f2..bc07652f31 100644 --- a/src/game/shared/neo/weapons/weapon_supa7.cpp +++ b/src/game/shared/neo/weapons/weapon_supa7.cpp @@ -155,14 +155,9 @@ bool CWeaponSupa7::StartReload(void) if (m_iClip1 >= GetMaxClip1()) return false; - if (IsTubeEnabled()) + if (!TubePhasesOnStart()) { - SyncTube(); - if (m_nTubeCount >= TubeCapacity()) - { - return false; - } - m_nInsert = SUPA7_INSERT_NONE; + return false; } SendWeaponAnim(ACT_SHOTGUN_RELOAD_START); @@ -196,19 +191,9 @@ bool CWeaponSupa7::StartReloadSlug(void) if (m_iClip1 >= GetMaxClip1()) return false; - if (IsTubeEnabled()) + if (!TubePhasesOnStartSlug()) { - // One slug per request: a held alt-fire neither queues another nor delays the shot - if (m_bSlugDelayed || m_nInsert == SUPA7_INSERT_SLUG) - { - return false; - } - - SyncTube(); - if (m_nTubeCount >= TubeCapacity()) - { - return false; - } + return false; } if (!m_bInReload) @@ -249,8 +234,10 @@ bool CWeaponSupa7::Reload(void) if (m_iClip1 >= GetMaxClip1()) return false; - if (IsTubeEnabled() && m_nTubeCount >= TubeCapacity()) + if (IsTubeFull()) + { return false; + } // Play reload on different channel as otherwise steals channel away from fire sound WeaponSound(SPECIAL1); @@ -290,12 +277,13 @@ bool CWeaponSupa7::ReloadSlug(void) if (m_iClip1 >= GetMaxClip1()) return false; - if (IsTubeEnabled()) + if (IsTubeFull()) { - if (m_nTubeCount >= TubeCapacity()) - return false; + return false; } - else + + // the tube takes the slug only once it is in + if (!IsTubeEnabled()) { FillClipSlug(); m_bShellInChamber = false; @@ -326,20 +314,8 @@ void CWeaponSupa7::FinishReload(void) m_bInReload = false; - if (IsTubeEnabled()) + if (TubePhasesOnFinish()) { - // A round still in the hand goes back to the reserve; an empty chamber is racked before the next shot - CancelInsert(); - SyncTube(); - if (!IsChamberLive() && m_nTubeCount > 0) - { - StartRack(); - } - else - { - SendWeaponAnim(ACT_SHOTGUN_RELOAD_FINISH); - } - pOwner->m_flNextAttack = gpGlobals->curtime; return; } @@ -411,13 +387,9 @@ void CWeaponSupa7::PrimaryAttack(void) return; } - if (IsTubeEnabled()) + if (!TubePhasesCanFire()) { - SyncTube(); - if (!IsChamberLive()) - { - return; - } + return; } int numBullets = GetNEOWpnData().m_iBullets; @@ -455,24 +427,16 @@ void CWeaponSupa7::PrimaryAttack(void) pPlayer->DoMuzzleFlash(); SendWeaponAnim(m_bSlugLoaded ? ACT_VM_PRIMARYATTACK : ACT_VM_SECONDARYATTACK); + m_bSlugLoaded = false; // Don't fire again until fire animation has completed ProposeNextAttack(gpGlobals->curtime + GetFireRate()); - if (IsTubeEnabled()) - { - // the fire animation's pump ejects the hull and feeds the tube's last-loaded round - m_nChamber = SUPA7_CHAMBER_HULL; - FeedChamber(); - } - else + m_iClip1 -= 1; + if (m_iClip1 == 0) { - m_bSlugLoaded = false; - m_iClip1 -= 1; - if (m_iClip1 == 0) - { - m_bShellInChamber = false; - } + m_bShellInChamber = false; } + TubePhasesOnShot(); // player "shoot" animation pPlayer->DoAnimationEvent(PLAYERANIMEVENT_ATTACK_PRIMARY); @@ -513,9 +477,7 @@ void CWeaponSupa7::ClearDelayedInputs(void) // for not having to do a larger rewrite. m_bInReload.GetForModify() = false; - // a rack or insert cut off by the drop does nothing for the next owner - CancelInsert(); - m_flRackFeedTime = 0.0f; + TubePhasesOnDrop(); SetShotgunShellVisible(false); } @@ -529,12 +491,7 @@ void CWeaponSupa7::ItemPostFrame(void) return; } ProcessAnimationEvents(); - if (IsTubeEnabled()) - { - SyncTube(); - RunInsert(); - RunRack(); - } + TubePhasesOnFrame(); if (m_bInReload) { @@ -555,17 +512,7 @@ void CWeaponSupa7::ItemPostFrame(void) m_bSlugDelayed.GetForModify() = false; } } - else if (IsTubeEnabled()) - { - // a slug insert ends the reload, as it does without the tube - const bool bSlugInserted = (m_nInsert == SUPA7_INSERT_SLUG); - m_nInsert = SUPA7_INSERT_NONE; - if (m_iPrimaryAmmoCount <= 0 || bSlugInserted || m_nTubeCount >= TubeCapacity() || !Reload()) - { - FinishReload(); - } - } - else + else if (!TubePhasesOnNextInsert()) { // If out of ammo end reload if ((m_iPrimaryAmmoCount <= 0 || m_bSlugLoaded || m_iClip1 >= GetMaxClip1())) @@ -607,8 +554,7 @@ void CWeaponSupa7::ItemPostFrame(void) { DryFire(); } - // rounds in the tube and none in the chamber: the trigger racks one up first - else if (IsTubeEnabled() && !IsChamberLive()) + else if (TubePhasesNeedRack()) { StartRack(); } @@ -634,10 +580,9 @@ void CWeaponSupa7::ItemPostFrame(void) if (!(pOwner->m_nButtons & IN_ATTACK) && m_flNextPrimaryAttack <= gpGlobals->curtime && pOwner->m_nButtons & IN_RELOAD && UsesClipsForAmmo1() && !m_bInReload) { // reload when reload is pressed, or if no buttons are down and weapon is empty. - // With nothing to load, a press racks up a round for an empty chamber - if (!StartReload() && IsTubeEnabled() && (pOwner->m_afButtonPressed & IN_RELOAD) && !IsChamberLive() && m_nTubeCount > 0) + if (!StartReload()) { - StartRack(); + TubePhasesOnReloadPress(); } } else if (!(pOwner->m_nButtons & IN_ATTACK) && m_flNextPrimaryAttack <= gpGlobals->curtime && pOwner->m_nButtons & IN_ATTACK2 && UsesClipsForAmmo1() && !m_bInReload) @@ -671,6 +616,169 @@ bool CWeaponSupa7::IsTubeEnabled() const return NEORules() && NEORules()->IsReloadExperimental(); } +bool CWeaponSupa7::IsTubeFull() const +{ + return IsTubeEnabled() && m_nTubeCount >= TubeCapacity(); +} + +// Returns whether the shell reload may start +bool CWeaponSupa7::TubePhasesOnStart() +{ + if (!IsTubeEnabled()) + { + return true; + } + + SyncTube(); + if (IsTubeFull()) + { + return false; + } + + m_nInsert = SUPA7_INSERT_NONE; + return true; +} + +// One slug per request: a held alt-fire neither queues another nor delays the shot +bool CWeaponSupa7::TubePhasesOnStartSlug() +{ + if (!IsTubeEnabled()) + { + return true; + } + + if (m_bSlugDelayed || m_nInsert == SUPA7_INSERT_SLUG) + { + return false; + } + + SyncTube(); + return !IsTubeFull(); +} + +// A round still in the hand goes back to the reserve; an empty chamber is racked before the next shot. +// Returns whether the tube finished the reload +bool CWeaponSupa7::TubePhasesOnFinish() +{ + CBaseCombatCharacter *pOwner = GetOwner(); + if (!IsTubeEnabled() || !pOwner) + { + return false; + } + + CancelInsert(); + SyncTube(); + if (!IsChamberLive() && m_nTubeCount > 0) + { + StartRack(); + } + else + { + SendWeaponAnim(ACT_SHOTGUN_RELOAD_FINISH); + } + pOwner->m_flNextAttack = gpGlobals->curtime; + return true; +} + +bool CWeaponSupa7::TubePhasesCanFire() +{ + if (!IsTubeEnabled()) + { + return true; + } + + SyncTube(); + return IsChamberLive(); +} + +// The fire animation's pump ejects the hull and feeds the tube's last-loaded round; the tube then sets the clip +void CWeaponSupa7::TubePhasesOnShot() +{ + if (!IsTubeEnabled()) + { + return; + } + + m_nChamber = SUPA7_CHAMBER_HULL; + FeedChamber(); +} + +// A rack or insert cut off by the drop does nothing for the next owner +void CWeaponSupa7::TubePhasesOnDrop() +{ + if (!IsTubeEnabled()) + { + return; + } + + CancelInsert(); + m_flRackFeedTime = 0.0f; +} + +void CWeaponSupa7::TubePhasesOnFrame() +{ + if (!IsTubeEnabled()) + { + return; + } + + SyncTube(); + RunInsert(); + RunRack(); +} + +// The next shell of a reload; a slug insert ends the reload, as it does without the tube. +// Returns whether the tube handled the step +bool CWeaponSupa7::TubePhasesOnNextInsert() +{ + if (!IsTubeEnabled()) + { + return false; + } + + const bool bSlugInserted = (m_nInsert == SUPA7_INSERT_SLUG); + m_nInsert = SUPA7_INSERT_NONE; + if (m_iPrimaryAmmoCount <= 0 || bSlugInserted || IsTubeFull() || !Reload()) + { + FinishReload(); + } + return true; +} + +// Rounds in the tube and none in the chamber: the trigger racks one up first +bool CWeaponSupa7::TubePhasesNeedRack() const +{ + return IsTubeEnabled() && !IsChamberLive(); +} + +// With nothing to load, a reload press racks up a round for an empty chamber +void CWeaponSupa7::TubePhasesOnReloadPress() +{ + CBasePlayer *pOwner = ToBasePlayer(GetOwner()); + if (!IsTubeEnabled() || !pOwner || !(pOwner->m_afButtonPressed & IN_RELOAD)) + { + return; + } + + if (!IsChamberLive() && m_nTubeCount > 0) + { + StartRack(); + } +} + +// Credited rounds stay in the tube; a round still in the hand and a rack before its pump is home do nothing +void CWeaponSupa7::TubePhasesOnHolster() +{ + if (!IsTubeEnabled()) + { + return; + } + + CancelInsert(); + m_flRackFeedTime = 0.0f; + m_bSlugDelayed = false; +} + // Rebuild the tube from the clip count when something set the count directly (a new or picked-up gun, a give): // a live round in the chamber, shells in the tube void CWeaponSupa7::SyncTube() @@ -819,13 +927,7 @@ float CWeaponSupa7::ViewModelSequenceDuration() const bool CWeaponSupa7::Holster(CBaseCombatWeapon *pSwitchingTo) { - // Credited rounds stay in the tube; a round still in the hand and a rack before its pump is home do nothing - if (IsTubeEnabled()) - { - CancelInsert(); - m_flRackFeedTime = 0.0f; - m_bSlugDelayed = false; - } + TubePhasesOnHolster(); return BaseClass::Holster(pSwitchingTo); } diff --git a/src/game/shared/neo/weapons/weapon_supa7.h b/src/game/shared/neo/weapons/weapon_supa7.h index 3a463b846b..78eb837911 100644 --- a/src/game/shared/neo/weapons/weapon_supa7.h +++ b/src/game/shared/neo/weapons/weapon_supa7.h @@ -102,6 +102,21 @@ class CWeaponSupa7 : public CNEOBaseCombatWeapon } bool IsTubeEnabled() const; + bool IsTubeFull() const; + + // Tube phases (sv_neo_reload_experimental); each hook does nothing with the flag off + bool TubePhasesOnStart(); + bool TubePhasesOnStartSlug(); + bool TubePhasesOnFinish(); + bool TubePhasesCanFire(); + void TubePhasesOnShot(); + void TubePhasesOnDrop(); + void TubePhasesOnFrame(); + bool TubePhasesOnNextInsert(); + bool TubePhasesNeedRack() const; + void TubePhasesOnReloadPress(); + void TubePhasesOnHolster(); + bool IsChamberLive() const { return m_nChamber == SUPA7_CHAMBER_SHELL || m_nChamber == SUPA7_CHAMBER_SLUG; } bool IsTubeSynced() const { return m_nTubeCount + (IsChamberLive() ? 1 : 0) == m_iClip1; } int TubeCapacity() const { return GetMaxClip1() - SUPA7_CHAMBER_ROUNDS; } From f89db5caa4ed292a5020be348cdef3a60afe6e20 Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sun, 8 Nov 2026 18:31:01 -0700 Subject: [PATCH 51/55] Empty the clip when the old magazine comes out With sv_neo_reload_experimental, the clip drops to the chambered round at the end of the unload phase instead of keeping the old magazine's count until the load. The old rounds are discarded, as FinishReload already does at the load, so the ammo economy is unchanged on every path: an uninterrupted reload, a switch before the unload, and a resume after it. --- .../shared/neo/weapons/weapon_neobasecombatweapon.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp index ca4c999a0d..4bb6274cd7 100644 --- a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp +++ b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp @@ -698,9 +698,13 @@ void CNEOBaseCombatWeapon::RunReloadPhases() void CNEOBaseCombatWeapon::FinishReloadPhase(ReloadPhase_t phase) { - // The unload takes no rounds: they are lost only if a switch interrupts the reload after it (ResumeReload), - // so an uninterrupted reload shows the same clip as without phases - if (phase == RELOAD_PHASE_LOADED) + // The old magazine's rounds go with it, as a reload without phases discards them at the load (FinishReload); + // a chambered round stays + if (phase == RELOAD_PHASE_UNLOADED) + { + m_iClip1 = IsRoundChambered() ? 1 : 0; + } + else if (phase == RELOAD_PHASE_LOADED) { // the magazine loads now, as at a reload's ready time (ItemBusyFrame) m_flReloadReadyTime = gpGlobals->curtime; From 31e7eac4467d9e076a33c62f9093a2ce3ec641bd Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sun, 8 Nov 2026 18:31:01 -0700 Subject: [PATCH 52/55] Keep bots on a gun reloading past the unload With sv_neo_reload_experimental, the clip reads empty from the unload until the load. EquipBestWeaponForThreat treated that as an empty primary and switched a bot to its secondary at close range, which interrupts the reload. A bot now keeps the active weapon while its reload is past the unload. The weapon query is false with the flag off, so bots run the existing code then. --- src/game/server/neo/bot/neo_bot.cpp | 7 +++++++ src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp | 6 ++++++ src/game/shared/neo/weapons/weapon_neobasecombatweapon.h | 1 + 3 files changed, 14 insertions(+) diff --git a/src/game/server/neo/bot/neo_bot.cpp b/src/game/server/neo/bot/neo_bot.cpp index d9c37498c5..0e9479d7e4 100644 --- a/src/game/server/neo/bot/neo_bot.cpp +++ b/src/game/server/neo/bot/neo_bot.cpp @@ -1628,6 +1628,13 @@ void CNEOBot::EquipBestWeaponForThreat(const CKnownEntity* threat, const bool bN if (EquipRequiredWeapon()) return; + // A switch would only delay the reload that is about to refill the clip + auto *pActiveWeapon = static_cast(GetActiveWeapon()); + if (pActiveWeapon && pActiveWeapon->IsReloadPastUnload()) + { + return; + } + // ------------------------------------------------------------------------------- CNEOBaseCombatWeapon* primaryWeapon = static_cast(Weapon_GetSlot(0)); diff --git a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp index 4bb6274cd7..3e04504a21 100644 --- a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp +++ b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp @@ -800,6 +800,12 @@ bool CNEOBaseCombatWeapon::PlayReloadSequence(const char *pszName, int iTable, R return true; } +// The old magazine is out and the fresh one not yet in: the reload is about to refill the clip +bool CNEOBaseCombatWeapon::IsReloadPastUnload() const +{ + return IsReloadPhaseSystemEnabled() && m_bInReload && m_nReloadPhase == RELOAD_PHASE_UNLOADED; +} + bool CNEOBaseCombatWeapon::HasChamberSlot() const { return IsReloadPhaseSystemEnabled() && GetNEOWpnData().m_bChamberedRound; diff --git a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h index ad14fbd88b..469bbab87c 100644 --- a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h +++ b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.h @@ -302,6 +302,7 @@ class CNEOBaseCombatWeapon : public CBaseHL2MPCombatWeapon // Each hook checks IsReloadPhaseSystemEnabled itself, so with the flag off a hook call does nothing public: void StopReloadOnDrop(); + bool IsReloadPastUnload() const; // Clip1 includes the chambered round; the magazine can hold GetMaxClip1() more. bool HasChamberSlot() const; From 1fc30ecaad83d06fec29ad307906e668756805f5 Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sun, 8 Nov 2026 19:46:52 -0700 Subject: [PATCH 53/55] Hold an SRS reload until the bolt is home With sv_neo_reload_experimental, a reload pressed during the bolt cycle after a shot cleared the pending bolt and then counted the spent case as a chambered round: the tactical reload ran without a bolt cycle, the unload kept one round and the load added it back. The reload now waits for the bolt while rounds are left; an empty gun reloads at once, as before. With the flag off the check is false. --- src/game/shared/neo/weapons/weapon_srs.cpp | 12 ++++++++++++ src/game/shared/neo/weapons/weapon_srs.h | 1 + 2 files changed, 13 insertions(+) diff --git a/src/game/shared/neo/weapons/weapon_srs.cpp b/src/game/shared/neo/weapons/weapon_srs.cpp index 6bf5ec4a98..0a6eb32911 100644 --- a/src/game/shared/neo/weapons/weapon_srs.cpp +++ b/src/game/shared/neo/weapons/weapon_srs.cpp @@ -124,6 +124,11 @@ bool CWeaponSRS::Deploy() bool CWeaponSRS::Reload() { + if (BoltPhasesBlockReload()) + { + return false; + } + // The reloading animation already contains the bolting motion; // we don't want to bolt twice. m_bNeedsBolting = false; @@ -159,6 +164,13 @@ bool CWeaponSRS::BoltPhasesBlockShot() const return HasChamberSlot() && IsBoltPending(); } +// With rounds left, the chamber holds the shot's spent case until the bolt is home. A reload before then would +// count the case as a chambered round, at the unload and as the round kept through the magazine change +bool CWeaponSRS::BoltPhasesBlockReload() const +{ + return HasChamberSlot() && IsBoltPending() && m_iClip1 > 0; +} + void CWeaponSRS::BoltPhasesOnShot() { if (!IsReloadPhaseSystemEnabled()) diff --git a/src/game/shared/neo/weapons/weapon_srs.h b/src/game/shared/neo/weapons/weapon_srs.h index c73439a99e..a7ef6f9422 100644 --- a/src/game/shared/neo/weapons/weapon_srs.h +++ b/src/game/shared/neo/weapons/weapon_srs.h @@ -60,6 +60,7 @@ class CWeaponSRS : public CNEOBaseCombatWeapon // Bolt phases (sv_neo_reload_experimental); each hook does nothing with the flag off bool BoltPhasesBlockShot() const; + bool BoltPhasesBlockReload() const; void BoltPhasesOnShot(); bool BoltPhasesDelayCycle() const; void BoltPhasesOnCycle(); From 97ad1890e01191a2ce118d0ce0d64649698c1bb4 Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sun, 8 Nov 2026 23:46:00 -0700 Subject: [PATCH 54/55] Drop the name from the NEO TODO comments --- src/game/client/neo/ui/neo_hud_ammo.cpp | 16 +++++++++++++++- src/game/server/neo/bot/neo_bot.cpp | 18 +++++++++++++++++- .../neo/weapons/weapon_neobasecombatweapon.cpp | 4 ++-- 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/game/client/neo/ui/neo_hud_ammo.cpp b/src/game/client/neo/ui/neo_hud_ammo.cpp index 84525f1e51..97c65ac351 100644 --- a/src/game/client/neo/ui/neo_hud_ammo.cpp +++ b/src/game/client/neo/ui/neo_hud_ammo.cpp @@ -24,6 +24,8 @@ #include "weapon_smokegrenade.h" #include "weapon_supa7.h" +ConVar cl_neo_harness_hudtrace("cl_neo_harness_hudtrace", "0", FCVAR_NONE, "Harness only: print the ammo HUD inputs when they change"); // NEO-HARNESS-TEMP + // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" @@ -166,9 +168,21 @@ void CNEOHud_Ammo::DrawAmmo() const int fireModeWidth = 0, fireModeHeight = 0; int magSizeMax = 0; int magSizeCurrent = 0; - // NEO TODO (sunzenshen): client tests for the 30+1/30 row and the chamber glyph (fresh, after tactical reload, after drop). + // NEO TODO: client tests for the 30+1/30 row and the chamber glyph (fresh, after tactical reload, after drop). // a gun with a chamber counts the magazine in the row, and the round icon of the fire-mode glyph shows the chamber const bool hasChamber = activeWep->HasChamberSlot(); + { // NEO-HARNESS-TEMP: the HUD's ammo inputs, printed when they change + static ConVarRef s_hudTrace("cl_neo_harness_hudtrace"); + static char s_szLast[128]; + char szHud[128]; + V_sprintf_safe(szHud, "clip=%d mag=%d chambered=%d haschamber=%d", activeWep->Clip1(), activeWep->RoundsInMagazine(), + activeWep->IsRoundChambered() ? 1 : 0, hasChamber ? 1 : 0); + if (s_hudTrace.IsValid() && s_hudTrace.GetBool() && V_strcmp(szHud, s_szLast)) + { + V_strcpy_safe(s_szLast, szHud); + Msg("NEO_HUDTRACE t=%.3f %s\n", gpGlobals->curtime, szHud); + } + } // NEO-HARNESS-TEMP if ((activeWep->UsesClipsForAmmo1() && !(activeWep->GetNeoWepBits() & NEO_WEP_THROWABLE)) || (activeWep->GetNeoWepBits() & NEO_WEP_BALC)) { diff --git a/src/game/server/neo/bot/neo_bot.cpp b/src/game/server/neo/bot/neo_bot.cpp index 0e9479d7e4..c135162828 100644 --- a/src/game/server/neo/bot/neo_bot.cpp +++ b/src/game/server/neo/bot/neo_bot.cpp @@ -35,6 +35,9 @@ ConVar neo_bot_ignore_real_players("neo_bot_ignore_real_players", "0", FCVAR_CHE ConVar neo_bot_shotgunner_range("neo_bot_shotgunner_range", "320", FCVAR_NONE); ConVar neo_bot_recon_ratio("neo_bot_recon_ratio", "0.2", FCVAR_NONE); ConVar neo_bot_support_ratio("neo_bot_support_ratio", "0.2", FCVAR_NONE); +// NEO-HARNESS-TEMP: harness-only, so an in-eye spectator sees a chosen weapon in bot hands. +ConVar sv_neo_harness_bot_weapon("sv_neo_harness_bot_weapon", "", FCVAR_CHEAT, + "Harness only: bots pick this loadout weapon (e.g. weapon_zr68c) when their class can carry it."); extern ConVar bot_class; extern ConVar neo_bot_fire_weapon_min_time; @@ -682,6 +685,19 @@ void CNEOBot::Spawn() int CNEOBot::ChooseRandomWeaponIndex() const { + // NEO-HARNESS-TEMP: forced bot weapon, see sv_neo_harness_bot_weapon + const char *szForcedWep = sv_neo_harness_bot_weapon.GetString(); + if (szForcedWep[0] && IN_BETWEEN_EQ(NEO_CLASS_RECON, m_iNeoClass, NEO_CLASS_VIP)) + { + for (int i = 0; i < MAX_WEAPON_LOADOUTS; ++i) + { + if (FStrEq(CNEOWeaponLoadout::s_LoadoutWeapons[m_iNeoClass][i].info.m_szWeaponEntityName, szForcedWep)) + { + return i; + } + } + } + const int iEffectiveXP = CNEOWeaponLoadout::GetEffectiveXP(m_iXP); const ENeoRank eRank = static_cast(GetRank(iEffectiveXP) - 1); if (eRank == NEO_RANK_RANKLESS_DOG || (false == IN_BETWEEN_EQ(NEO_CLASS_RECON, m_iNeoClass, NEO_CLASS_VIP))) @@ -1820,7 +1836,7 @@ void CNEOBot::ReloadIfLowClip(bool bForceReload) return; } - // NEO TODO (sunzenshen): with a chamber slot 30 of 31 counts as full here, and 29+1 (clip 30) never reloads by bot + // NEO TODO: with a chamber slot 30 of 31 counts as full here, and 29+1 (clip 30) never reloads by bot // logic. Accepted for now; revisit the threshold later. if (myWeapon->Clip1() >= myWeapon->GetMaxClip1()) { diff --git a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp index 3e04504a21..b4ecf00a00 100644 --- a/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp +++ b/src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp @@ -594,7 +594,7 @@ bool CNEOBaseCombatWeapon::ReloadPhasesOnDeploy() // Only a phase that a sequence resumes from outlasts the switch, with the table that names the resume void CNEOBaseCombatWeapon::ReloadPhasesOnHolster() { - // NEO TODO (sunzenshen): Decide whether RELOAD_END should stop the gesture on a switch. + // NEO TODO: Decide whether RELOAD_END should stop the gesture on a switch. if (!IsReloadPhaseSystemEnabled()) { return; @@ -876,7 +876,7 @@ void CNEOBaseCombatWeapon::StopReloadOnDrop() StopReloadSoundPieces(); // Preserve a pending bolt cycle for the next owner's draw. - // NEO TODO (sunzenshen): Should a drop after 1_unload also resume for the next owner? + // NEO TODO: Should a drop after 1_unload also resume for the next owner? if (m_nReloadPhase >= RELOAD_PHASE_LOADED && FindResumeSequence()) { return; From 474b2ec031ab67f10f7add01f645892a2f80a206 Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Sun, 8 Nov 2026 23:47:00 -0700 Subject: [PATCH 55/55] Remove harness-only code committed by mistake The previous commit took the harness trace commands (NEO-HARNESS-TEMP) along with the TODO rename. They stay out of the PR. --- src/game/client/neo/ui/neo_hud_ammo.cpp | 14 -------------- src/game/server/neo/bot/neo_bot.cpp | 16 ---------------- 2 files changed, 30 deletions(-) diff --git a/src/game/client/neo/ui/neo_hud_ammo.cpp b/src/game/client/neo/ui/neo_hud_ammo.cpp index 97c65ac351..55d355b076 100644 --- a/src/game/client/neo/ui/neo_hud_ammo.cpp +++ b/src/game/client/neo/ui/neo_hud_ammo.cpp @@ -24,8 +24,6 @@ #include "weapon_smokegrenade.h" #include "weapon_supa7.h" -ConVar cl_neo_harness_hudtrace("cl_neo_harness_hudtrace", "0", FCVAR_NONE, "Harness only: print the ammo HUD inputs when they change"); // NEO-HARNESS-TEMP - // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" @@ -171,18 +169,6 @@ void CNEOHud_Ammo::DrawAmmo() const // NEO TODO: client tests for the 30+1/30 row and the chamber glyph (fresh, after tactical reload, after drop). // a gun with a chamber counts the magazine in the row, and the round icon of the fire-mode glyph shows the chamber const bool hasChamber = activeWep->HasChamberSlot(); - { // NEO-HARNESS-TEMP: the HUD's ammo inputs, printed when they change - static ConVarRef s_hudTrace("cl_neo_harness_hudtrace"); - static char s_szLast[128]; - char szHud[128]; - V_sprintf_safe(szHud, "clip=%d mag=%d chambered=%d haschamber=%d", activeWep->Clip1(), activeWep->RoundsInMagazine(), - activeWep->IsRoundChambered() ? 1 : 0, hasChamber ? 1 : 0); - if (s_hudTrace.IsValid() && s_hudTrace.GetBool() && V_strcmp(szHud, s_szLast)) - { - V_strcpy_safe(s_szLast, szHud); - Msg("NEO_HUDTRACE t=%.3f %s\n", gpGlobals->curtime, szHud); - } - } // NEO-HARNESS-TEMP if ((activeWep->UsesClipsForAmmo1() && !(activeWep->GetNeoWepBits() & NEO_WEP_THROWABLE)) || (activeWep->GetNeoWepBits() & NEO_WEP_BALC)) { diff --git a/src/game/server/neo/bot/neo_bot.cpp b/src/game/server/neo/bot/neo_bot.cpp index c135162828..8f9036fb00 100644 --- a/src/game/server/neo/bot/neo_bot.cpp +++ b/src/game/server/neo/bot/neo_bot.cpp @@ -35,9 +35,6 @@ ConVar neo_bot_ignore_real_players("neo_bot_ignore_real_players", "0", FCVAR_CHE ConVar neo_bot_shotgunner_range("neo_bot_shotgunner_range", "320", FCVAR_NONE); ConVar neo_bot_recon_ratio("neo_bot_recon_ratio", "0.2", FCVAR_NONE); ConVar neo_bot_support_ratio("neo_bot_support_ratio", "0.2", FCVAR_NONE); -// NEO-HARNESS-TEMP: harness-only, so an in-eye spectator sees a chosen weapon in bot hands. -ConVar sv_neo_harness_bot_weapon("sv_neo_harness_bot_weapon", "", FCVAR_CHEAT, - "Harness only: bots pick this loadout weapon (e.g. weapon_zr68c) when their class can carry it."); extern ConVar bot_class; extern ConVar neo_bot_fire_weapon_min_time; @@ -685,19 +682,6 @@ void CNEOBot::Spawn() int CNEOBot::ChooseRandomWeaponIndex() const { - // NEO-HARNESS-TEMP: forced bot weapon, see sv_neo_harness_bot_weapon - const char *szForcedWep = sv_neo_harness_bot_weapon.GetString(); - if (szForcedWep[0] && IN_BETWEEN_EQ(NEO_CLASS_RECON, m_iNeoClass, NEO_CLASS_VIP)) - { - for (int i = 0; i < MAX_WEAPON_LOADOUTS; ++i) - { - if (FStrEq(CNEOWeaponLoadout::s_LoadoutWeapons[m_iNeoClass][i].info.m_szWeaponEntityName, szForcedWep)) - { - return i; - } - } - } - const int iEffectiveXP = CNEOWeaponLoadout::GetEffectiveXP(m_iXP); const ENeoRank eRank = static_cast(GetRank(iEffectiveXP) - 1); if (eRank == NEO_RANK_RANKLESS_DOG || (false == IN_BETWEEN_EQ(NEO_CLASS_RECON, m_iNeoClass, NEO_CLASS_VIP)))