Skip to content

fix: NPCs change their look when they change armor at runtime (G2: Greg wears the farmer clothes) - #541

Merged
JaXt0r merged 1 commit into
developfrom
fix/npc-armor-visual-runtime
Nov 22, 2026
Merged

JaXt0r merged 1 commit into
developfrom
fix/npc-armor-visual-runtime

Conversation

@BoroBongo

Copy link
Copy Markdown
Contributor

What

An NPC that changes its armor while the game runs now also changes its look. In G2, Greg puts on the farmer clothes you give him outside Khorinis, and his captain hat goes away with his old outfit.

  • NpcService listens to NpcVisualBodyChanged (armor equipped or unequipped, Mdl_SetVisualBody). For an NPC whose mesh is already built, NpcInitializerDomain.RebuildBody swaps the body on its existing skeleton (MeshService.RebuildNpcBody → NpcMeshBuilder.RebuildBody).
    • Head, weapons, helmet, colliders and animation stay.
    • Fatness and ghost looks are applied again.
    • Log line: [ArmorVisual] <npc>: body rebuilt as '<mdm>'.
  • The skeleton is put into its rest pose for the rebuild and back afterwards. Bind poses are written into the cached mesh shared by everyone wearing that armor, so building from an animated pose would break that armor for every NPC wearing it.
  • Armor attachments (hats) sit in their own child of the bone, so an armor change removes the old ones.
  • Colour-only (texture-less) parts of NPC bodies are drawn in their colour, like in the engine. Before, they were skipped, which also shifted every following material by one sub mesh.
  • NPCs not built yet (lazy loading) and the hero are skipped. The VR hero body still rebuilds itself.

Why

Playtest 2026-11-22 (G2 Night of the Raven, PCVR build from develop): after DIA_Addon_Greg_NW_Stadtwachen_klamotten the log said Greg now wears 'Armor_Bau_L.asc', but Greg still looked like the captain. Develop only updated the data (EquipDomain.UpdateArmorVisual: "An NPC's built mesh is swapped with a later PR"). Follow-up of #539. The code existed on the experimental branch (b441350, 2c13522) but never reached main/develop. No issue exists for it.

How to test manually

  • G2: give Greg your farmer clothes outside Khorinis (Stadtwachen_klamotten). He visibly wears the farmer clothes right away, his captain hat is gone, and his animations (walking to the market) look normal. The log has [ArmorVisual] Greg: body rebuilt as 'Armor_Bau_L.asc'.
  • G2: look at other NPCs wearing farmer clothes after Greg changed. Their clothes aren't mangled, because the shared mesh was built in the rest pose.
  • G1: an NPC that puts on armor from a script (e.g. after a guild change in a dialog). The look changes and the animation stays fine.
  • G1/G2: NPCs with colour-only armor parts (e.g. Greg's hat before the change) show them, and no material is shifted (faces/armor textures look right).
  • Walk away until Greg is culled, come back. He still wears the farmer clothes.

Save/load

Nothing new is stored. Equipped items are saved; after a load, MdmName is derived from them and the NPC is built with the new armor anyway.

Known gaps / follow-ups

  • Compiled in the Editor together with the other fixes of this playtest round (EditMode tests 87/87), not play tested yet.
  • Mdl_SetVisualBody on an already built NPC rebuilds the body twice (two events). It only happens on change.
  • The hitbox padding (NpcBodyBounds) isn't recalibrated after a rebuild.
  • Other users of MeshService.CreateNpc (VR hero body, Lab) now also draw colour-only parts and keep attachments in _Attachment children.

AI usage

Claude ported the experimental commits onto develop's mesh builders and wrote this description. The user found the bug in a playtest.

…eg wears the farmer clothes you give him

- An already built NPC whose visual body changes (NpcVisualBodyChanged: armor (un)equipped, Mdl_SetVisualBody)
  gets its body's skinned meshes swapped on its existing skeleton (NpcMeshBuilder.RebuildBody via
  MeshService.RebuildNpcBody, listener in NpcService). The skeleton is put into its rest pose for the rebuild, as
  bind poses are written into the cached, shared mesh. Fatness/ghost looks are applied again. The hero is skipped.
- Armor attachments go into an own child of their bone, so the old armor's ones (Greg's captain hat) are removed.
- Color-only (untextured) sub meshes of NPC bodies are drawn in their color instead of being skipped, which also
  shifted every following material by one sub mesh.
Ported from the experimental branch (b441350, 2c13522) onto develop's builders.
@JaXt0r
JaXt0r merged commit 8fccef7 into develop Nov 22, 2026
1 check passed
@JaXt0r
JaXt0r deleted the fix/npc-armor-visual-runtime branch November 22, 2026 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants