Jump to content

Actor scripting questions


inawe

Recommended Posts

You know, I`ve found problem with changing headparts. It seems that the game does not save this changes. Each time after quiting and loading a save , npc get their default headparts( from the CK). They also get the same headparts after leaving and returning to the area. I don`t know if this happenes with all npc, or only non persistent. And to avoid this you probably would need to use OnInit,OnLoad and OnPlayerLoadGame . Creating a randomInt on Inint and then using this variable for other events.

This should take care of it. States no longer required.

 

ScriptName ChangeMyHeadParts extends Actor Hidden

FormList Property EyeList Auto Const Mandatory
FormList Property HairList Auto Const Mandatory

int RandomEyeIndex = -1
int RandomHairIndex = -1

Event OnLoad()
	If RandomEyeIndex < 0
		RandomEyeIndex = Utility.RandomInt(0, 21)
	EndIf
	If RandomHairIndex < 0
		RandomHairIndex = Utility.RandomInt(0, 33)
	EndIf
	RegisterForRemoteEvent(Game.GetPlayer(),"OnPlayerLoadGame")
	ChangeHeadPart(EyeList.GetAt(RandomEyeIndex) as HeadPart)
	ChangeHeadPart(HairList.GetAt(RandomHairIndex) as HeadPart)
endEvent

Event Actor.OnPlayerLoadGame(Actor akSender)
	ChangeHeadPart(EyeList.GetAt(RandomEyeIndex) as HeadPart)
	ChangeHeadPart(HairList.GetAt(RandomHairIndex) as HeadPart)
EndEvent
I haven't tried compiling it as I am not at home. Cheers.
Link to comment
Share on other sites

  • Recently Browsing   0 members

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