Jump to content

auto equip armor-script help


FullmetalRyuken

Recommended Posts

Hello all,

 

I'm looking for some help as far as putting a script together. My goal is when a player equips a particular necklace it will run a script that will automatically equip an armor set in the player inventory. I have skimmed through the forums and other sites and haven't found much of anything. Any help or a point in the right direction would be much appreciated!!!

Link to comment
Share on other sites

Thanks for the help! I am new to this whole script thing, but this is what i came up with...

 

Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference)

Game.GetPlayer().EquipItem(ebonymail)

endEvent

 

i attached the script to the necklace i wanted to use in ck, then compiled and came back with zero errors. Tried in game but nothing happens. Is there something i missed?

Link to comment
Share on other sites

Since you're attaching the script to the necklace, you'll want OnEquipped, not OnObjectEquipped. Here's what I would recommend:

 

Actor Property Player Auto
Armor Property EbonyMail Auto

Event OnEquipped(akactor)
if (akactor == Player)
Player.additem(EbonyMail, 1)
Player.EquipItem(EbonyMail)
Endif
EndEvent

Event OnUnequipped(akactor)
if (akactor == Player)
Player.UnequipItem(EbonyMail)
Player.removeitem(EbonyMail, 1)
Endif
EndEvent

 

EDIT: Forgot "endif" statements in my original post. I've corrected this mistake.

Edited by JanusForbeare
Link to comment
Share on other sites

Since you're attaching the script to the necklace, you'll want OnEquipped, not OnObjectEquipped. Here's what I would recommend:

 

Actor Property Player Auto
Armor Property EbonyMail Auto

Event OnEquipped(akactor)
if (akactor == Player)
Player.additem(EbonyMail, 1)
Player.EquipItem(EbonyMail)
Endif
EndEvent

Event OnUnequipped(akactor)
if (akactor == Player)
Player.UnequipItem(EbonyMail)
Player.removeitem(EbonyMail, 1)
Endif
EndEvent

 

EDIT: Forgot "endif" statements in my original post. I've corrected this mistake.

 

Still doesn't do anything in game. When I equip the necklace nothing happens. Must be something im doing when i create the script in ck, for some reason It compiles okay without any errors. Thanks for all your help Janus, going to try a couple more things before I give up on this idea.

Link to comment
Share on other sites

If you're loading a savegame where you already have the necklace from before you attached the script to it, I believe the necklace won't have the script. Because it didn't exist at the time it was spawned, it wasn't saved with the script attached, it won't be there when loaded. Try spawning a new necklace and equipping it.

 

 

 

Link to comment
Share on other sites

No, you had it right before. Those methods take a Form, which Armor extends so that should be ok.

 

I was referring to the necklace that script is attached to. When you attached the script to the necklace in the CK and loaded a savegame, I don't believe that script is automatically added to any existing necklaces. Scripts attached to Form objects are only attached to instances of those Form objects when at the time the instance was created.

 

So I was suggesting that you spawn a new instance of the necklace and equipping that instead of the existing necklace you already had.

 

Assuming my understanding of how this works is correct.

Link to comment
Share on other sites

No, you had it right before. Those methods take a Form, which Armor extends so that should be ok.

 

I was referring to the necklace that script is attached to. When you attached the script to the necklace in the CK and loaded a savegame, I don't believe that script is automatically added to any existing necklaces. Scripts attached to Form objects are only attached to instances of those Form objects when at the time the instance was created.

 

So I was suggesting that you spawn a new instance of the necklace and equipping that instead of the existing necklace you already had.

 

Assuming my understanding of how this works is correct.

 

I went back to the original script(using EbonyMail) and just attached it to the common gold necklace. loaded a new save and added one through console commands, but the necklace still doesn't equip or add any armor. Could it be the way I'm attaching the script through ck? I just attach the script, compile to make sure that it succeeds, then I save and load skyrim. Thanks again for your help jshelper.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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