Jump to content

Possible to add/remove ArmorAddon via script?


Kohdi

Recommended Posts

Hey all, I've got yet another scripting question for you. I'm trying to make an amulet which, by its enchantment, senses when the player gets below a certain health percentage, then activates a few beneficial effects. I'd like the amulet to change its appearance during this time to an identical model with a glow map, but the amulet needs to remain the same object or the enchantment-script will be interrupted. The only workaround I can think of is if there is a way to modify an armor object's ArmorAddon properties via script, which would allow me to take out or switch the non-glowing with the glowing (I'm not going to sweat the inventory model). Any suggestions?
Link to comment
Share on other sites

Uneducated guess: Can you use a second object with an identical but - apart from a glow map - completely transparent mesh which is addiitionally equipped to the character in one of the unused slots? I know it's not what you asked for but I just thought I share a spontaneous idea. Sorry if you already tried that.
Link to comment
Share on other sites

There's no way to change the armoraddon via script. There are a couple of other workarounds you may consider however. Both use a 2nd model of the amulet with the changes you want made.

 

You can move the enchantment effect to an ability on the player, added during OnEquip of the first model. This ability can monitor global variables set by the 1st amulet.

You can use global variables for temporary storage of float values inbetween the change.

If you know the state the enchantment script will be in at the point the interruption would occur, it should be quite easy for the 2nd one to pick up where the 1st left off as it were. Along the lines of.

 

1st Amulet

OnEquip

Stuff

 

OnUnequip

Stop stuff

Set Global Variable to x

 

2nd Amulet

OnEquip

If (global variable == x)

Carry on with stuff

else

do other stuff

 

I think the first approach I suggested should work. There will be no interruption to the script and you can freely manipulate the ability with either amulet and global variables. If you don't mind giving away a little about script, what function is it running that cannot be interrupted? Is it a graphical sequence?

Link to comment
Share on other sites

Thanks for the suggestions, I think what I'll try to do is make the inactive amulet run the script to check the player's health, then if the percentage is reached it will switch to the active, glowing amulet which will have the actual magic effects, which can switch itself back out when it's done working. The reason I was trying to keep the same amulet equipped was because the script runs out of an enchantment, and if the amulet is unequipped, the enchantment-script will no longer run. The enchantment itself is a modified version of the Kohnariik mask, without the dragon priest summoning and with a magic drain applied to the player (this works pretty well).
Link to comment
Share on other sites

Forgive me if I oversimplify or miss something, but from the looks of it, the values that need to be monitored are health and magicka. You can use two global variables as temporary storage during the change over.

 

1st amulet:

OnEquip

Drain Magicka

If Current Health Percentage <= Threshold

Global Variable 1 = Current Health

Global Variable 2 = Current Magicka

Force add and equip 2nd Amulet

Remove 1st amulet from inventory

 

2nd Amulet

On Equip

Set wearer's health to GV1

Set wearer's magicka to GV2

Drain Magicka

Special Enchantment

if Current Health Percentage > Threshold

Force add and equip 1st Amulet

Remove 2nd amulet from inventory

 

OnUnequip

Remove 2nd amulet from inventory and add 1st amulet to inventory

 

It may not even be necessary to use GVs to store the values as the change will be very fast. Assuming the special voodoo actually going on only happens below the threshold as with the mask you mention, that part can be left solely on the 2nd amulet.

Link to comment
Share on other sites

That's essentially what I did, and after some frustrated script finagling and tweaking to visual effects, the amulet is working beautifully. Thanks for your help! Now I just need to write the owner's journal...
Link to comment
Share on other sites

  • Recently Browsing   0 members

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