Jump to content

SetOutfit does not work on Actors, only Actorbase


PJMail

Recommended Posts

I have a script attached to the ActorBase record from which I create multiple Actors from. In it I can change the individual Actor's outfit (via a message menu).

All fine - 3 Actors in front of me, all with different outfits. I go away and come back - all have same outfit of last Actor changed.

The CK documentation has SetOutfit working on both Actor and Actorbase, but even if I cast the objectreference as Actor (which I assume "self" is anyway) it is acting as if the SetOutfit is effecting ActorBase only... and on 3D load resets the outfit of the Actor(s) to the outfit on the Actorbase.

 

Anyone seen this?

Link to comment
Share on other sites

SetOutfit absolutley works on Actor/ObjectReferences ... use it all the time.

 

But only in external scripts attached to actors via Quest Aliases, I have never attached direct to an ActorBase.

 

The base game does not use SetOutfit on any ActorBase attached scripts either.

 

It could be a glitch, like using AddItem on an actor will trigger their DefaultOutfit to reset.

Link to comment
Share on other sites

Trust me to find yet another 'glitch'. So, works on quest aliases attached to objectreferences (and probably magic effects as well) but not in scripts attached to the actual Actor(base) record.

Wonderful... Onload here I come. Thanks for that.

I did see your addItem issue thread when I was searching for this, but had already come across it when working on my PowerArmor mod (related problem - equipping headgear would randomly unequip clothing in other - unrelated - slots).

Link to comment
Share on other sites

Try this to see if they are somehow sharing the same script instance;

Script MyInstanceScript extends Actor ; NO NOT CONST

Int iMyScriptSerial

Event OnInit()
	iMyScriptSerial = Utility.RandomInt(0,999999)
	Debug.Trace("MyInstanceScript.OnInit " + (Self as Actor) + " " + iMyScriptSerial)
EndEvent

Function GetMyScriptSerial() ; call from console with REFID.CF "MyInstanceScript.GetMyScriptSerial"
	Debug.Trace("MyInstanceScript.GetMyScriptSerial " + (Self as Actor) + " " + iMyScriptSerial)
EndFunction 

Link to comment
Share on other sites

You mean the same script local variables? Is that a thing? I certainly use a lot of variables with unique values for each actor created off that base, and they remain different according to my logs.

The outfit ID is one of them. I tried it anyway. Each printed a different serial in the log.

Link to comment
Share on other sites

Is this for the vertibird? If so: You can attach multiple scripts to it, so perhaps make a 2nd script extending ObjectReference. You can then do some casting like ((Self as ObjectReference) as Actor).SetOutfit(theOutfit, false). That's how the Pilot Outfit Script in my addon works. Accessing Properties and Functions across scripts that are attached to the same reference can be done by casting as well:

 

In TheOneScript:

((Self as ObjectReference) as TheOtherScript).PropertyOnOtherScript = 1337

 

In TheOtherScript:

((Self as ObjectReference) as TheOneScript).MyFunction(theParameter)

 

I often use this technique to keep code for functionally distinct blocks apart and to help with reusability. It's akin to some sort of Polymorphism and it can be used to "fake" Interfaces as well.

 

 

Local variables are never shared across different script instances. What SKK meant is if all the birds use the same script instance for some reason.

Link to comment
Share on other sites

My confusion here is my script extends "Actor", which I understood to be an ObjectReference (an objectreference created from an Actorbase is an 'actor').

It certainly acts like an ObjectReference, so what benefit do I get from a second script extending Objectreference?

My problem is doing a setoutfit on the objectreference (cast as Actor) effects the outfit on ALL other objectreferences derived from the same actorbase.

Not immediately - but when they next 3d load.

It is as if doing (myobjectreference as actor).setoutfit(outfit) is being treated as (myobjectreference as actor).getactorbase().setoutfit(outfit)

Remember - I don't create these objectreferences/Actors from a "leveled npc" list (like the Pilot), but directly from a single NPC record.

Perhaps that is the issue... I know actors created from a levelled list are treated very differently by many script functions.

For instance you have to use Getleveledactorbase()

Link to comment
Share on other sites

  • Recently Browsing   0 members

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