I got it working for the most part: Followers unequip their helmet if I give them one when their weapon is sheathed. They equip their helmet when they draw their weapon and unequip it when they sheath it. Perfect. However, it stops working when I fast travel or enter/exit a city. The follower comes out of the loading screen with their helmet equiped and doesn't unequipe it anymore (in other words: the vanilla behaviour). Entering/exiting a house or a cave doesn't seem to cause this problem though.
My attempts to come up with a sollution have met with no success so far. If anyone has any idea on how to keep this script from stopping to work, I'd apreciate it.
Script:
Spoiler
Scriptname Rayg_FollowerAliasHelmetScript extends ReferenceAliaskeyword property ArmorHelmet autoarmor Helmetbool SkipUpdate = falseAuto State IdleEvent OnObjectEquipped(Form akBaseObject, ObjectReference akReference) if (akBaseObject as armor) if (akBaseObject as armor).HasKeyword(ArmorHelmet) Helmet = akBaseObject as armor if !GetActorReference().IsWeaponDrawn() GetActorReference().UnequipItem(Helmet, false, true) endif GoToState("Run") endif endifEndEventEndStateState RunEvent OnBeginState() RegisterForAnimationEvent(GetActorReference(), "weaponDraw") RegisterForAnimationEvent(GetActorReference(), "weaponSheathe")EndEventEvent OnAnimationEvent(ObjectReference akSource, string asEventName) if asEventName == "weaponDraw" if !GetActorReference().GetItemCount(Helmet) Helmet = None GoToState("Idle") return endif if !GetActorReference().IsEquipped(Helmet) SkipUpdate = true GetActorReference().EquipItem(Helmet, false, true) endif elseif asEventName == "weaponSheathe" if GetActorReference().IsEquipped(Helmet) SkipUpdate = true GetActorReference().UnequipItem(Helmet, false, true) endif endif if !(Helmet as armor) Helmet = None GoToState("Idle") return endifEndEventEvent OnObjectEquipped(Form akBaseObject, ObjectReference akReference) if (akBaseObject as armor) if (akBaseObject as armor).HasKeyword(ArmorHelmet) if SkipUpdate SkipUpdate = false return endif if !GetActorReference().IsEquipped(akBaseObject) return endif if GetActorReference().IsWeaponDrawn() Helmet = akBaseObject as armor else Helmet = None GoToState("Idle") endif endif endifEndEventEvent OnObjectUnequipped(Form akBaseObject, ObjectReference akReference) if (akBaseObject as armor) if (akBaseObject as armor).HasKeyword(ArmorHelmet) if SkipUpdate SkipUpdate = false return endif if GetActorReference().WornHasKeyword(ArmorHelmet) return endif Helmet = None GoToState("Idle") endif endifEndEventEvent OnEndState() UnregisterForAnimationEvent(GetActorReference(), "weaponDraw") UnregisterForAnimationEvent(GetActorReference(), "weaponSheathe")EndEventEndState