paulatreides0 Posted August 1, 2016 Share Posted August 1, 2016 Hey, sorry to be back yet again, but I've stumbled across something that has me scratching my head big time again. I was trying to change some code to see if I could make it easier to work with and more efficient, so I decided to try using keyword pulls instead of iterating through form lists. My code is as follows: Scriptname RestrictionFunctions:HeavyRangedWeaponry extends ObjectReference Const Message Property CantEquipWearPA Auto Const Perk Property HeavyGunner1 Auto Const Perk Property StrongBack1 Auto Const Keyword Property isPowerArmorFrame Auto Const Keyword Property HeavyRangedWeapon Auto Const ActorValue Property Strength Auto Const Event OnEquipped(Actor AkActor) If (Self.HasKeyword(HeavyRangedWeapon) == True && akActor.IsInPowerArmor() == false) If (akActor.HasPerk(StrongBack1) == false || akActor.HasPerk(HeavyGunner1) == false || akActor.GetBaseValue(Strength) < 8) akActor.UnequipItem(Self, True, True) CantEquipWearPA.Show() endIf endIf endEvent Event Actor.OnItemUnequipped(Actor akSender, Form akBaseObject, ObjectReference akReference) If akBaseObject.HasKeyword(isPowerArmorFrame) == True ; Check if the player did unequip Power Armor If akSender.GetEquippedWeapon().HasKeyword(HeavyRangedWeapon) If (akSender.HasPerk(StrongBack1) == false || akSender.HasPerk(HeavyGunner1) == false || akSender.GetBaseValue(Strength) < 8) akSender.UnequipItem(akSender.GetEquippedWeapon(), True, True) CantEquipWearPA.Show() endIf endIf endIf EndEvent The problem is that it seems that akActor.UnequipItem(Self, True, True) isn't working. And it should, from what I can tell. The script is applied to a weapon so that on being equipped that specific instance of the weapon is what the script is being run on. It DOES properly check itself and say "Do I have this Keyword?" And I know it does that because the CantEquipPA.Show() event happens, but it does not unequip itself from the actor. Any idea what is going on? Link to comment Share on other sites More sharing options...
Reneer Posted August 1, 2016 Share Posted August 1, 2016 You may want to try this: akActor.UnequipItem(Self.GetBaseObject(), True, True) Link to comment Share on other sites More sharing options...
paulatreides0 Posted August 2, 2016 Author Share Posted August 2, 2016 You may want to try this: akActor.UnequipItem(Self.GetBaseObject(), True, True) Hmm, I'll try it. If you don't mind my asking though, I don't get why that's the case. Isn't self already an instance of the item in question? So if the item is, say, a Gatling Laser, it should know that I'm asking it to unequip not just a gatling laser, but that specific gatling laser in question, no? Link to comment Share on other sites More sharing options...
Reneer Posted August 2, 2016 Share Posted August 2, 2016 (edited) You may want to try this:akActor.UnequipItem(Self.GetBaseObject(), True, True) Hmm, I'll try it. If you don't mind my asking though, I don't get why that's the case. Isn't self already an instance of the item in question? So if the item is, say, a Gatling Laser, it should know that I'm asking it to unequip not just a gatling laser, but that specific gatling laser in question, no? Your script is running on an Objectreference, whereas the UnequipItem function is expecting a Form. Objectreference.GetBaseObject() returns a Form. Edited August 2, 2016 by Reneer Link to comment Share on other sites More sharing options...
paulatreides0 Posted August 2, 2016 Author Share Posted August 2, 2016 You may want to try this: akActor.UnequipItem(Self.GetBaseObject(), True, True) Hmm, I'll try it. If you don't mind my asking though, I don't get why that's the case. Isn't self already an instance of the item in question? So if the item is, say, a Gatling Laser, it should know that I'm asking it to unequip not just a gatling laser, but that specific gatling laser in question, no? Your script is running on an Objectreference, whereas the UnequipItem function is expecting a Form. Objectreference.GetBaseObject() returns a Form. Ahh, I see. Thank you! Link to comment Share on other sites More sharing options...
Recommended Posts