script to apply selected enchantments to armor, possible?

Post » Thu Oct 02, 2014 7:03 am

Hi :smile:

So, I just created this script, from scratch, with practically no clue as to what I was doing, and it works, yay! :D (if you can't tell that made me very happy lol) But anyway, it's not quite finished yet. At the moment in the script at the part I haven't done yet, I've just put a description as to what I want to do, but I have no idea how to go about doing it, or if it's even possible :S Basically, the script comes up with a message box when you equip the piece of armor, and asks you which set of enchantments (choice of three) you'd like to apply to it. Then whichever one you pick it'll give you a description and ask you if you're sure. Right now if you then select no, it'll take you back to the first menu. But what I don't how to do is script what happens when you select yes. Is there a way for a script to enchant an item for you? If anyone can help me I'd really appreciate it, thanks! :smile:

Here's the script I've got so far so you can see what I mean:

Spoiler
Scriptname HeroAmuletEnchantmentScript extends ObjectReference   Message Property EnchantMsg AutoMessage Property MageEnchantMsg AutoMessage Property WarriorEnchantMsg AutoMessage Property ThiefEnchantMsg Auto AUTO STATE WaitingEvent OnEquipped (Actor akActor)GoToState("Done")if akActor == Game.GetPlayer()Menu()EndifEndEventENDSTATE STATE DoneEvent OnEquipped (Actor akActor);;nothingEndEventENDSTATE Function Menu(int aiButton = 0)aiButton = EnchantMsg.Show()If aiButton == 0MageEnchantMsg.Show()ElseIf aiButton == 1WarriorEnchantMsg.Show()ElseIf aiButton == 2ThiefEnchantMsg.Show()EndIfEndFunction Function MageMenu(int aiButton = 0)aiButton = MageEnchantMsg.Show()If aiButton == 0;;apply mage enchantments to amuletElseIf aiButton == 1EnchantMsg.Show()EndIfEndFunction Function WarriorMenu(int aiButton = 0)aiButton = WarriorEnchantMsg.Show()If aiButton == 0;;apply warrior enchantments to amuletElseIf aiButton == 1EnchantMsg.Show()EndIfEndFunction Function ThiefMenu(int aiButton = 0)aiButton = ThiefEnchantMsg.Show()If aiButton == 0;;apply thief enchantments to amuletElseIf aiButton == 1EnchantMsg.Show()EndIfEndFunction Int Property aiButton  Auto  
User avatar
Margarita Diaz
 
Posts: 3511
Joined: Sun Aug 12, 2007 2:01 pm

Post » Wed Oct 01, 2014 7:11 pm

EDIT: I actually forgot to test selecting the no option before posting this, and it actually doesn't work, it just closes the menu instead of taking you back to the first menu. :( Can I also get some help with sorting that? Thanks.

User avatar
Shelby Huffman
 
Posts: 3454
Joined: Wed Aug 08, 2007 11:06 am

Post » Thu Oct 02, 2014 10:34 am

Instead of

EnchantMsg.Show() 

You need to call your Menu() function again when the NO option is selected.

Regarding the enchantment, you can set the enchantment on the item using SKSE. You would need to make those three enchantments and add them as properties to your script. Then, something like:

Armor HeroAmulet = self.GetBaseObject() as Armor    ;this will work as long as this script is attached to the amuletHeroAmulet.SetEnchantment(yourEnchantmentProperty)

I'm slightly unsure if this will work if your amulet is already a created object reference, I don't know if it will still inherit the enchantment from the base armor form in that case. If not, there is another alternative, using ObjectReference.SetEnchantment(). I would try the method above first, though.

User avatar
Breanna Van Dijk
 
Posts: 3384
Joined: Mon Mar 12, 2007 2:18 pm


Return to V - Skyrim