Jump to content

Using a PlaceAtMe reference as a LinkedReference?


Recommended Posts

I've got a companion framework, and currently, the packages use "Near Current Location". But that is a problem, as the NPCs using the package seem to veer off-course after being reloaded a bunch of times. And since these NPCs are created at run-time, I can't exactly prepare the markers in advance. Or I could, but that would be a colossal pain in the butt to script, as I'd have to keep track of every NPC that gets added, dies, has their package changed, etc.

 

So I figured I'd create a marker on the fly, and have that set as a linked reference. But that just doesn't seem to work.

 

Here's the block that makes the initial marker:

 

 

    
    if iWait == 1
    
        let iButton := GetButtonPressed
        if iButton == 0
            let refSpawn := Player.PlaceAtMe AAAFyTyEyebotCombat
            let refLinkedMarker := Player.PlaceAtMe AAAFyTyCompanionMarker
            refSpawn.SetLinkedReference refLinkedMarker
            let iWait := 0
            Dispel AAAFyTyRoboticianEyebotKit
        elseif iButton == 1
            let refSpawn := Player.PlaceAtMe AAAFyTyEyebotOutcast
            let refLinkedMarker := Player.PlaceAtMe AAAFyTyCompanionMarker
            refSpawn.SetLinkedReference refLinkedMarker
            let iWait := 0
            Dispel AAAFyTyRoboticianEyebotKit
        endif
        
    endif
    
End

 

Now, no error is thrown when that is done. But if I later try to get the spawned link reference, like so:

 

 

let refLinkedRef := refSpawn.GetLinkedRef

 

A null reference will be returned. Is there a way around this?

Link to comment
Share on other sites

As these are companions, and presumably the "near current location" is "current location of Player", have you considered giving the Player a "token" as the named persistent reference marker, and bring them to that?

 

Also, recall that dynamically spawned Actor AI packages are only processed when in cells that are currently loaded into memory. See also the 'Tip Best Practice Avoiding Save Game Bloat' under the "Scripting" section, and the several AI related Tips (such as 'TIP AI Packages and Distance') under the "Custom NPCs" section of the wiki "Getting started creating mods using GECK" article.

 

-Dubious-

Link to comment
Share on other sites

As these are companions, and presumably the "near current location" is "current location of Player", have you considered giving the Player a "token" as the named persistent reference marker, and bring them to that?

 

Also, recall that dynamically spawned Actor AI packages are only processed when in cells that are currently loaded into memory. See also the 'Tip Best Practice Avoiding Save Game Bloat' under the "Scripting" section, and the several AI related Tips (such as 'TIP AI Packages and Distance') under the "Custom NPCs" section of the wiki "Getting started creating mods using GECK" article.

 

-Dubious-

 

Actually, the "Near current location" selection in packages refers to the NPC that has the package, not the player. For a package to use the player's position, you choose "Near Reference" and select the PlayerRef entry from any cell.

 

It's a shame about PlaceAtMe actors only being processed in unloaded cells, as that does affect their follow package. A solution to that is rather easy though, I just have to hook the OnCellEnter event and run HasLoaded3D for the followers, which I assume I can do by adding them to an array, and then passing that array to the event handler.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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