From e042579e17b95be5eba5ee0f53a6c444a73c9f3b Mon Sep 17 00:00:00 2001 From: kanym Date: Tue, 25 Aug 2026 22:48:30 +0200 Subject: [PATCH] Fix Bone Servant crash when dropping a payload it can't place DropPayload() cloned template.m_itemData straight off the ObjectDB prefab and handed the clone to ItemDrop.DropItem, which instantiates item.m_dropPrefab - a field a clone off a raw prefab never carries (same pitfall already fixed in AswidBloodPotions.MakeFood). The result was an unhandled ArgumentException instantiating null. This fires whenever a servant is holding something with nowhere sealed to put it - e.g. chests without the sigil item yet, as in the bug report - and since the exception aborts before m_payload.Clear() runs, the same broken load is retried, and crashes, on every AI tick after: relogging or killing the servant doesn't clear it, because the payload lives in the ZDO, not the character. Fix: set clone.m_dropPrefab = prefab before dropping, same as the existing fix. --- JotunnModStub/Butler/BoneServantAI.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/JotunnModStub/Butler/BoneServantAI.cs b/JotunnModStub/Butler/BoneServantAI.cs index c6eee21..922cb36 100644 --- a/JotunnModStub/Butler/BoneServantAI.cs +++ b/JotunnModStub/Butler/BoneServantAI.cs @@ -921,7 +921,15 @@ namespace RacesOfValheim while (left > 0) { int stack = Mathf.Min(left, max); - ItemDrop.DropItem(template.m_itemData.Clone(), stack, + + // ItemDrop.DropItem instantiates item.m_dropPrefab - a clone off a raw ObjectDB + // prefab does not carry that (see AswidBloodPotions.MakeFood for the same fix). + // Without this, dropping a payload throws instantiating null and never clears + // it, so the same broken load is retried - and crashes - on every AI tick after. + ItemDrop.ItemData clone = template.m_itemData.Clone(); + clone.m_dropPrefab = prefab; + + ItemDrop.DropItem(clone, stack, at + Random.insideUnitSphere * 0.3f, Quaternion.identity); left -= stack; }