Help with script to set outfit when in combat?

Post » Tue Nov 20, 2012 1:59 am

Scriptname CasChangeClothes extends ActorOutfit Property CasWorkOutfit  AutoOutfit Property CasHomeOutfit  AutoReferenceAlias Property Alias_Cas  AutoEvent OnUpdate()RegisterForSingleUpdate(5.0)Actor Cas = Alias_Cas.GetActorReference()  if Cas.IsInCombat()==true  Cas.SetOutfit(CasHomeOutfit)	else	Cas.SetOutfit(CasWorkOutfit)EndIfEndEvent

This script is supposed to change the NPC's outfits when in combat. I attached it to the NPC. It compiles ,but doesn't work.
Help?

Also how could I check if the NPC's location changes and then set an outfit based on whether the location is an interior or not?
Could I use that in the same script itself?
User avatar
Bigze Stacks
 
Posts: 3309
Joined: Sun May 20, 2007 5:07 pm

Post » Tue Nov 20, 2012 11:50 am

Scriptname CasChangeClothes extends ActorOutfit Property CasWorkOutfit  AutoOutfit Property CasHomeOutfit  AutoReferenceAlias Property Alias_Cas  Auto ;this property is redundant if attached to an actorEvent OnCombatStateChanged(Actor akTarget, int aeCombatState)  if (aeCombatState != 0)	   SetOutfit(CasHomeOutfit)   else	   SetOutfit(CasWorkOutfit)EndIfEndEventEvent OnLocationChanged(Location akOldLoc, Location akNewLoc)	 if (IsInInterior())		  ;inside outfit	 else		  ;outside outfit	 endifEndEvent
User avatar
Eve(G)
 
Posts: 3546
Joined: Tue Oct 23, 2007 11:45 am

Post » Tue Nov 20, 2012 12:03 pm

Thanks for the reply, but still no luck, the NPC just won't change his outfit into his work one. The script compiles, properties are set up correctly, I don't know what's wrong.

I originally tried the OnCombatStateChange event before, and that didn't work.

edit: I added a debug notification to check whether the script actually fires and then it started working. Strange.

That being done, is it possible to change outfits based on chance in the script (say I have outfit A B C and D and when NPC is outside, I want one of them to randomly trigger)
User avatar
KiiSsez jdgaf Benzler
 
Posts: 3546
Joined: Fri Mar 16, 2007 7:10 am


Return to V - Skyrim