Guidance on how to make NPCs change clothes every day?

Post » Sun Mar 15, 2015 11:35 pm

Hi! I apologize for coming at this from such an amateur angle, but for a long time I've been wanting to make NPCs change their clothes every so often. Whenever an NPC has their outfit pointed to a leveled list with different clothing, executing a simple disable/enable in the console on that NPC will make them load a random piece of clothing from that leveled list.

I would like to somehow implement that functionality into the game, so that once every day or every couple of days, NPCs outfits will reset and load something different from the leveled list.

So, my questions are:

  1. Is there another method / function available to "refresh" the NPC in this way besides disable/enable?
  2. If there is such a method, what would be the cleanest way to implement the event? Registering for a single update once a day for every NPC seems like a terrible idea. It seems like this would ideally happen upon loading of the cell containing NPCs, with some sort of boolean to check whether or not NPCs have refreshed for the day.
  3. Instead of a full reset like this, does Papyrus or SKSE have a function available to change outfits or refresh clothing specifically?

I am barely learned with Papyrus and need tons of reference in front of me to do simple things currently, so off the top of my head the ridiculous horrible pseudo-code could be something like:

global bool ClothingRefreshToday;RegisterForSingleUpdateGameTime at 6am on ResetNPCClothing() function //resets the check for NPC clothing refresh every morning at 6am// function to reset the bool for if NPCs have refreshed today or notfunction ResetNPCClothing(){   set global ClothingRefreshToday = 0;   RegisterForSingleUpdateGameTime at 6am again //I read doing something like this was a good way to avoid those log-spam, error prone timer based checks when a mod is removed}// the function that runs when a cell is loadedOn CellLoad(){   if(ClothingRefreshToday=0){ //if it's 1, meaning this already executed, we'll skip and not bother resetting any NPCs      GetAllNPCsInTheCell();      IterateOverNPCsAndIssueResetCommand();      set global ClothingRefreshToday = 1;   }}

Thoughts? Thank you!

User avatar
Janeth Valenzuela Castelo
 
Posts: 3411
Joined: Wed Jun 21, 2006 3:03 am

Post » Sun Mar 15, 2015 6:39 pm

Well it's been such a long time since I wrote this that I'd have to spend a little bit of time reminding myself what I did, but basically what this was for was a mini cat walk the actor would head back to a trigger box as part of a patrol and this was on a trigger box at one of the patrol points.

Actor Property SlaveModel  Auto  FormList Property VSDWardrobe  AutoInt TempArmor ChosenWearInt LasttimeInt SizeEvent OnTriggerEnter(ObjectReference akActionRef)	Size = VSDWardrobe.GetSize()	Temp = Utility.RandomInt(0, (Size - 1))	If akActionRef == SlaveModel		While Size			Size -= 1			ChosenWear == VSDWardrobe.GetAt(Size) As Armor			If SlaveModel.IsEquipped(ChosenWear)				SlaveModel.UnequipItem(ChosenWear)				Lasttime = Size			EndIf		EndWhile		SlaveModel.UnequipAll()		Size = VSDWardrobe.GetSize()		If Lasttime == Temp			Temp = Utility.RandomInt(0, (Size - 1))		EndIf		If Temp == 0 || Temp == 1			ChosenWear = VSDWardrobe.GetAt(0) As Armor			SlaveModel.EquipItem(ChosenWear)			ChosenWear = VSDWardrobe.GetAt(1) As Armor			SlaveModel.EquipItem(ChosenWear)		ElseIf Temp == 2 || Temp == 3			ChosenWear = VSDWardrobe.GetAt(2) As Armor			SlaveModel.EquipItem(ChosenWear)			ChosenWear = VSDWardrobe.GetAt(3) As Armor			SlaveModel.EquipItem(ChosenWear)		ElseIf Temp == 4			ChosenWear = VSDWardrobe.GetAt(4) As Armor			SlaveModel.EquipItem(ChosenWear)			ChosenWear = VSDWardrobe.GetAt(3) As Armor			SlaveModel.EquipItem(ChosenWear)		ElseIf Temp == 5			ChosenWear = VSDWardrobe.GetAt(5) As Armor			SlaveModel.EquipItem(ChosenWear)		ElseIf Temp == 6			ChosenWear = VSDWardrobe.GetAt(6) As Armor			SlaveModel.EquipItem(ChosenWear)		ElseIf Temp == 7 || Temp == 8			ChosenWear = VSDWardrobe.GetAt(7) As Armor			SlaveModel.EquipItem(ChosenWear,True)			ChosenWear = VSDWardrobe.GetAt(8) As Armor			SlaveModel.EquipItem(ChosenWear)		ElseIf Temp == 9			ChosenWear = VSDWardrobe.GetAt(9) As Armor			SlaveModel.EquipItem(ChosenWear)			ChosenWear = VSDWardrobe.GetAt(8) As Armor			SlaveModel.EquipItem(ChosenWear)		ElseIf Temp == 10 || Temp == 11 || Temp == 12			ChosenWear = VSDWardrobe.GetAt(10) As Armor			SlaveModel.EquipItem(ChosenWear)			ChosenWear = VSDWardrobe.GetAt(11) As Armor			SlaveModel.EquipItem(ChosenWear)			ChosenWear = VSDWardrobe.GetAt(12) As Armor			SlaveModel.EquipItem(ChosenWear)		ElseIf Temp == 13 || Temp == 14			ChosenWear = VSDWardrobe.GetAt(13) As Armor			SlaveModel.EquipItem(ChosenWear)			ChosenWear = VSDWardrobe.GetAt(14) As Armor			SlaveModel.EquipItem(ChosenWear)		ElseIf Temp == 15			ChosenWear = VSDWardrobe.GetAt(15) As Armor			SlaveModel.EquipItem(ChosenWear)		ElseIf Temp == 16			ChosenWear = VSDWardrobe.GetAt(16) As Armor			SlaveModel.EquipItem(ChosenWear)					EndIf	EndIfEndEvent
User avatar
Solène We
 
Posts: 3470
Joined: Tue Mar 27, 2007 7:04 am


Return to V - Skyrim