Skip to content

fix: smiths hold the hammer, the blade glows after the forge, drummers hold both sticks - model script items in the hand and the inventory - #577

Open
BoroBongo wants to merge 8 commits into
developfrom
fix/mds-create-item
Open

BoroBongo wants to merge 8 commits into
developfrom
fix/mds-create-item

Conversation

@BoroBongo

Copy link
Copy Markdown
Contributor

What

The animation item events DEF_CREATE_ITEM (ItemCreate) and DEF_EXCHANGE_ITEM (ItemExchange) now put their item into the hand.

  • T_BSANVIL_S0_2_S1 gives the smith his hammer.
  • T_BSFIRE_S0_2_S1 swaps the blade for the glowing ITMISWORDRAWHOT.
  • The pan, stove, cello and fire-eater animations get their items.
  • T_PAUKE gives a drumstick to each hand.

While held, the items are also in the NPC's inventory, like in the engine (OpenGothic: ITEM_CREATE/EXCHANGE add, ITEM_DESTROY removes, ITEM_REMOVE keeps). They can be bought or pickpocketed. The original's "infinite steel" trick at Harad is kept on purpose: an item sold or stolen from the hand is not taken from the NPC a second time. The items leave the hand (and the inventory) at the animation's ItemDestroy, or when the NPC is interrupted or culled.

The NPC now owns the item objects themselves (UsedItemGo, CreatedItemGos) instead of slot names, so a drawn weapon in the same hand is never deleted. Item lookup goes through VobService.CreateItemMesh(name) (warns on non-items), and slots are found through one FindSlot.

Why

In a playtest, Harad forged without a hammer: ItemCreate was "not yet supported".

How to test manually

  • G2 Harad at the anvil: the hammer is in his right hand and the hot blade in his left. Both go when he leaves.
  • G2 Harad at the forge fire: the blade glows.
  • Attack a smith at the anvil, or walk away and come back: no floating hammer, and his drawn weapon is visible.
  • NPCs eating, drinking and smoking still show and remove their items.
  • Trade with Harad while he holds the hot blade: it is in his goods. Buy it, and the next cycle offers another one.
  • Pickpocket a smith mid-anvil; kill one mid-anvil: the item is in his loot once.
  • Interrupt a smith several times: his hammer count doesn't grow.

Save/load

Nothing extra is saved. An item saved while held stays in the NPC's inventory (like the original); after a load the hand is empty and the next animation brings a new one.

Known gaps / follow-ups

🤖 Generated with Claude Code

BoroBongo and others added 8 commits November 25, 2026 21:13
…EF_CREATE_ITEM puts its item into the hand

T_BSANVIL_S0_2_S1 (HUMANS.MDS) inserts the hot blade (ItemInsert, the mob's item) into the left hand and creates the
hammer ITMW_1H_MACE_L_04 in the right one (ItemCreate). ItemCreate fell through to "not yet supported", so Harad
(G2) and the G1 smiths forged without a hammer. The created item's mesh goes into its slot and leaves together with
the used item (T_BSANVIL_S1_2_S0's ItemDestroy, or the item put away when the NPC is interrupted). The inventory
doesn't change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e put-away - only the item meshes we created go

NpcProperties remembered the used and the created item by slot name, and putting them away destroyed every child of
that slot. T_PAUKE_STAND_2_S0 creates a drumstick in each hand, so the second ItemCreate deleted the first one, and a
weapon drawn into ZS_RIGHTHAND would have gone together with the hammer. The NPC now keeps the item GameObjects
themselves (UsedItemGo, CreatedItemGos) and destroys exactly those. A slot holds one item like the engine's slots: a
new ItemCreate replaces only the used/created mesh in the same slot. InsertItem still replaces the used item,
ItemDestroy/ItemRemove and RemoveUsedItemFromHand still remove the used and the created items.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… with a warning instead of an error

CreateItem looked the DEF_CREATE_ITEM item up as a raw VM symbol, so a symbol that isn't an item instance reached
TryGetItemData and the mesh builder with null (NullReferenceException), and an item whose mesh wasn't built was
remembered anyway. It now goes through VobService.CreateItemMesh(string), which resolves the item via VmCacheService,
warns for a non-item and returns the built GameObject (both overloads guard a null item). Only a built mesh is
remembered. The slot lookup is one FindSlot helper; InsertItem warns about a missing slot instead of putting the
mesh at the scene root.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…fried meat - the model script's DEF_EXCHANGE_ITEM swaps the item in the hand

ItemExchange fell through to "not yet supported": T_BSFIRE_S0_2_S1 (ZS_LEFTHAND ITMISWORDRAWHOT) left the cold blade in
the smith's hand, T_PAN_S1_2_S0 and T_STOVE_S0_2_STAND (ZS_LEFTHAND ITFOMUTTON) never showed the fried meat. Like
OpenGothic's tickTimedEvt, the item meshes in that slot go; if the slot is empty (its cooking fallback) the used item
goes instead. Then the new item's mesh goes into the slot and is remembered as created, so ItemDestroy or putting the
item away removes it. CreateItem and ExchangeItem share PutItemIntoSlot. The inventory doesn't change (OpenGothic adds
the item to it).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…y too, like the engine - Harad's hot blade can be bought or stolen

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ted state - logged as info, not warning

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@BoroBongo

Copy link
Copy Markdown
Contributor Author

Review (architecture-reviewer + gothic-reviewer), three rounds

Round 1 (17d8e26). Both reviewers: OK / fits, with concerns. Fixed:

  • Ownership. The NPC owns the item objects, not slot names. A drawn weapon in the same hand survives, and both drumsticks stay.
  • Only real meshes. An item is remembered only when its mesh was built. Items are looked up through VobService.CreateItemMesh(name), and slots through one FindSlot.
  • ItemExchange. Supported: the forge's glowing blade, the pan, the stove.

Round 2 (6afffb0). Both reviewers: OK to merge. Fixed:

  • Exchange to nothing. Just clears the slot.

Round 3 (abee13f). Both reviewers: fits. The author decided to put the items into the inventory like the engine. Fixed:

  • ADR. Docs/adr/2026-11-25-model-script-items-in-inventory.md: the "infinite steel" trick is kept on purpose.
  • Log level. "Sold or stolen from the hand" is logged as info, not as a warning.

Follow-up: #568 (NpcHeldItemDomain / NpcHeldItems).

Editor check (G2 Khorinis):

  • Harad at the anvil holds ItMiSwordrawhot (left hand) and the sledgehammer (right hand).
  • The author confirmed the hammer in play.
  • No exceptions.
  • The inventory part is not yet tested in play.

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.

1 participant