Jump to content

Noob script question: Actor property Base vs. Ref


oldrayzor

Recommended Posts

Posted

This simple script should outfit a list of actors with armors posted in an outfit list. The script compiles without error. The message box presents all the Actor references as "None" when looping, though the outfit reference appears correctly. It doesn't outfit anyone. When using a formlist of actors drawn from the non-player category, must they be convert to use as a Reference Object?

 

Script:

Spoiler

Scriptname DebutOutfitter   Extends Quest
{Sets DefaultOutfit for listed NPCs}

FormList Property myNPCList  Auto  
FormList Property myOutfitList  Auto  
Outfit Property DebutOutfit Auto
Outfit Property NullOutfit Auto
Armor Property myArmorRef Auto
Actor Property myActorRef Auto

 

Event OnInit()

    Debug.MessageBox("Quest DebutOutfitter Start")

    SetDebutOutfits()

EndEvent

 

Function SetDebutOutfits()

    Int NPCListCnt = myNPCList.GetSize()

    while NPCListCnt

        NPCListCnt -=1
        myActorRef = myNPCList.GetAt(NPCListCnt) as Actor
        myActorRef.SetOutfit (NullOutfit)
        DebutOutfit = myOutfitList.GetAt(NPCListCnt) as Outfit
        myActorRef.SetOutfit (DebutOutfit)
    
        Debug.MessageBox("Actor #"+NPCListCnt+" : "+myActorRef+" : "+Debutoutfit)

 

        Int OutfitListCnt = DebutOutfit.GetNumParts()

        while OutfitListCnt

            OutfitListCnt -=1
            myArmorRef = debutOutfit.GetNthPart(OutfitListCnt) as Armor
            myActorRef.additem (myArmorRef,1,TRUE)
            myActorRef.equipItem (myArmorRef,0,TRUE)

        EndWhile

    EndWhile

 

    Debug.MessageBox("Script Complete")

 

EndFunction

 

Script Properties:

Spoiler

QuestScreen.jpg.02bf0a81a8b3417bbbc08fde1e56f83d.jpg

 

Posted

Actor is a special case of ObjectReference, e.g. an ActorBase placed in the world.

ActorBase is the definition of an actor, but not the actor itself. For example you can have multiple actors using the same actorbase (think about the guards.)

Posted
1 hour ago, CPU said:

Actor is a special case of ObjectReference, e.g. an ActorBase placed in the world.

ActorBase is the definition of an actor, but not the actor itself. For example you can have multiple actors using the same actorbase (think about the guards.)

Thanks. Sorry I'm such a noob at this. While, yes, I do get the difference in your example, I don't understand which is incorporated into a FormList (simple drag-n-drop from Non-player category and how it is applied with SetOutfit(). It appears the form list contains the reference to a named NPC but it does not appear to work as applied in the script above.

Posted

i give u some general ideas on debugging,

better than messagebox or notification,

inject debug.trace method on 

every suspicious method and varible types 

in your scripts and 

monitor the error logs statments outputted and value dump in papyrus0.log

 

it will help u a lot in script debugging ,  sometimes much helpful and faster than waiting ppl provide an answer. 

Posted
21 minutes ago, oldrayzor said:

Thanks. Sorry I'm such a noob at this. While, yes, I do get the difference in your example, I don't understand which is incorporated into a FormList (simple drag-n-drop from Non-player category and how it is applied with SetOutfit(). It appears the form list contains the reference to a named NPC but it does not appear to work as applied in the script above.

The outfit is actually not part of Actor but is part of ActorBase.

I am not home right now, so I cannot give you good examples.

 

Tomorrow evening I will try to give you a better, visual, example.

Posted
11 minutes ago, oldrayzor said:

Thanks for the tip.

realtime gameplay

logs can be printed via notification, console and papyrus0.log , most script error issues can be 

identified during watch papyrus0.log  which prints out a error stack telling u which specific line of ur psc script stopped function well .

  • 1 month later...
Posted
On 2/21/2019 at 10:25 AM, CPU said:

The outfit is actually not part of Actor but is part of ActorBase.

I am not home right now, so I cannot give you good examples.

 

Tomorrow evening I will try to give you a better, visual, example. 

Apologies, been preoccupied with other parts of the mod, but did manage to get the outfitter to work. Problem is I have a formlist comprised of actorbases and can't find how to add items to an actorbase or to convert actorbase to reference or maybe simply can't add an item to the base.  Not sure.

Posted

OK, the function to set an outfit is this one:

 

anActor.SetOutfit(akOutfit, abSleepOutfit)

This should update the outfit of the actor.

Posted
1 hour ago, CPU said:

OK, the function to set an outfit is this one:

Thanks, yes I have the default outfit no problem, but I wish to add a weapon to the NPCs inventory yet I only have the ActorBase original to work with. Does the additem function work with the ActorBase? I've tried, but may have done something wrong.

Posted

No, it does not work with ActorBase. You need an ObjectReference that can be considered a container (an Actor, for example.)

 

Posted
21 hours ago, CPU said:

No, it does not work with ActorBase. You need an ObjectReference that can be considered a container (an Actor, for example.)

That's very interesting. Explains why Immersive Weapons replaces the entire NPC record to add weapons to an NPC's inventory.  Thank you for your assistance CPU.

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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