From 819abb1a2741a04a66463df812c784d5ef71328d Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Sat, 29 Aug 2026 11:47:49 +0200 Subject: [PATCH] tester-fixes --- JotunnModStub/RaceClaws.cs | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/JotunnModStub/RaceClaws.cs b/JotunnModStub/RaceClaws.cs index 5d0846d..3e3c540 100644 --- a/JotunnModStub/RaceClaws.cs +++ b/JotunnModStub/RaceClaws.cs @@ -636,10 +636,35 @@ namespace RacesOfValheim // it is put back to full once rather than left as a stale figure in the save file. if (claws.m_durability < claws.GetMaxDurability()) claws.m_durability = claws.GetMaxDurability(); - // Empty-handed means clawed. Anything else in the right hand wins until it is put away, - // which is the whole compromise. - ItemDrop.ItemData held = Traverse.Create((Humanoid)player).Field("m_rightItem").Value; - if (held == null && !player.InAttack()) + // Empty-handed means clawed. Anything the player is actually holding wins until it is + // put away, which is the whole compromise. + // + // BOTH HANDS, and asking only about the right one is what broke the bow. A bow is held + // in m_leftItem, so a bow-wielding player read as empty-handed here and got the claws + // forced into his hands - and Humanoid.EquipItem's OneHandedWeapon branch (read off the + // IL) does this before it puts anything in the right hand: + // + // UnequipItem(m_rightItem); + // if (m_leftItem != null && m_leftItem.m_shared.m_itemType != Shield) + // UnequipItem(m_leftItem); + // + // Everything but a shield is torn out of the left hand. So the archer's bow was pulled + // out from under him, up to twice a second - and not only on the throttled tick, because + // RaceClaws_UnequipItem_Patch calls Maintain from inside UnequipItem and EquipItem calls + // UnequipItem first, so drawing a bow started the fight immediately. + // + // Free is therefore defined as "nothing the claws would displace", which is that rule + // mirrored rather than a second guess at it: a shield stays because equipping the claws + // over a shield costs the player nothing. + Humanoid humanoid = player; + ItemDrop.ItemData right = Traverse.Create(humanoid).Field("m_rightItem").Value; + ItemDrop.ItemData left = Traverse.Create(humanoid).Field("m_leftItem").Value; + + bool leftIsShield = left != null && left.m_shared != null && + left.m_shared.m_itemType == ItemDrop.ItemData.ItemType.Shield; + bool handsFree = right == null && (left == null || leftIsShield); + + if (handsFree && !player.InAttack()) { player.EquipItem(claws, false); }