So I'm working on a script that is supposed to resemble the bound armor in TESIV. The variant that I'm having trouble with is one designed solely for NPCs. The goal is to have the spell trigger when the NPC goes into combat, and have it automatically dispel when he dies or leaves combat. I have just about everything sorted out, but I don't know how to have the "EquipItem" function reference the actor that the script is attached to.
Here's what I have so far:
Scriptname VHBoundArmorMythicDawnDeathDispel extends ObjectReference
;Begin Bound Armour list
Armor Property Helmet Auto
Armor Property chest Auto
Armor Property boots Auto
Armor Property Hands Auto
;End Bound Armour list
;Begin Regular Clothes list
Armor Property Robe Auto
Armor Property RobeBoots Auto
Armor Property RobeHands Auto
;End Bound Armor list
Message Property FailedEquip Auto
Int Property Worked Auto
SPELL Property ThisSpell Auto
Event OnCombatStateChanged(Actor akTarget, int aeCombatState)
if (aeCombatState == 1)
SELF.AddItem(Helmet)
;SELF.EquipItem(Helmet)
SELF.AddItem(chest)
;SELF.EquipItem(chest)
SELF.AddItem(boots)
;SELF.EquipItem(boots)
SELF.AddItem(Hands)
;SELF.EquipItem(Hands)
SELF.RemoveItem(Robe)
elseif (aeCombatState == 0)
;Put the same things as in "OnDying" in this area once bugs worked out
else
endif
endEvent
;======================================================
;The functions that have the semicolons are the ones that aren't working. Since they couldn't work, I nulled them for the time being
;so that the script could compile as-is. I'm wanting the person that this script is attached to to equip the items in those
;circumstances.
;======================================================
Event OnDying(Actor akTarget, Actor akCaster)
SELF.RemoveItem(Helmet)
SELF.RemoveItem(chest)
SELF.RemoveItem(boots)
SELF.RemoveItem(Hands)
SELF.AddItem(Robe)
;EquipItem(Robe)
;EquipItem(RobeHands)
;EquipItem(RobeBoots)
endEvent