So as a workaround I've created a left hand and right hand unarmed weapon and now I'm trying to make a scripted magic effect for an ability that would equip said weapons whenever the player's hand is empty. But it doesn't work. Here is the full script:
Spoiler
Scriptname dsrUnarmedEquipScript extends activemagiceffect ObjectReference Property UnarmedRightRef Auto ; references to the right hand unarmed weaponObjectReference Property UnarmedLeftRef Auto ; references to the left hand unarmed weaponActor PlayerRef ;reference to the playerEvent OnEffectStart(Actor Target, Actor Caster) RegisterForSingleUpdate(1) ; Give us a single update in one secondendEventEvent OnUpdate() PlayerRef = Game.GetPlayer() ; this is the player ; if the player doesn't have any unarmed weapons, give him some if (PlayerRef.GetItemCount(UnarmedRightRef) == 0) PlayerRef.AddItem(UnarmedRightRef, 1, true) ; the item to add is the right hand weapon, give only one, don't display a message endif if (PlayerRef.GetItemCount(UnarmedLeftRef) == 0) PlayerRef.AddItem(UnarmedLeftRef, 1, true) endif ; now that we made sure the player has the unarmed weapons in their inventory, we check if the script should equip said weapons if (PlayerRef.GetEquippedItemType(1) == 0) ; if the player' right hand is unarmed if (PlayerRef.IsEquipped(UnarmedRightRef) == 0); and the player doesn't have the right hand weapon equiped PlayerRef.EquipItem(UnarmedRightRef) ; then the player has an actually empty right hand and we can equip the right hand unarmed weapon endif endIf if (PlayerRef.GetEquippedItemType(0) == 0) ; if the player' left hand is unarmed if (PlayerRef.IsEquipped(UnarmedLeftRef) == 0); and the player doesn't have the left hand weapon equiped PlayerRef.EquipItem(UnarmedLeftRef) ; then the player has an actually empty left hand and we can equip the left hand unarmed weapon endif endIf RegisterForSingleUpdate(1) ; Now that this has all been done we can do it again.endEvent
During testing I've found that the unarmed weapons are added to my inventory as they should be and if I store them in a container they get moved back into my inventory. So far so good, but the script fails to equip them so I must've messed up something in this part:
if (PlayerRef.GetEquippedItemType(1) == 0) ; if the player' right hand is unarmed if (PlayerRef.IsEquipped(UnarmedRightRef) == 0) ; and the player doesn't have the right hand weapon equiped PlayerRef.EquipItem(UnarmedRightRef) ; then the player has an actually empty right hand and we can equip the right hand unarmed weapon endif endIf
Any ideas what I'm doing wrong?
