Jump to content

Scripting help - added to inventory event


Recommended Posts

Hey,

 

I'm trying to get an object to perform an action (add a keyword or store a reference) on a companion or settler when the player adds it to their inventory. I've looked at the OnContainerChanged event, but this seems to give an ObjectReference and I can't find a way to check if this is an Actor let alone a potential follower. Is there an easier way to go about this?

Link to comment
Share on other sites

If you would like to check if the old container or new container is an actor in the OnContainerChanged() event then cast them as an actor to check..

Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)
    If (Game.GetPlayer() == akOldContainer) && (akNewContainer As Actor)
        Faction PotentialCompanionFaction = Game.GetFormFromFile(0x001EC1B9, "Fallout4.esm") As Faction
        Bool bIsPotComp = (akNewContainer As Actor).IsInFaction(PotentialCompanionFaction)
        If bIsPotComp
            Debug.Notification("Player Added This Item To A Potential Companion")
        Else
            Debug.Notification("Player Added This Item To A NON Potential Companion")
        EndIf
    EndIf
EndEvent
Link to comment
Share on other sites

  • Recently Browsing   0 members

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