Repository navigation
Partial reloads 06: Resume a ZR68C reload after the magazine is unloaded - #2293
Closed
sunzenshen wants to merge 3 commits into
Closed
sunzenshen wants to merge 3 commits into
sunzenshen wants to merge 3 commits into
Conversation
Behind sv_neo_reload_experimental, a weapon whose script has a ReloadPhases block (only the ZR68C here) keeps its reload step across a weapon switch: switched after the unload, the next draw plays the resume sequence named in the phases file, loads the magazine and plays the remaining sound pieces. A switch before the unload still cancels the reload, and a dropped weapon cancels it. The parser reads the ReloadPhases block and stores tables only for weapons that have one. Master's Reload, FinishReload, Deploy, Holster and ItemBusyFrame each gain one call into a hook that checks the flag. The flag is read once per map into the game rules. The third-person reload gesture adopts the new weapon on a resumed reload, so NEO's weapon-switch reset does not clear it. The viewmodel reads the weapon data by reference instead of copying it every frame.
Reviewers can test the resume without setting the cvar. The last PR of the partial-reload stack sets the default back to 0.
This was referenced Nov 9, 2026
sunzenshen
force-pushed
the
stack/reload-zr68c/30-mvp
branch
from
November 10, 2026 02:10
86d98ed to
17e65e5
Compare
sunzenshen
changed the base branch from
master
to
stack/reload-zr68c/11-tachi-low
November 10, 2026 02:12
sunzenshen
marked this pull request as ready for review
November 10, 2026 04:47
sunmachine
reviewed
Nov 10, 2026
sunmachine
requested changes
Nov 10, 2026
The gamerules constructor runs before the queued exec of server.cfg, so the first map after a server start used the flag's previous value. Read it on the first think instead, which runs after the cfg, and keep it for the whole map as before.
sunmachine
self-requested a review
November 10, 2026 05:49
sunmachine
approved these changes
Nov 10, 2026
sunzenshen
marked this pull request as draft
November 12, 2026 06:55
This was referenced Nov 13, 2026
Closed
Closed
Closed
Contributor
Author
|
Closing to clear the board in favor of sunzenshen#34 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Depends on NeotokyoRebuild/neoAssets#179 (the ZR68C resume animation, its phases file and three reload sounds).
Partial reloads 06: this PR pairs with neoAssets layer 06 (NeotokyoRebuild/neoAssets#179) and builds on #2310 (layer 02: an
empty Tachi keeps its slide back while lowered, with NeotokyoRebuild/neoAssets#194). The other neoAssets layers under it
have no neo PR: 01 (NeotokyoRebuild/neoAssets#176, the Blender layout and tools), 03 (NeotokyoRebuild/neoAssets#195, the
MilSO sources) and 05 (NeotokyoRebuild/neoAssets#177, the ZR68C sources) carry no game change; 04
(NeotokyoRebuild/neoAssets#196, lowered clips for an empty MilSO) is played by the layer 02 code. Next: #2292 (07, resume after the
load) and #2294 (08, the bolt cycle, a chambered round).
Today a weapon switch during a reload cancels it, even after the old magazine has visibly dropped
out. With
sv_neo_reload_experimental 1, a ZR68C reload that is interrupted after the unload stepcontinues when the ZR68C is drawn again: the draw brings up the fresh magazine, seats it, pulls the
bolt, and ends with a full magazine. The resume cannot be skipped; the gun can fire when it ends.
The last PR of the stack sets the default back to 0. The flag is read once when the map starts (into the game
rules), so a change applies from the next map.
view. The one shared-file change is in
hl2mp_playeranimstate(+8 lines). The resume starts inDeploy, after theweapon switch, so NEO's weapon-switch reset in
multiplayer_animstate.cppcleared the gesture after one frame. Theresume's reload event carries a
RELOAD_EVENT_RESUMEDmarker, and only that event adopts the new weapon after thegesture starts. A plain reload event runs master's code.
ReloadPhasesblock uses the new code, and only the ZR68C has one.seat (1.333 s) instead of at 2.217 s, so a switch after the seat keeps the full magazine and plays
a normal draw. A switch before the unload cancels the reload as it does today.
How it works
ReloadPhaseslists, per viewmodel sequence, when each reload step (1_unload,2_load,3_cycle) counts its ammo and when each of its sounds plays. A resume after step N listsonly the later steps, so it never replays an earlier step's sound. A row's
resumekey names thesequence that resumes a reload interrupted after that step. The table is the one of the sequence the
reload plays, so
reloadandreloademptycan time and resume differently. The ZR68C rows come from neoAssets(
#base "weapon_zr68c_reload_phases.txt"), whose export sets every time from markers in the.blend, so the timing follows the animation. If that file is missing, the parser warns and theweapon plays the normal reload.
ends with both hands at rest. The resume uses no
ReloadReadyBeforeEnd-style time; an uninterruptedreload keeps today's code,
ReloadReadyBeforeEndincluded.table (both networked). Nothing else outlasts the switch.
(
drawunloaded_reload, 2.767 s) instead ofdraw. A second switch during the resume, before itsload, plays the resume again. The load step loads the magazine through the normal
reload finish. The load, its tap and the cycle sounds play as separate pieces, because the single reload sound
cannot start part way. A switch or a drop stops them.
not resume it.
Reload,FinishReload,Deploy,HolsterandItemBusyFrameeach gain oneReloadPhasesOn*call. Every hook holds the flag gate, so master's functions only gain one-line calls.weapon_zr68.reload_load,reload_load_part2andreload_cycle, asreload_<step>[_part<N>]. Indrawunloaded_reloadthey start at 1.367 s, 1.800 s and 2.100 s; the load countsat 1.400 s and the cycle at 2.333 s (times from the neoAssets phases file). The waves keep the
)prefix ofweapon_zr68.npc_reload, the entry NEO plays for areload (
RELOAD_NPC).predicts the resume with the server's values.
Why one glued resume sequence, not a runtime join
A runtime join (a transition clip, then
reloadstarted at the resume frame) hitched for about 85 ms at the join,because of how the engine updates a predicted viewmodel's sequence, and saved only about 3.9 KB per model. The model
duplicates the reload frames in the glued clip instead.
Cost with the flag off
props, 1 rules bit). Prediction fields are constant.
script has them (the ZR68C). The sound pieces are precached with the weapons soundscript at either flag value.
cheap.
neo_predicted_viewmodel.cppnow reads the weapon data by reference instead of copying it every frame.How to review
ReloadPhasesOn*calls inReload,FinishReload,Deploy,Holster,ItemBusyFrame. Each hook returns first on the flag.hl2mp_playeranimstate.cpp, guarded byRELOAD_EVENT_RESUMED.ReloadPhasesinneo_weapon_parse.cpp.drawunloaded_reload, the three sound pieces).How to test
sv_neo_reload_experimentalis 1 by default in this PR).(about 0.7 s in). Switch back: the draw should bring up a fresh magazine, seat it, pull the bolt,
and end with 30 rounds. Holding fire during this draw should not fire.
sv_neo_reload_experimental 0, and with another rifle at both values: the reloadshould behave as it does today.
Results
Tested with this PR's head and the neoAssets layer 06 assets (NeotokyoRebuild/neoAssets#179), Linux Debug client and dedicated server, no
warnings. The layer 06 resume clip is 2 frames longer than the one first tested here (a slower magazine clasp flip
in
drawunloaded): the resume runs 2.767 s instead of 2.70 s, and its load and every sound piece come 0.067 s later(load 1.400 s instead of 1.333 s). The third-person, remote-view and flag-off rows were measured with the earlier clip; the code
they exercise did not change, and the clip length does not enter the flag-off path.
drawunloaded_reload, clip 0 to 30 at 1.41 s after the draw (table 1.400 s), fire allowed at the clip end (2.767 s); fire held through the draw fires no shotReload_ZR68Cplays whole (2.51 s) inside the 2.767 s resume; nostudio.cppassertsReloadPhasesdraw, then the normal reload; no resumematch_end=True, 0 assertsFlag-off against master. One script (ZR68C then Tachi: taps, tactical and dry reloads, switches at 0.3 s and 1.0 s)
logged per tick the weapon, clip, in-reload state, viewmodel sequence and next-attack time, on this PR and on master.
The difference between the PR and master is smaller than master's own run-to-run noise: 194 aligned states, one
differing block (a wall-clock race in the script on master), next-attack times equal within one tick at every state
entry. A second pair confirms it; the two PR runs are identical.
Remote view. A bot replayed the owner's inputs (
bot_mimic) and the owner's client rendered it as a remote player.After a switch and the resume draw, the bot's
Reload_ZR68Crestarts on the draw and plays whole. Its sound piecesstart +0.452 s and +0.753 s after the load piece (table: +0.433 s, +0.733 s; the same spacing in layer 06).
cl_showerrorshows no prediction error at the switch, theresume draw, the fill or the end. This used a bot observed by one client, not two human clients.
The only asserts are engine baseline asserts (
m_simThinkListat join, one client shadow-leaf assert); none firesduring a reload.
Known limits
with an enemy within 250 units switches to its secondary then (
EquipBestWeaponForThreat), as intoday's empty reload; its next draw resumes again.
same after 2.217 s.
Later PRs
Resuming after the load and after the cycle, keeping a chambered round (31/30), and partial reloads.
The script block and the phase list are shaped so those add rows and cases, not new syntax.
Toolchain
Linked Issues