Jump to content

UnequipItem(Self)


Recommended Posts

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:







  1. Scriptname RestrictionFunctions:HeavyRangedWeaponry extends ObjectReference Const


  2. Message Property CantEquipWearPA Auto Const


  3. Perk Property HeavyGunner1 Auto Const


  4. Perk Property StrongBack1 Auto Const


  5. Keyword Property isPowerArmorFrame Auto Const


  6. Keyword Property HeavyRangedWeapon Auto Const


  7. ActorValue Property Strength Auto Const


  8. Event OnEquipped(Actor AkActor)


  9. If (Self.HasKeyword(HeavyRangedWeapon) == True && akActor.IsInPowerArmor() == false)


  10. If (akActor.HasPerk(StrongBack1) == false || akActor.HasPerk(HeavyGunner1) == false || akActor.GetBaseValue(Strength) < 8)

  11. akActor.UnequipItem(Self, True, True)


  12. CantEquipWearPA.Show()


  13. endIf
  14. endIf


  15. endEvent



  16. Event Actor.OnItemUnequipped(Actor akSender, Form akBaseObject, ObjectReference akReference)


  17. If akBaseObject.HasKeyword(isPowerArmorFrame) == True ; Check if the player did unequip Power Armor

  18. If akSender.GetEquippedWeapon().HasKeyword(HeavyRangedWeapon)


  19. If (akSender.HasPerk(StrongBack1) == false || akSender.HasPerk(HeavyGunner1) == false || akSender.GetBaseValue(Strength) < 8)

  20. akSender.UnequipItem(akSender.GetEquippedWeapon(), True, True)


  21. CantEquipWearPA.Show()


  22. endIf
  23. endIf


  24. endIf


  25. 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

 

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

 

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 by Reneer
Link to comment
Share on other sites

 

 

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...