Jump to content

Handling temporarily persistent object?


Recommended Posts

I'm working on a follower framework, and in order to make the sandbox, guard & wait packages work properly, I need to add a LinkedRef to each follower.

 

Now, since the system works at runtime, and you can dismiss/recruit followers at will, I need to create these LinkedRef objects, that are persistent for as long as the player hasn't fired the follower.

 

I've created three functions. One that uses PlaceAtMe() with the persistent flag set to true, another that moves the marker to the follower, and another that deletes it.

 

Making the LinkedRef persistent through PlaceAtMe() is what gives me the jeebies. If it works fine with Delete(), then all is good. But I don't know if that's true, and as far as I can tell, f4se doesn't have a SetPersistent(false) function yet.

 

 

If it's any help, here are the three functions:

Function AddRelaxMarker(Actor akActor)
    
    akActor.SetLinkedRef(akActor.PlaceAtMe(AAAFyTy_FollowerFramework_RelaxMarker, 1, true, false, false), AAAFyTy_FollowerFramework_RelaxMarkerKWRD)

EndFunction

Function MoveRelaxMarker(Actor akActor)
    
    ObjectReference objRelax = akActor.GetLinkedRef(AAAFyTy_FollowerFramework_RelaxMarkerKWRD)
    
    objRelax.MoveTo(akActor)
    
    objRelax = None
    
EndFunction

Function RemoveRelaxMarker(Actor akActor)
    
    ObjectReference objToDelete = akActor.GetLinkedRef(AAAFyTy_FollowerFramework_RelaxMarkerKWRD)

    objToDelete.Disable()
    objToDelete.Delete()

    objToDelete = None
    
EndFunction

One potential workaround is to add the created LinkedRef to a RefCollection alias, but if the script has no issue, then why bother.

 

 

Edit: Decided to go with the RefCollection method. Code was changed to the following:

 

 

Function AddRelaxMarker(Actor akActor)
    
    ObjectReference objRelax = akActor.PlaceAtMe(AAAFyTy_FollowerFramework_RelaxMarker, 1, false, false, false)
    AAAFyTy_FF_RelaxMarkerRefColl01.AddRef(objRelax)
    akActor.SetLinkedRef(objRelax, AAAFyTy_FollowerFramework_RelaxMarkerKWRD)

    objRelax = None

EndFunction

Function MoveRelaxMarker(Actor akActor)
    
    ObjectReference objRelax = akActor.GetLinkedRef(AAAFyTy_FollowerFramework_RelaxMarkerKWRD)
    
    objRelax.MoveTo(akActor)
    
    objRelax = None
    
EndFunction

Function RemoveRelaxMarker(Actor akActor)
    
    ObjectReference objRelax = akActor.GetLinkedRef(AAAFyTy_FollowerFramework_RelaxMarkerKWRD)
    
     AAAFyTy_FF_RelaxMarkerRefColl01.RemoveRef(objRelax)
    
    objRelax.Delete()

    objRelax = None
    
EndFunction
Edited by FiftyTifty
Link to comment
Share on other sites

I found if you remove all the linkedrefs on a marker, disable and then markfordelete or delete it, it will go away. So long as it's not a full property either, otherwise better to just move it back to some persistent cell you would make to house them.

 

I see you've settled for a solution though.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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