From 501ef4927687ff264c9c9c4f73ddf715e45385e2 Mon Sep 17 00:00:00 2001 From: BoroBongo Date: Sun, 22 Nov 2026 02:07:48 +0000 Subject: [PATCH] fix: " - received / given" messages name the item again (G2 B_GiveInvItems) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Like the engine, CreateInvItem(s) makes the created item the scripts' global 'item'. G2's B_GiveInvItems reads item.name right after CreateInvItems; without it the print was " - otrzymałeś" / "2 przedm. - otrzymałeś ()" and ZenKit logged 'Accessing member "C_ITEM.NAME" without an instance set' (Cavalorn, Dexter, Greg). --- .../Domain/Vm/VmNpcInventoryExternalDomain.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Assets/Gothic-Core/Scripts/Domain/Vm/VmNpcInventoryExternalDomain.cs b/Assets/Gothic-Core/Scripts/Domain/Vm/VmNpcInventoryExternalDomain.cs index 0b8f39dc9..c0038fd64 100644 --- a/Assets/Gothic-Core/Scripts/Domain/Vm/VmNpcInventoryExternalDomain.cs +++ b/Assets/Gothic-Core/Scripts/Domain/Vm/VmNpcInventoryExternalDomain.cs @@ -41,6 +41,7 @@ public class VmNpcInventoryExternalDomain [Inject] private readonly NpcInventoryService _npcInventoryService; [Inject] private readonly ProjectileService _projectileService; [Inject] private readonly GameStateService _gameStateService; + [Inject] private readonly VmCacheService _vmCacheService; private readonly VmExternalSupport _support; @@ -94,15 +95,29 @@ public int Npc_HasReadiedWeapon(NpcInstance npc) public void CreateInvItem(NpcInstance npc, int itemId) { _npcInventoryService.ExtCreateInvItems(npc, itemId, 1); + SetScriptItem(itemId); _support.LogInstantExternal(nameof(CreateInvItem), npc, itemId); } public void CreateInvItems(NpcInstance npc, int itemId, int amount) { _npcInventoryService.ExtCreateInvItems(npc, itemId, amount); + SetScriptItem(itemId); _support.LogInstantExternal(nameof(CreateInvItem), npc, itemId, amount); } + /// + /// Like the engine, the created item becomes the scripts' 'item': G2's B_GiveInvItems prints item.name right + /// after CreateInvItems ("Torch - received"). Without it the name was empty and ZenKit logged + /// 'Accessing member "C_ITEM.NAME" without an instance set'. + /// + private void SetScriptItem(int itemId) + { + var item = _vmCacheService.TryGetItemData(itemId); + if (item != null) + _gameStateService.GothicVm.GlobalItem = item; + } + public void Npc_RemoveInvItem(NpcInstance npc, int itemId) { _npcInventoryService.ExtRemoveInvItems(npc, itemId, 1);