Repository navigation
Research: partial reloads for the primary weapons and pistols - #2290
Closed
sunzenshen wants to merge 60 commits into
Closed
sunzenshen wants to merge 60 commits into
sunzenshen wants to merge 60 commits into
Conversation
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Port the old slice's 30+1 count and the fire-mode glyph's chamber icon, guarded by HasChamberSlot.
Bring in the MVP's per-weapon reload tables and the per-map flag, and finish the slice code for the full set of ZR68C animations: use the new sequence names (reload_reloadexit for the fresh tactical reload), add the unload sound piece entry, and let a gun with a loaded magazine and an empty chamber play the dry reload to chamber a round when its resume was lost.
The user renamed the slice's clips after the shipped lowtoidle pattern: reload_reloadexit is now reload_loadedtoidle.
The user chose skipcycle for the clip that returns to idle without the bolt pull: it says why the clip exists.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Tactical reloads keep the chambered round. The original reload animations and sounds play unchanged.
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.
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.
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).
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.
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.
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.
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.
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_<step>, 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.
Bring in the NeotokyoRebuild#2285 commits that cut its gesture change, add the one-line reload-phase hooks and rename the sound pieces. Each conflict resolves to the slice: it keeps its gesture fit, which short resumes and reload_skipcycle need. The hook layout and the sound names follow in their own commits.
Master's Reload, FinishReload, Deploy, Holster and ItemBusyFrame gain one hook call each, as in NeotokyoRebuild#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.
Name each piece reload_<step>, and a step's later pieces _part2, as in NeotokyoRebuild#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.
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.
Bring in the ZR68C slice's review-ease commits: the reload phases run through one-line ReloadPhasesOn* hooks, the in-reload guard moves behind the flag, and the ZR68 sound pieces are named by step. The only conflict: the research makes the chamber queries virtual so the SRS and the Supa-7 can override them; they stay virtual in the hook layout's public block.
Name each primary's reload sound pieces reload_<step>, 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.
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.
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.
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.
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.
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.
The previous commit took the harness trace commands (NEO-HARNESS-TEMP) along with the TODO rename. They stay out of the PR.
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.
Builds on #2286 (review that first). Companion of NeotokyoRebuild/neoAssets#175, which holds the
animations and sounds.
Description
This research PR turns on the partial-reload slice from #2286 for the other primary weapons and the
MilSO and Tachi pistols, and adds a tube-and-chamber reload for the Supa-7. It is data for each gun plus three C++
changes: the third-person reload fix, which #2286 also carries, the SRS bolt and the Supa-7. The PBK56S is not covered (no viewmodels
exist). With
sv_neo_reload_experimental 1, each wired gun reloads tactically, resumes after a weapon switch at theunload or the load step, and keeps a chambered round (+1), as the ZR68C does in #2286.
Per-gun wiring
Each weapon script gets the same block as the ZR68C:
and the sound entries for the reload pieces go in
game_sounds_weapons.txt, namedreload_<step>[_part<N>]as in#2285 (
weapon_<gun>.reload_unload,reload_load,reload_cycle, plus_part2/_part3pieces on some guns; the)prefix kept). The phases files come from neoAssets.weapon_m41,weapon_m41s,weapon_m41lweapon_mpn,weapon_mpn_unsilencedweapon_mx,weapon_mx_silencedweapon_zr68s,weapon_zr68lweapon_jitte,weapon_jittescopedweapon_srm,weapon_srm_sweapon_srsweapon_aa13weapon_pzweapon_milso,weapon_tachiA gun without a phases file keeps the normal reload and the parser warns, so a script can ship before its assets.
ZR68-S plays the ZR68C's sound pieces; the ZR68-L has its own. The pistols keep their reload animations and sounds;
their phases file only times the slide release, so a tactical reload keeps the chambered round. The Kyla is unchanged.
Unload clip, bots and code layout
above, SRS included): when the old magazine comes out, the clip drops to the chambered round, 1 or 0, and the old
magazine's rounds are discarded there instead of at the load, as master's reload discards them. The reserve changes
as on master. The rule is in the shared reload-phase code, so no gun carries its own copy.
the old magazine until the load, as on master. The Supa-7 has no magazine: shells go into the tube one at a time and
nothing is unloaded. The Kyla is unchanged.
secondary on the empty clip. The check covers every gun with an unload step and is false with the flag at 0.
reload pressed in the bolt cycle counted the spent case as a chambered round: the tactical reload skipped the bolt
and the unload kept one round. A held R reloads when the bolt is home; an empty SRS reloads at once, as before.
ReloadPhasesOn*hooks from Partial reloads 03: Resume a ZR68C reload after the magazine is unloaded #2285 and Partial reloads 05: Keep a chambered round through a partial reload #2286,BoltPhases*in the SRS andTubePhases*in the Supa-7. A few masterlines change beyond a one-line call (listed under Known limits).
Third-person reload fix
reload_skipcycleplayed the whole gesture against a shorter clip. The world model was also given a viewmodelsequence index, which asserted in
studio.cppon other clients.ends it with the clip (keep-end); a fresh partial reload keeps the gesture start and cuts it at the clip end
(keep-start). The world model no longer gets a viewmodel index.
changes.
Supa-7
Under
sv_neo_reload_experimental 1the Supa-7 tracks a 6-round tube and a chambered round (7 in the gun, as master).With the flag at 0 it runs master's code path.
reloadend) plays first: thechamber is fed at 0.700 s and the gun fires at 1.000 s.
draw. The round in the hand and a rack not yet home are dropped.Where the pieces come from:
035_EXPERIMENTAL_AdvancedSupa7.The base chamber hooks are made virtual so the Supa-7 can override them; the Supa-7 itself is
weapon_supa7.{h,cpp}only. It uses the shipped clips and sounds, so there are no new assets.Time to first shot, from the R press (flag 1 against master):
Divergences from master, for reviewers:
Known limits and reviewer flags
and keeps the chambered round; a dry reload runs it.
pace fixes (some glued clips on the MPN45, SRS and PZ252 are 2-4 frames longer). Debug client and dedicated server
compile with 0 warnings. The test results below are from before these changes.
slug load, the next-insert step and the reload press, and the SRS
Deployassignment. The Supa-7 shot bookkeepingruns master's code before its tube hook; this order needs a game check before the PR leaves draft.
change here.
How to test
sv_neo_reload_experimental 1.the draw should continue with the load and the cycle and end at a full magazine + 1.
Test results
Linux listen server (Debug client) with the companion models,
sv_neo_reload_experimental 1unless noted:reload_skipcycle14 to 16; fresh dryreload0 to 15; dryafter unload
drawunloaded_reload0 to 15 in about 3.8 s; tactical after unload ends 16; dry after loaddrawtocycle_reloadends 15; tactical after load plaindraw; fire held through a resume fires after the clip end;M41S, M41L and NSF M41; flag 0 plays
reloadboth ways; ZR68C unchanged; headless TDM, 12 bots, 1 round: 0 asserts,0 crashes.
reload_skipcycle(for example MPN45 30 to 31, SRM 34 to 51); dry after unloaddrawunloaded_reload; dry after loaddrawtocycle_reload. MPN45 unsilenced, MX silenced, Jitte scoped and SRM-S fresh tactical; NSF MPN45 and SRS dry afterunload. SRS: tactical after a shot and the bolt ends 6 (5 + 1); dry
reloadends 5. Flag 0 MX:reloadboth ways,no + 1. Headless TDM, 12 bots, 1 round: 0 asserts.
after load, fresh dry, NSF dry after unload; flag 0 PZ252 tactical as master. The AA13 drum and PZ252 box stay off
screen through the unloaded draw. Headless TDM, 12 bots, 1 round: 0 asserts.
reload9 to 13 / 12 to 16; dryreloadempty0 to 12 / 0 to 15; first shot after a dry reload at the clip end with the flag on or off (about 2.1 s);a switch during the dry reload recovers and fires; Kyla still loads 6. Headless TDM, 12 bots, 1 round: 0 asserts.
thirdpersonview, Debug):reload_skipcycleends the gesture at cycle 0.878 after2.22 s; resumes keep the gesture; the Tachi switch-back replay plays whole; flag 0 unchanged; no
studio.cppasserts.TDM run
20261108-091726: PASS, 0 asserts. Another client's view was not tested.20261108-100716and20261108-100811: PASS, 0 asserts. Third person: the gesture plays per insert as master.SRS bolt
With the flag, the SRS counts a round as chambered only when the bolt is home (frame 25 of
charge, 0.833 s,from the phases file), and it cannot fire before then. Shot-to-shot gaps are unchanged (1.45 s both ways). After a
switch away mid-bolt the bolt runs again after the draw, so the first shot comes 1.64 s after the switch back
instead of master's 0.84 s; this is a deliberate change for realism. Headless TDM, 12 bots, 1 round: 0 asserts.
Toolchain
Linked Issues