Jump to content

Random Clothing Script


Firehawk777

Recommended Posts

Scriptname FH:ChangeClothes extends Actor Conditional 
{A simple change clothes script}
ActorBase property theNPC Auto const
Outfit property theOutfit Auto Conditional

Function ChangeToSleepClothes(ActorBase theNPC, Outfit theOutfit)
		Outfit OldOutfit = theNPC.GetOutfit()
		if(theOutfit)
			theNPC.SetOutfit(theOutfit)

		else
			theNPC.SetOutfit(theNPC.GetOutfit(true))
			theOutfit=theNPC.GetOutfit(true)
			if(theOutfit)
		
			else
				theOutfit=theNPC.GetOutfit()
			
			endif
		endif
EndFunction

Event OnActivate(ObjectReference theNPC)
		ChangeToSleepClothes(theNPC,theOutfit)
EndEvent 

Hi all.

I am totally new to scripting using the fallout CK and I am wondering if someone could help me with implementing a simple script.

I am trying to get an actor to change clothing to a random outfit either from within their inventory or a custom array of outfits at the start of a package.

Its pretty clear as to where I do this in the package. Though I am only learning how papyrus fragments and scripts are implemented. I was wondering if someone might give me some pointers or point me to tutorials that explain how I would do this.

The script function name is not representative as the script should change to firstly the chosen outfit, if that does not exist then the sleepoutfit and finally default to the normal worn outfit if neither exist.

Edited by Firehawk777
Link to comment
Share on other sites

  • 1 month later...
You might want to place your script in an (OnBegin) package fragment. (In the package's "Begin/End/Change" tab). I haven't tested it but maybe you can try out this one:

Scriptname Fragments:Packages:PF_SCRIPTNAME Extends Package Hidden Const

;BEGIN FRAGMENT Fragment_End
Function Fragment_End(Actor akActor)
;BEGIN CODE

int ArrayLength = myArray.Length

int RandomInt = utility.randomint(0, ArrayLength) ;you can use a number instead of the arrayLength because you know how many Armors you added to the Array. In this case, no need for the first (the int arrayLenght) line.

If RandomInt == 0
akActor.EquipItem(myArray [0])
ElseIf RandomInt == 1
akActor.EquipItem(myArray [1])
EndIf

;END CODE
EndFunction
;END FRAGMENT

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

Armor[] Property myArray Auto Const

Edited by LarannKiar
Link to comment
Share on other sites

AFK, you may check if outfit change works.
If I remember correctly changing an Outfit with papyrus is buggy. The outfit will not change.
You may need to mess around with adding single clothing/armors.

> I am trying to get an actor to change clothing to a random outfit either from within their inventory or a custom array of outfits at the start of a package.
You need a script on the Package, not the Actor.

Example code using a Papyrus file:

    Scriptname MyNameSpace:MyPackage extends Package

    Outfit[] property TheOutfits

    Event OnStart(Actor akActor)
        Outfit SelectedOutfit = TheOutfits[Utility.RandomInt(0, TheOutfits.Length-1)]
    EndEvent

I guess the namespace is auto generated when using inline/fragments.
Notice the typed Array[] for TheOutfits property. Besides being an Array CK will let you add multiple values in the UI - property window.

If list reuse becomes a requirement or some other case you may plug a FormList type instead of an Array.

https://www.creationkit.com/fallout4/index.php?title=FormList
https://www.creationkit.com/fallout4/index.php?title=FormList_Script

Again. Test wether outfit change via Papyrus works as expected.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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