Grave Spade RE: killing, pinning and posing a worm
Status: built and shipped in Melange 0.16.0. These are the research notes written before and during the work; the API as built is documented in lua-api.md, and where the two differ lua-api.md is right.
These are research notes for the Kindjal Grave Spade execution (Melange 0.16.0). They cover three questions:
- (a) a deterministic sim-side instant kill;
- (b) a prone victim with the attacker mounted on it;
- (c) a client-side pose or bone override: hands that follow a held object, a bent body, and a hidden head.
The notes propose an API and a hook plan. (a) and (b) shipped in 0.16.0 as written.
Update after the in-game run (r1): Route A is dead on build #1077. Worms are skinned on the CPU. In game, no
FFVertex*Skinnedprogram was ever created. The cause is static and was checked in the disassembly: the concrete GL draw actionXOglDrawAction(vtable0x8b319c) overrides the vertex-program name builder in slot 60 with0x790880. That function starts withtest al, 8; jeand returns the empty name for every index with bit 8 (“Skinned”). The baseIXDrawActionImplbuilder0x78eb20(vtable0x8b2c3c) would append “Skinned”. The program loader0x78ec80skips an empty name, so the 64-entry vertex table never holds a skinned program, and skinned shapes reach GL already blended through the plainFFVertexMain*programs. TheBlendMatpalette is never uploaded, so there is nothing to patch. The earlier inference from Sunstone ([I] below) was wrong. MiragePose now checks for that override at install. When it finds it, it uses the CPU route instead (gravespade-re-pose-cpu-skin.md, implemented in 0.16): the palette at the engine’s XSkinShape draw, plus the mesh transform and the clip table (gravespade-re-pose-anim.md). The Grave Spade now stages the mount through it; the upright staging with client meshes stays as its fallback. (Before the CPU route this note read: a real pose on this build would need the CPU skinning path, where the per-instance joint matrices are blended into the vertex stream, inside the XOM scene traversal ofXOglDrawAction; slot 190x78e8d0walks the shape’s children with a matrix stack.)
Everything refers to build #1077 (WormsMayhem.exe, Steam/GOG). Decompiles are re/out/decomp/decomp_<chunk>.c in the private research checkout. Message-object names were resolved by scanning the static initialisers push "<name>"; mov ecx, <obj>; call 0x68bb9f (2082 objects).
Confidence follows meshes.md:
| Tag | Meaning |
|---|---|
| [V] | Read from the decompile or disassembly, and consistent with the data files |
| [I] | Inferred from strong indirect evidence |
| [P] | A proposal not yet run in game |
| [U] | Unknown |
Verdicts
Section titled “Verdicts”| Question | Verdict | Route |
|---|---|---|
| (a) Instant kill from the sim | Feasible today, and cleanly in 0.16. | Worm.KillNow (an IntMessage carrying the slot) is a vanilla, script-only “die now” message the worm already subscribes to. 0.16 should wrap it as worm:kill{...}, with hooks that skip the death explosion and grave and shorten the throes. |
| (b) Prone victim, mounted attacker | Feasible as a visual only. No engine prone state exists. | The sim anchors both worms (worm:anchor, 0.11). “Prone” and “mounted” are client pose overrides of the rendered skeleton (c). Sim positions never change, so this cannot desync. |
| (c) Client pose or bone override | Not on build #1077 (CPU skinning, see the update above). The GL palette patch below was the planned route. | Worms are GPU-skinned with a 34-bone world-space palette (BlendMat[35]) that the game uploads as ARB program-local registers. Melange already mirrors those registers and hooks glDrawElements. The work is: patch the palette per draw for one worm, restore it after, and optionally draw a second copy with another palette to get a severed head. Hats and the held weapon need extra handling (see Attachments). |
| Fallback | Available | Vanilla clips by name through XMeshInstance::PlayClip 0x6a0730 (speed scalable), plus client meshes. See the clip list. |
(a) Killing a worm
Section titled “(a) Killing a worm”How a worm dies [V]
Section titled “How a worm dies [V]”Worm logic is WXWormLogicEntity (one per slot):
- the slot is the byte at
+0x30; HandleMessageis0x5b07c0, and its second-level handler is0x5adcf0;- the per-tick update is
0x5b1d60, which is 20 ms per sim tick.
The worm’s data is the WormDataContainer described in worm_anchor.cpp: health is a u16 at +0x11e, state +0xf0, flags +0xec, active +0x124.
| Step | Function | What it does |
|---|---|---|
| Damage accrues | AddDamage 0x5ab7e0 (thiscall on the logic entity: amount, type) |
Adds to a per-type pending array at container +0x118 (types 0..7). Types 2, 3 and 4 are capped at 75, type 6 is uncapped and skips stats, type 7 is fire. It also sets data DamagedWorm.Id and DamageTypeTaken, updates the Turn.*Damage stats and posts Worm.Damaged. Callers are Explosion 0x5ae4f0, Damage.Impulse 0x5ae320, poison 0x5ac060, Vapourize 0x5ac160, and 0x5ac3e0/0x5ca1f0. |
| Turn-end apply | GameLogic.ApplyDamage → 0x5abc50 |
Sums the pending array. If the sum is at least the health, it sets flag 4 and health 0 (0x5a70e0, “Worm Waiting To Die”) and posts GameLogic.AddMeToDeathQueue. Otherwise it subtracts. It also posts GSS.CreateDamageGraphic and Worm.DamageComplete. |
| Death queue | GameLogic → Worm.TimeToDie → 0x5adbf0 |
Unless the worm is drowning (state 8), it posts Worm.LandDeath(slot), runs ChangeState(container, 7 = DeathThroes) and queues anim id 0x13 (“Death” clip). 0x5a7190 (“Worm Dying”) sets health 0, records stats, and posts WormManager.SurrenderTeamById if flag 0x100. The throes timer at logic entity +0x128 = 3000 ms. |
| Throes tick | 0x5aa080 (state 7, from Update 0x5b1fe1) |
The timer drops by 20 each tick. At 0 or below it sets active = 0 and runs the death explosion 0x5a9400, which uses data Worm.DeathWormDamageMagnitude, ...ImpulseMagnitude, ...WormDamageRadius, ...LandDamageRadius and ...ImpulseRadius through 0x518ce0, plus FX WXP_Explosion_Small. It then makes the gravestone 0x5a9310 (team grave style, at feet + 20 y) and posts WXWormManager.UnspawnWorm(slot) (handled by WXWormManagerService 0x5b5e70 → 0x5b4af0). |
| Drowning | 0x5ad640 → state 8, 0x5aa130 |
The same end through the drowning branch. |
Script-reachable “die now” messages [V]
Section titled “Script-reachable “die now” messages [V]”Message objects are named via the static-initialiser scan. Subscriptions are in the worm entity’s init 0x5a5ae0.
Worm.KillNow(object0x95fcd8, subscribed at0x5a5c3c). Its handler is in0x5adcf0:if (IntMessage.value == slot) { 0x5a70e0(container); 0x5adbf0(); }. That means flag 4, health 0, then straight into the throes (theWorm.TimeToDiepath) without the death queue. Nothing in the exe sends it, so it is a script-facing message. The engine’s ownSendIntMessage(0x69676a) builds exactly thisIntMessage(0x691951) and Posts it (0x6910e4), and the only effective deny isGameLogic.PauseGame(framework-feasibility U12).- So
wum.sim.sendInt("Worm.KillNow", slot)already kills a worm on Melange 0.15, at the same tick on every machine. Not yet run in game: [I].
- So
Worm.Vapourize(subscribed at0x5a5bc4, handler0x5ac160). It is a 16-byte two-int message{slot, 20}built by0x691985; the only sender is0x5885f0. It runs ApplyDamage, AddDamage(health, 0), ApplyDamage, sets active = 0, posts UnspawnWorm and records stats0x613080. The worm vanishes at once: no throes, no explosion, no grave. There is no Lua binding for two-int messages, so this route is C++ only.Worm.TimeToDieis the death-queue message. On its own it skips0x5a70e0(health stays as it was), so it must not be sent alone.Worm.DieQuietlygoes toWXWormManagerService(0x5b5e70) and acts on a global or the active worm, not on a slot. Not useful.- Do not write health alone.
ApplyDamagereturns early when health is 0, and nothing then moves the worm into the throes, so it stays “alive” at 0 hp.
Kill options
Section titled “Kill options”-
K1, no core change (0.15):
wum.sim.sendInt("Worm.KillNow", slot). The full vanilla death follows: 3 s death anim, small death explosion, grave, unspawn.- The explosion hits the adjacent attacker and the terrain. To suppress the damage without core work,
wum.sim.setData("Worm.DeathWormDamageMagnitude"/"ImpulseMagnitude"/"LandDamageRadius", 0)before the kill and restore after the throes. That is deterministic, but the data ids still need a [U] check againstDataPrecheck. - The
WXP_Explosion_SmallFX and anExplosionmessage still fire. Bloodsand treats anExplosionat a dying worm asdieNowand blows the corpse apart.
- The explosion hits the adjacent attacker and the terrain. To suppress the damage without core work,
-
K2, damage accrual: call
AddDamage(health, 6)through the logic entity at strike time. The engine kills the worm in the normal turn-end death queue, which is the most “vanilla” for stats.- Rejected for the spade: the death would run at turn end, which is before the holdTurn cinematic, so the victim would be a gravestone before the camera orbits. The exact order of the death queue against
GameLogic.Turn.Endedis [U].
- Rejected for the spade: the death would run at turn end, which is before the holdTurn cinematic, so the victim would be a gravestone before the camera orbits. The exact order of the death queue against
-
K3, recommended for 0.16 [P]:
worm:kill{explode=false, grave=true, throesMs=N}. It postsWorm.KillNowfrom C++ (thelevels/factory.cppmessage-post pattern: alloc0x691705,IntMessagector0x691951, Post0x6910e4) and records per-slot kill options. Three hooks, active only while a record exists, read those options:- after
0x5adbf0(thiscall,ecx= logic entity): set entity+0x128 = throesMs(default 3000; 20..3000); 0x5a9400(death explosion,__stdcall(container)): skip whenexplode=false. That means no explosion, no FX and noExplosionmessage;0x5a9310(gravestone, thiscallecx= entity, arg container): skip whengrave=false.
The records are sim state, set by sim scripts at the same tick on every machine, so they are hashed in a Wormsign contributor (
melange.wormkill) and cleared at UnspawnWorm or match end. - after
Net safety for every route: the sim script issues the kill. The engine’s message processing and the 20 ms throes timer are sim-tick driven, so every machine dies at the same tick. Nothing reads the camera or the local player.
Open risks [U], to check in a LocalNet run:
- A kill during a
holdTurn(betweenTurn.Endedand the swallowedStartTurn): team-elimination and game-over checks, and the next-worm selection when the victim was the next team’s chosen worm (Worm.RemoveFromTeamQueueexists). - Killing the last worm of a team.
Worm.LandDeathcommentary playing mid-hold.
Bloodsand also needs to know about the kill. With K3 and explode=false it sees no Explosion. It takes the “state flipped or worm vanished” death branch and would throw organ gibs on a decapitated corpse. Kindjal sends mod.kindjal.decap first (see the Bloodsand recon) so Bloodsand marks the slot decap.
(b) Prone victim and mounted attacker
Section titled “(b) Prone victim and mounted attacker”-
There is no prone or knocked-down state [V]. The physics states (
kWPS_*table0x90d374) are Ambulatory 0, DetectJump 1, Ballistic 2, Sliding 3, Vaulting 4, Override 5, Passive 6, DeathThroes 7 and DrownFloat 8. “Knocked” worms are Ballistic flights withBlastflight2..5clips that recover withRecoverBack1/2,RecoverFront1andRecoverBurried1(resolved by the graphic entity init0x5a49a0). -
Worm.OverridePhysics(handler in0x5adcf0):- a positive int puts the worm in state 5, ORs the int into
+0xe8, sets+0xecbit 1 and queues anim0x12; - zero or below clears the bits, goes Ballistic and queues anim 7.
The handler does not check a slot, so it reaches every worm entity that receives it. Do not use it from a script.
- a positive int puts the worm in state 5, ORs the int into
-
Recommendation [P]:
- The sim pins and kills. At the strike, in the sim hit handler, it calls
victim:anchor(true)andattacker:anchor(true). The anchor refuses Ballistic and Sliding, swallows walk and jump, and is released automatically when the victim enters state 7 (Repin, sim_worms.cpp). It sendsKindjal.Execute(victim|attacker|tick), armsholdTurnatTurn.Ended, and issuesworm:kill{explode=false}at the decap beat. The beat must be at leastthroesMs + 0.5 sbefore the hold ends. - The client poses. The victim is rendered rotated onto its back and the attacker translated and bent onto it, both through the pose override (c). Sim positions stay where they were, so Wormsign, physics and AI never see the cinematic.
- The sim pins and kills. At the strike, in the sim hit handler, it calls
-
A sim-side placement API (for example
anchor(true, x,y,z[,yaw])writing container+0x38and yaw+0x90throughBackend::Write) is possible and deterministic, but the spade does not need it. It is left out to keep the risk at zero. -
Engine anim ids can be queued on a logic entity, deterministically, through
0x5ac4d0(id, param), which pushes to the queues at entity+0x17c/+0x188(0x5acb80also sets the current id+0x244). Known ids are 7 (fly),0x12(override),0x13(death) and0x15(drown). The id-to-clip table lives in the graphic entity or data and is [U], so this is not proposed.
(c) Pose override
Section titled “(c) Pose override”The worm skeleton [V]
Section titled “The worm skeleton [V]”The data comes from xomtool clone W4.Worm --from Bundl474.xom --tree and inspect. W4.Worm (w4worm.xom, section 474) has three XSkins on one skeleton:
- the body,
boggybodyShape, 567 vertices, plus eye and teeth shapes; boggyhand_leftShape;boggyhand_rightShape.
Every XSkinShape has the same 34-entry bone palette, in this order. The palette index is the BlendMat index:
| idx | bone | parent | idx | bone | parent |
|---|---|---|---|---|---|
| 0 | main (root) | - | 17 | wrist_left | 16 |
| 1 | tail | 0 | 18 | pinkyknuckle_left | 17 |
| 2 | tail2 | 1 | 19 | pinky_left | 18 |
| 3 | tail3 | 2 | 20 | indexknuckle_left | 17 |
| 4 | head | 0 | 21 | index_left | 20 |
| 5 | upperlip_right | 4 | 22 | foreknuckle_left | 17 |
| 6 | upperlip_left | 4 | 23 | fore_left | 22 |
| 7 | bottomlip_left | 4 | 24 | thumb_left | 17 |
| 8 | bottomlip_right | 4 | 25 | shoulder_right | 0 |
| 9 | bottomlip | 4 | 26 | wrist_right | 25 |
| 10 | mouthmiddle_left | 4 | 27 | pinkyknuckle_right | 26 |
| 11 | mouthmiddle_right | 4 | 28 | pinky_right | 27 |
| 12 | eyetop_left | 4 | 29 | indexknuckle_right | 26 |
| 13 | eyebrow_left | 4 | 30 | index_right | 29 |
| 14 | eyetop_right | 4 | 31 | foreknuckle_right | 26 |
| 15 | eyebrow_right | 4 | 32 | fore_right | 31 |
| 16 | shoulder_left | 0 | 33 | thumb_right | 26 |
Locators (unskinned XGroups):
HatLocator,TashLocator,BubbleSpawnandVomitLocatorunder head;WeaponLocatorunderwrist_right(the held weapon mesh hangs here);Pack_LocatorandNameLocatorunder main.
The hands are separate skins, weighted only to the shoulder, wrist and finger bones, so moving a hand subtree moves the hand rigidly.
The body’s vertex weights against bind-space height (y) are what make a clean cut possible:
- head-subtree weight (bones 4..15) is 0 below y = -6;
- it rises through 0.2..0.5 between y = -6 and y = -2, and 0.74 at y = 0;
- it is at least 0.94 from y = 2 up to the top (y = 20).
The “head” is the upper half of the worm, and the blend band at y = -6..+2 is the neck.
How the game skins [V]
Section titled “How the game skins [V]”CG/FixedFunction.cg declares float4x4 BlendMat[35] : register(c8). The FFVertex*Skinned entries, which include FFVertexMainTexLitDirectionalSkinned, blend up to 4 bones per vertex (numBonesPerVertex, a uniform). They treat the skinned position as world space: the comment says “Object-space vertex coord (or world space for skinned objects)”, and only view and projection follow.
The game binds Cg through cgGL, so each palette entry is World(bone) x PoseMatrix(bone), flushed into the bound ARB vertex program’s local parameters. Melange’s GLSL replacement layer (shaders_glsl.cpp) already:
- mirrors every
glProgramLocalParameter*per ARB program (Store); - hooks
glDrawElements,glDrawRangeElementsandglDrawArrays; - resolves any Cg parameter to its register (
GetParameterResourceIndex).
Sunstone’s replaced fragment stage links with the Cg-compiled FFVertexMainTexLitDirectionalSkinned and draws skinned worms correctly, which shows that BlendMat reaches that path through the mirrored local registers [I]. A one-frame gltrace capture with cgGetNamedParameter(prog, "BlendMat") logged would confirm the register base (expected local 8) [U].
Route A: patch the palette at the draw [P], recommended
Section titled “Route A: patch the palette at the draw [P], recommended”This is a new client module, “MiragePose”, next to shaders_glsl.cpp. It shares the mirror and the draw hooks, and installs them even when no GLSL replacement file exists.
-
Find the skinned programs. When a Cg program is first bound, check whether its entry matches
FFVertex*Skinned. If so, resolveBlendMat[i]→ ARB local index (cgGetArrayParameterplusGetParameterResourceIndex) and keep{arbId, base, count=34}. Also keep themodelregister of non-skinned programs, which tints already resolves asmodelIndex, for the attachments. -
Work out which worm a draw belongs to. Before each skinned draw, while any override is live:
- read the 34 matrices from the mirror;
- compute
pivot0 = BlendMat[0] x bindPivot(main), wherebindPivot(i) = inverse(PoseMatrix_i) x origin, a 34-entry table generated fromBundl474.xomand self-tested; - pick the nearest live worm by container position plus a fixed centre offset, read on the main thread from the same frame’s game state, within 14 units.
The body, eye, teeth and hand shapes of one worm all carry the same palette, so they classify alike. The worms in a mount are at least the melee reach apart in the sim, because the mount is only visual, so the unpatched palette never confuses them.
-
Build the patched palette. Each bone gets a world delta
D_i, givingP'_i = D_i x P_i. A child inherits its parent’s delta first, soD_i = D_parent x L_i, whereL_iis the bone’s own local edit about its world pivotP_i x bindPivot(i). The edits:- Whole-worm transform:
D_root, for example “prone on back” is a 90-degree rotation about the feet, and “mount” is a translation plus pitch over the victim. - Bend: rotate
headortail*about their pivots. - Hands: rigid wrist targets.
D = T(target) x R x T(-currentWristPivot)is applied to the whole hand subtree (16..24 left, 25..33 right). This is the “hands follow the spade” IK: the client spade mesh gives the two grip points every frame. - Hide head as a stump:
D_head = T(neck) x S(sx, 0, sz) x T(-neck)in the bone’s frame, applied to the head subtree. Vertices weighted fully to the head flatten into a disk at the neck plane, and the blend band at y = -6..+2 tapers into it. The result is a flat-topped stump, not a spike, because nothing collapses to a distant point.
- Whole-worm transform:
-
Draw.
- On the plain ARB path: upload
P'with the driver’s ownglProgramLocalParameters4fvEXT(n_ls4fv) for the 136 registers, call the real draw, then re-upload the original 136 so cgGL’s shadow state stays true. - On the GLSL-replacement path (Sunstone and similar): patch the mirror vector, bump
version, runUpload(), draw, then restore and bump again.
- On the plain ARB path: upload
-
Severed head (ghost draw). For a live “copy” request, call the same draw a second time with palette
G:- head subtree:
G_i = H x P_i, whereHis the client’s rolling-head transform relative to the original neck; - every other bone:
T(neckGhost) x S(0), so the body collapses into the neck point and the blend band forms a second stump on the head side.
This draws the worm’s real head (texture, eyes, Sunstone skin and team colours) with no client head mesh. The cost is one extra draw per skinned shape of one worm.
- head subtree:
-
Expiry. Like
cameraOverride, a pose lastsframesframes (default 3, range 1..600) unless it is re-set, so a crashed script cannot leave a worm bent.
Cost: about 8 skinned draws per worm, 136 registers each, only for posed worms. That is negligible. This route is render-only: it changes no sim state and no Wormsign input, so it cannot desync.
Attachments
Section titled “Attachments”Rigid meshes on locators (the held weapon on WeaponLocator, the hat on HatLocator, the moustache on TashLocator, glasses) are separate non-skinned draws placed by their model matrix. They do not follow a patched palette. There are three options, in order:
- Held spade: give the Grave Spade an invisible held mesh (a tiny or empty
kindjal.GraveSpadeHiddenbank throughWeaponGraphicsResourceID). The client draws the animated spade itself withwum.draw.mesh, and the hand IK grips it. - Hat and accessories on a decapitated or bent worm: in the same draw hook, for a non-skinned draw whose
modeltranslation equals (within 0.5 units) the original world position of an overridden worm’sHatLocator/TashLocator/WeaponLocatorthis frame, apply that bone’sD(or the zero-scale stump delta) to themodelregister for the draw. [P] - The engine’s accessory mask:
WXWormGraphicEntitykeepsm_nHatMaskand callsActiveWorm_UnmaskAccessories(0x5a43d0,0x5a17d0). [U], a backup way to hide the hat.
Risks for Route A
Section titled “Risks for Route A”- Shadow pass [U]. If the engine draws worms into its shadow map with a skinned program, the patch applies there too, because it works per draw. If the shadow map uses another path, a prone worm would cast a standing shadow. Check with
[MirageShadows]on. - Culling. The engine culls the worm by its real instance bounds. A pose offset of about 20 units over the victim is well inside the bounds, so this is not a problem in practice.
- Identification. It fails only if two worms’
mainpivots are within a few units, and two sim worms cannot overlap that closely. Use frame-to-frame continuity as the tie-break. - Unexpected programs. If
BlendMatturns out not to be in program locals (an env binding), Melange must also hookglProgramEnvParameter*. Unlikely given Sunstone.
Route B: CPU joint override [U], not pursued
Section titled “Route B: CPU joint override [U], not pursued”XMeshInstance (vtable 0x888074) advances its XAnimScheduler in Update (0x6a02b0, slot 11):
- the time is at
+0xcc; - the scheduler is at
+0xc8, slots+0x20/+0x1c/+0x24; - the clip library is at
+0xc0.
Overriding the joint transforms after the scheduler runs would also move the hats and the held weapon, because those are children of joints. The research gap is where the per-instance joint output lives, and whether the skeleton graph is shared between instances. Route A covers the spade without it.
Route C: fallback retimed vanilla clips
Section titled “Route C: fallback retimed vanilla clips”The client plays a clip on a worm’s mesh instance:
XMeshInstance::PlayClip(name, &handle, speed, ...)is0x6a0730. It finds the clip throughFindClip0x6a0350, then calls the scheduler’s+0x14with a duration scale of1/speed.GetClipLength(name)is0x6a0990.0x5ce7e0playsNailedwith speed 1.0.
The worm’s instance should be WXWormGraphicEntity+0x30 (it gets the HatLocator attachment in 0x5a49a0) [I]. The slot-to-graphic-entity path is [U].
Desync risk. Clips can carry anim events (XExpandedAnimInfo). If an event posts a logic message, playing a clip on one machine only would desync. So only play clips during the hold, only clips without events, or play them from the sim.
Useful clips (329 in XCULLEDboggyb):
| Use | Clips |
|---|---|
| Dig | WindupBat, Fire1Bat, Fire2Bat, FireNMN, HoldNMN, FireProd, Poke, LobThrown, InspectHands |
| Victim knocked down | Hit_Back, Hit_Front, Blastflight2..5, Fall, Squish, Nailed, NailedHitBack, and the first frame of RecoverBack1 (lying on the back) |
| Victim | Cower, Terror, Pray, Cover_Head, ClutchChest, Wounded, Scared |
| Attacker | Fire1Bat, Fire2Bat (overhead chop), FireProd, Shake_Fist, EvilGrin, PointAndLaugh, Victorious_Grin, TauntBat |
The API (proposed here, built in Melange 0.16.0) [P]
Section titled “The API (proposed here, built in Melange 0.16.0) [P]”Sim (Lua 5.0, deterministic, hashed)
Section titled “Sim (Lua 5.0, deterministic, hashed)”-- Kills through the engine death path (Worm.KillNow). Options (all optional):-- explode (default true) false: no death explosion, no WXP FX, no Explosion message-- grave (default true) false: no gravestone-- throes (ticks, 1..150, default 150 = 3 s) length of the DeathThroes state before unspawn-- Returns true, or nil and "no worm" | "dead" | "drowning" | "not in a match".ok, why = wum.sim.worm(slot):kill({explode = false, grave = true, throes = 25})The C++ side:
-
simworms::BackendgainsKill(slot, opts), which postsWorm.KillNow(IntMessage0x691951, Post0x6910e4). -
WormAnchorgains three inline hooks, each enabled only while a kill record exists:0x5adbf0(post: entity+0x128 = throes*20);0x5a9400(skip if!explode);0x5a9310(skip if!grave).
Each hook gets its prologue checked with
mem::Expect, and the records are cleared atWXWormManager.UnspawnWormand at VM close. -
A Wormsign contributor
melange.wormkillhashes the records. -
The sim event
sim.wormKilled(slot,tick) fires when the unspawn happens.
worm:damage(n[, type]) (AddDamage 0x5ab7e0 on the logic entity, uncapped type 6) is a cheap addition for other mods. The spade does not need it.
Client (Lua 5.4, render-only)
Section titled “Client (Lua 5.4, render-only)”-- Pose one worm for `frames` frames (re-set every frame, like cameraOverride). One mod per slot ("busy").ok, why = wum.render.wormPose(slot, { frames = 3, root = {pos = {x,y,z}, yaw = deg, pitch = deg, roll = deg}, -- whole-worm transform about the feet (world) bones = { head = {rot = {x,y,z}}, tail = {rot = {...}}, main = {move = {...}} }, -- local edits, children inherit hands = { left = {pos = {x,y,z}, dir = {x,y,z}}, right = {...} }, -- rigid wrist targets (IK grip) hide = { head = "stump" }, -- "stump" (flat neck) or "point" attach = true, -- hats / accessories follow their bones})wum.render.wormPose(slot, nil) -- release
-- Draw a second copy of the worm's head subtree (real texture) at `head` (a 16-number matrix or {pos,yaw,pitch,roll}).ok, why = wum.render.wormCopy(slot, {bones = "head", model = m, frames = 3})
-- Last frame's rendered (posed) bone frames, for gore and for attaching client meshes: name -> {x,y,z, 9 axis floats}.bones = wum.render.wormBones(slot)These can never desync: they read only render state and change only draws. The C++ plan for them:
src/render/mirage/pose.cpp, with its logic inpose_logic.h(pure maths, unit-tested: the palette composition, stump scale and identification);- the 34-bone bind-pivot and parent table generated from
Bundl474.xom(the self-test compares it with the bundle when--gameis available); - a pre-draw and post-draw filter added to
shaders_glsl.cpp’sHkDrawElements/HkDrawRange/HkDrawArrays; - the Lua bindings in
wum_render.cpp.
Skinned programs are found by entry name. If BlendMat cannot be resolved, the feature reports “unsupported” and the mod falls back to Route C or client meshes.
Verification plan (in game, before building on it)
Section titled “Verification plan (in game, before building on it)”- K1 probe. In a guarded match, run
lua.evalagainst the sim:wum.sim.sendInt("Worm.KillNow", <enemy slot>). Expect the worm to die with the death anim, explosion, grave and unspawn, and theMelange.logworm lines to agree. Then repeat during aholdTurn, and on the last worm of a team. - Palette probe.
- Log
BlendMatresolution for each*Skinnedprogram (base register). - Take one
gltraceframe and confirm the 136ProgramLocalParameterfloats per worm draw. - Write a debug
pose.test <slot> pronethat rotates the root by 90 degrees andpose.test <slot> stumpfor the head stump. Screenshot both with Sunstone on and off.
- Log
- Shadow probe. Check that a prone worm’s shadow matches the pose with
[MirageShadows]on. - LocalNet. Run a spade execution on both A and B with a full Wormsign hash run (
melange-ingame-test-harnessrunbook §8): no desync, equal hold, equal unspawn tick.
Addresses (build #1077)
Section titled “Addresses (build #1077)”| What | Address |
|---|---|
WXWormLogicEntity::HandleMessage, second level |
0x5b07c0, 0x5adcf0 |
Worm subscription list (Worm.KillNow at 0x5a5c3c) |
0x5a5ae0 |
AddDamage(amount, type) thiscall |
0x5ab7e0 |
| ApplyDamage handler / “Waiting To Die” | 0x5abc50 / 0x5a70e0 |
| TimeToDie / “Worm Dying” | 0x5adbf0 / 0x5a7190 |
| Throes tick / drown tick / water check | 0x5aa080 / 0x5aa130 / 0x5ad640 |
| Death explosion / gravestone | 0x5a9400 / 0x5a9310 |
| Vapourize handler / sender | 0x5ac160 / 0x5885f0 |
WXWormManagerService::HandleMessage |
0x5b5e70 |
| Queue anim id / set current | 0x5ac4d0 / 0x5acb80 (entity +0x17c, +0x188, +0x244) |
Damage.Impulse ctor / melee hit (MeleeWeaponLogicEntity) |
0x518c20 / 0x567a40 |
IntMessage ctor / Post / engine SendIntMessage |
0x691951 / 0x6910e4 / 0x69676a |
| Message objects: KillNow / Vapourize / TimeToDie / DieQuietly | 0x95fcd8 / 0x95fcb0 / 0x95fcc8 / 0x95ff40 |
XMeshInstance vtable / Update / FindClip / PlayClip / ClipLength |
0x888074 / 0x6a02b0 / 0x6a0350 / 0x6a0730 / 0x6a0990 |
WXWormGraphicEntity init (clip names) |
0x5a49a0 |
Cg CGParam vtable (slot 9 cgGLSetMatrixParameterfr 0x796ab0) |
0x8b3c30 |
Damage.Impulse layout (0x518c20): +8 damage, +0xc impulse direction, +0x18 position, +0x24 impulse magnitude, +0x28 target slot (u8), +0x29 (u8), +0x2c type (5 has a 200 ms cooldown).
The melee hit at 0x567a40 builds it for the struck worm. That is the hook point for a melee “hit” event with a veto, which the weapons recon owns.