Jump to content

[LE] How to store an outfit as a variable and use it in different scripts


xEthann

Recommended Posts

So I am trying to create a script that resets an NPCs outfit back to its default state. A previous script (which works perfectly) Uses the SetOutfit() function to make the NPC wear a ragged outfit and is triggeed with dialogue

 

Now what I am trying to figure out is how to store the original outfit as a variable that can be called when I am trying to revert the outfit back to its original state.

I have tried a few methods but none seem to work - although they do compile

 

This was the first method:

 

Script that sets the outfit:

if WhiterunBeggar01.GetActorRef() == none
WhiterunBeggar01.ForceRefTo(akSpeaker as objectreference)
akSpeaker.moveto(Marker01)
CitizenOutfit01 = akSpeaker.GetActorBase().GetOutfit()
akSpeaker.SetOutfit(BeggarOutfit)
Outfit Property CitizenOutfit01  Auto

Script that reverts everything back to normal:

 

if akSpeaker as objectreference == WhiterunBeggar01.GetReference()
WhiterunBeggar01.clear()
akSpeaker.SetOutfit(BeggarScript.CitizenOutfit01)
AAInfluenceMakeBeggar Property BeggarScript auto

When the script was triggered, everything worked as intended except for the change in outfit back to normal.

 

So I then tried a different approach by directly adding an empty Outfit (the same way you would add an NPC) and calling it CitizenOutfit01

Then I made CitizenOutfit01 a property in BOTH scripts and auto filled the property.

 

So the script to change the default outfit stayed the same and the script to reset the outfit had a very small change:

if akSpeaker as objectreference == WhiterunBeggar01.GetReference()
WhiterunBeggar01.clear()
akSpeaker.SetOutfit(CitizenOutfit01)
Outfit Property CitizenOutfit01  Auto

This approach didn't work either.

 

Could anyone please shed some light as to why this isn't working or show me what I should do instead?

 

Link to comment
Share on other sites

You have posted snippets of code and imho not very explaining.

Maybe next is helpful for you:

 

(1) dialogue script (AAInfluenceMakeBeggar) to get the outfit, move the actor and set a new beggar outfit

  otherScriptname PROPERTY myScript         auto    ; change otherScriptname to scriptname from (2)
  Outfit          PROPERTY BeggarOutfit     auto

  ReferenceAlias  PROPERTY WhiterunBeggar01 auto    ; ***
  ObjectReference PROPERTY Marker01         auto


    IF WhiterunBeggar01.GetReference()
        ; already in use
    ELSE
        WhiterunBeggar01.ForceRefTo(akSpeaker as ObjectReference)

        actorBase AB = akSpeaker.GetActorBase()
        myScript.CitizenOutfit01 = AB.GetOutfit()    ; store outfit in other dialogue script
        
        akSpeaker.Disable()
        akSpeaker.MoveTo(Marker01)
        Utility.Wait(0.1)
        akSpeaker.EnableNoWait()
        akpeaker.EvaluatePackage()

        akSpeaker.SetOutfit(BeggarOutfit)
    ENDIF

(2) dialogue script (otherScriptname) to revert the outfit

  Outfit PROPERTY CitizenOutfit01 auto Hidden          ; filled by script from (1)

  ReferenceAlias PROPERTY WhiterunBeggar01 auto        ; ***

    IF (akSpeakerRef == WhiterunBeggar01.GetReference())
        WhiterunBeggar01.Clear()
        
        actorBase AB = akSpeaker.GetActorBase()
        IF ( CitizenOutfit01 )
            AB.SetOutfit(CitizenOutfit01)
            CitizenOutfit01 = None                    ; clear this property
        ENDIF
    ENDIF
Link to comment
Share on other sites

Thank you so much for your response but for some reason I still can't get this to work properly, the outfit still doesn't revert back to normal.

 

Sorry I couldn't explain better, here are the whole scripts, (they're very small) I'm writing them in the creation kit fragment box

 

(1) Script to get the outfit, move the npc and set the beggar outfit

;BEGIN FRAGMENT CODE - Do not edit anything between this and the end comment
;NEXT FRAGMENT INDEX 1
Scriptname AAInfluenceMakeBeggarWhiterun Extends TopicInfo Hidden

;BEGIN FRAGMENT Fragment_0
Function Fragment_0(ObjectReference akSpeakerRef)
Actor akSpeaker = akSpeakerRef as Actor
;BEGIN CODE
if WhiterunBeggar01.GetActorRef() == none
WhiterunBeggar01.ForceRefTo(akSpeaker as objectreference)
akSpeaker.moveto(Marker01)
ReleaseScript.CitizenOutfit01 = akSpeaker.GetActorBase().GetOutfit()
akSpeaker.SetOutfit(BeggarOutfit)
debug.Notification("Citizen has been made a beggar")
EndIF
akSpeaker.EvaluatePackage()
;END CODE
EndFunction
;END FRAGMENT

ReferenceAlias Property WhiterunBeggar01  Auto  

ObjectReference Property Marker01  Auto  

Outfit Property BeggarOutfit  Auto  

AAInfluenceRelease Property ReleaseScript Auto

(2) Script to revert the outfit back to normal

;BEGIN FRAGMENT CODE - Do not edit anything between this and the end comment
;NEXT FRAGMENT INDEX 1
Scriptname AAInfluenceRelease Extends TopicInfo Hidden

;BEGIN FRAGMENT Fragment_0
Function Fragment_0(ObjectReference akSpeakerRef)
Actor akSpeaker = akSpeakerRef as Actor
;BEGIN CODE
if akSpeaker as objectreference == WhiterunBeggar01.GetReference()
WhiterunBeggar.clear()
akSpeaker.SetOutfit(CitizenOutfit01)
debug.Notification("Citizen's status has been restored")
endif
;END CODE
EndFunction
;END FRAGMENT

;END FRAGMENT CODE - Do not edit anything between this and the begin comment

ReferenceAlias Property WhiterunBeggar01  Auto  

Outfit Property CitizenOutfit01 Auto

I'm still quite new to this, I have only been using creation kit for about a week so I'm mostly just working from the wiki and youtube but for some reason I just can't get the two scripts to link properly.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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