Skip to content

fix: a script that takes the last piece of a worn item takes it off (G2: Greg's farmer clothes) - #539

Merged
JaXt0r merged 1 commit into
developfrom
fix/removed-item-unequips
Nov 22, 2026
Merged

JaXt0r merged 1 commit into
developfrom
fix/removed-item-unequips

Conversation

@BoroBongo

Copy link
Copy Markdown
Contributor

What

When a script takes the last piece of an item you're wearing, you take it off first, like in the original engine.
In G2, when you give Greg your farmer clothes, the armor leaves your inventory and your VR body goes back to the naked
body. You also lose the armor's protection.

  • Npc_RemoveInvItem and Npc_RemoveInvItems call the new NpcInventoryService.UnequipIfLastOneRemoved
    (engine: oCNpc::RemoveFromInv; OpenGothic: Inventory::delItem).
  • It reuses the existing unequip code:
    • armor, helmets, amulets, rings and belts go through EquipDomain.UnequipItemWithEffects: protection is removed,
      on_unequip runs next frame like other script equips, and the armor visual returns to the naked body;
    • weapons go through EquipDomain.RemoveEquippedWeapon.
  • Only script removals do this. A VR weapon in a hand or holster is out of the backpack but still equipped, so the
    backpack paths are unchanged.
  • Log line: [Equip] <npc>: a script took the last '<item>' - taking it off like the engine. (category NPC)

Why

Found in a playtest on 2026-11-22 (G2 Night of the Raven, PCVR build from develop). In Greg's dialog
DIA_Addon_Greg_NW_Stadtwachen_klamotten outside Khorinis, the farmer clothes left the inventory, but the hero still
wore them. No issue exists for this.

How to test manually

  • G2: wear farmer clothes and talk to Greg outside Khorinis. Choose to give him your clothes. The armor is gone
    from the inventory, the VR hero body shows the naked body, and the log has
    [Equip] ... a script took the last 'Strój farmera ...'.
  • G2: after that, check the status menu. The armor's protection values are gone.
  • G2: hold a weapon in your hand or holster and take items out of the backpack. Nothing gets unequipped.
  • Save and load after giving the clothes away. The hero still isn't wearing them.

Save/load

Equipped items are saved, and the given-away armor is no longer among them, so after a load the hero isn't wearing
it. Nothing new is stored.

Known gaps / follow-ups

  • Greg's own look doesn't change at once. The data is correct (log: Greg now wears 'Armor_Bau_L.asc'), but develop
    doesn't rebuild an NPC's built mesh when it changes armor at runtime (EquipDomain.UpdateArmorVisual, comment
    "swapped with a later PR"). Fixing that is a port of the experimental b44135034 and 2c1352259
    (MeshService.RebuildNpcBody).
  • Not checked: whether trades through InventoryTransferService unequip a worn item that gets traded away.
  • Compiled in the Editor together with the other fixes from the same playtest (EditMode tests 87/87), not play
    tested yet.

AI usage

Claude traced the bug from the playtest log, wrote the fix and compared it with the engine and OpenGothic. The user
found the bug in a playtest.

… giving Greg your farmer clothes leaves you in your naked body

Like the engine (oCNpc::RemoveFromInv, OpenGothic Inventory::delItem), Npc_RemoveInvItem(s) unequips an equipped item
when its last piece leaves the inventory: protection and on_unequip (next frame, like script equips) go, the armor
visual (VR hero body) goes back to the naked body. Weapons leave the equipped list and the NPC's belt. Only script
removals: a VR weapon in a hand or holster is out of the backpack but still equipped.
@BoroBongo

Copy link
Copy Markdown
Contributor Author

Follow-up for Greg's own look (NPC body mesh rebuilt on a runtime armor change): #541

@JaXt0r
JaXt0r merged commit ca9be77 into develop Nov 22, 2026
1 check passed
@JaXt0r
JaXt0r deleted the fix/removed-item-unequips branch November 22, 2026 14:10
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