Hello,
I am making a mod which adds custom flags which you can equip using the torch mechanics as a way to hold the flag.
To force NPC's to equip flags, I made a script for an enchanted ring.
The magic effect for the ring states as condition that the target must have one or more of the flags in their inventory.
When that is true, the script fires.
It checks which flag is in the npc's inventory and equips that specific flag. When the ring is removed, the npc unequips the flag.
I gave it a 3 second delay, because I have mods which allow me to trade items with non followers. The script/trademod combo didn't work without this delay. My guess is those mods run scripts of their own and I need mine to run after those.
So far, the script compiled and works in game.
However, this is still my first script and my first mod for Skyrim.
Could someone check my script to see if I could improve it?
The script goes as follows:
Scriptname FLAGS_BearerDesignation extends activemagiceffect
light property FLAGSauto auto
Light Property FLAGSSons Auto
Light Property FLAGSImperial Auto
Light Property FLAGSWhiterun Auto
MagicEffect Property FLAGS_enchantment Auto
Form Flag
event OnEffectStart(Actor target, Actor caster)
If (Target.GetItemCount(FLAGSauto) >= 1)
Flag = FLAGSauto
Debug.MessageBox("The person should now equip the normal flag")
ElseIf (target.GetItemCount(FLAGSImperial) >= 1)
Flag = FLAGSImperial
Debug.MessageBox("The person should now equip the imperial flag")
ElseIf (target.GetItemCount(FLAGSWhiterun) >= 1)
Flag = FLAGSWhiterun
Debug.MessageBox("The person should now equip the Whiterun flag")
ElseIf (target.GetItemCount(FLAGSSons) >= 1)
Flag = FLAGSSons
Debug.MessageBox("The person should now equip the Stormcloak flag")
Else
Debug.MessageBox("No flag detected")
EndIf
RegisterForSingleUpdate(3.0)
endEvent
Event OnUpdate()
actor target = getTargetActor()
target.EquipItem(FLAG,true,true)
EndEvent
Event OnEffectFinish(Actor Target, Actor caster)
Target.UnequipItem(FLAG)
EndEvent