Difference between revisions of "Talk:UnequipItem - Actor"
imported>Bluedanieru |
imported>Chesko (Enchantment charge bug work-around details.) |
||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
== | == Weapon Enchantment Charge Bug == | ||
I am able to consistently wipe out the charge on weapons in the player's inventory with this command. You need a two-handed enchanted weapon and a one-handed enchanted weapon or staff. Equip the one-handed weapon first, then the two handed weapon. They should be set up such that you can switch between them in inventory by clicking on the two-hander. If you then call UnequipItem(TwoHandedWeaponRef) on the player, they will unequip the weapon and switch to the one-handed one, only it will have no charge. A subsequent call to EquipItem(TwoHandedWeaponRef) will reequip the two-handed weapon, but surprisingly it will have the charge points that the one-handed weapon had! | I am able to consistently wipe out the charge on weapons in the player's inventory with this command. You need a two-handed enchanted weapon and a one-handed enchanted weapon or staff. Equip the one-handed weapon first, then the two handed weapon. They should be set up such that you can switch between them in inventory by clicking on the two-hander. If you then call UnequipItem(TwoHandedWeaponRef) on the player, they will unequip the weapon and switch to the one-handed one, only it will have no charge. A subsequent call to EquipItem(TwoHandedWeaponRef) will reequip the two-handed weapon, but surprisingly it will have the charge points that the one-handed weapon had! --[[User:Bluedanieru|Bluedanieru]] 11:52, 16 February 2012 (EST) | ||
'''Work-around''' | |||
I have found a work around for this issue (tested in 1.9.32.0.8). When you want to unequip a two-handed weapon, equip a "dummy" one-handed weapon instead. This will unequip the two-handed weapon safely and the charges of your two-handed and one-handed weapons in your inventory will be safe. | |||
Here is some sample code to help illustrate this fix. | |||
<source lang="papyrus"> | |||
Weapon property myDummyWeapon auto | |||
... | |||
;I want to unequip the player's weapon. Check if they have a two-handed weapon or bow equipped first. | |||
int iWeaponType = myActor.GetEquippedItemType(1) | |||
if iWeaponType == 5 || iWeaponType == 6 || iWeaponType == 7 | |||
;Player has a two-handed weapon or a bow equipped! | |||
UnequipUsingDummyWeapon(myActor, myDummyWeapon) | |||
else | |||
myActor.UnequipItem(myActor.GetEquippedWeapon()) | |||
endif | |||
... | |||
function UnequipUsingDummyWeapon(Actor akActor, Weapon akDummyWeapon) | |||
akActor.AddItem(akDummyWeapon, abSilent = true) | |||
akActor.EquipItem(akDummyWeapon, abSilent = true) | |||
akActor.UnEquipItem(akDummyWeapon, abSilent = true) | |||
akActor.RemoveItem(akDummyWeapon, abSilent = true) | |||
endFunction | |||
</source> | |||
I personally made a duplicate of the Iron Dagger and then zeroed out the weight and value, and erased the name and the art / mesh properties and it seemed to work fine. This way, when you make the switch, the player never actually sees the dummy weapon. [[User:Chesko|Chesko]] ([[User talk:Chesko|talk]]) 2013-03-31T16:25:31 (EDT) |
Latest revision as of 15:25, 31 March 2013
Weapon Enchantment Charge Bug[edit source]
I am able to consistently wipe out the charge on weapons in the player's inventory with this command. You need a two-handed enchanted weapon and a one-handed enchanted weapon or staff. Equip the one-handed weapon first, then the two handed weapon. They should be set up such that you can switch between them in inventory by clicking on the two-hander. If you then call UnequipItem(TwoHandedWeaponRef) on the player, they will unequip the weapon and switch to the one-handed one, only it will have no charge. A subsequent call to EquipItem(TwoHandedWeaponRef) will reequip the two-handed weapon, but surprisingly it will have the charge points that the one-handed weapon had! --Bluedanieru 11:52, 16 February 2012 (EST)
Work-around
I have found a work around for this issue (tested in 1.9.32.0.8). When you want to unequip a two-handed weapon, equip a "dummy" one-handed weapon instead. This will unequip the two-handed weapon safely and the charges of your two-handed and one-handed weapons in your inventory will be safe.
Here is some sample code to help illustrate this fix.
Weapon property myDummyWeapon auto
...
;I want to unequip the player's weapon. Check if they have a two-handed weapon or bow equipped first.
int iWeaponType = myActor.GetEquippedItemType(1)
if iWeaponType == 5 || iWeaponType == 6 || iWeaponType == 7
;Player has a two-handed weapon or a bow equipped!
UnequipUsingDummyWeapon(myActor, myDummyWeapon)
else
myActor.UnequipItem(myActor.GetEquippedWeapon())
endif
...
function UnequipUsingDummyWeapon(Actor akActor, Weapon akDummyWeapon)
akActor.AddItem(akDummyWeapon, abSilent = true)
akActor.EquipItem(akDummyWeapon, abSilent = true)
akActor.UnEquipItem(akDummyWeapon, abSilent = true)
akActor.RemoveItem(akDummyWeapon, abSilent = true)
endFunction
I personally made a duplicate of the Iron Dagger and then zeroed out the weight and value, and erased the name and the art / mesh properties and it seemed to work fine. This way, when you make the switch, the player never actually sees the dummy weapon. Chesko (talk) 2013-03-31T16:25:31 (EDT)