Move non-persisten character references

Post » Fri Nov 18, 2011 3:35 pm

I am experimenting with ways to move an NPC reference (like a spawned creature) to a holding cell, then move them back to the player a later time.

I have attempted using a persistent reference in the form of a scripted activator to store variables. I use a target spell to get the reference to a creature, and set a reference variable on the persistent object to that reference.

Moving this persistent activator's reference variable to a holding cell seems to work just fine to teleport the correct creature to that cell.

However, when I attempt to move that reference back to the player using MoveTo on the persistent activator's reference it fails, or rather it ignores what I set the reference variable to on my persistent ref and moves the player to the player instead.

I am uncertain how these spawned references are handled. Do they get a new temporary reference assigned every time they change cells? Are they destroyed in three days no matter what?

Is there any way to move a spawned reference to another cell, and later move it back to the player again?

Also, are variables set on a persistent ref stored in a save file, or only globals?
User avatar
luis ortiz
 
Posts: 3355
Joined: Sun Oct 07, 2007 8:21 pm

Post » Fri Nov 18, 2011 4:33 pm

ALL variable contents are saved in the save file. Your problem is not this.

The problem is that when a non-persistent reference goes 'out-of-scope' (either by moving it to an unloaded cell, as you did, or the player leaving the area) all variables holding its FormID are temporarily and artificially set to zero. These variables will remain this way until the reference gets loaded into memory (by the player getting close to it)

In short: you cannot manipulate non-persistent references in unloaded cells.

I can't think of any way of moving it back, short of moving the player to that cell.
User avatar
Lindsay Dunn
 
Posts: 3247
Joined: Sun Sep 10, 2006 9:34 am

Post » Fri Nov 18, 2011 11:14 am

The problem is that when a non-persistent reference goes 'out-of-scope' (either by moving it to an unloaded cell, as you did, or the player leaving the area) all variables holding its FormID are temporarily and artificially set to zero. These variables will remain this way until the reference gets loaded into memory (by the player getting close to it)

In short: you cannot manipulate non-persistent references in unloaded cells.

I can't think of any way of moving it back, short of moving the player to that cell.

I see, thanks. Well, that makes sense now at least. Somewhat dashes once again my hopes of a true "tame anything you can kill" companion mod.

I am wondering now though, when you say all variables holding it's FormID are set to zero, do you mean that the activator I used to store it's reference is also getting those variables set to zero?

If the player does go to the cell they were moved to, does the reference become available as the same reference it was before? I am assuming it is some derivative of the BaseID?
User avatar
Cathrine Jack
 
Posts: 3329
Joined: Sat Dec 02, 2006 1:29 am

Post » Fri Nov 18, 2011 10:31 am

So I was testing moving a marker rat to the player, moving the player to the test cell where the non-persistent creature was sent, then from there moving that creature to the marker rat, then the player back to the marker rat. It seemed like it might work, though MoveTo has some weirdness, and I would have to hammer out the useage to avoid CTD or getting stuck in the test cell. Plus the weather would have changed and you have to wait through loading menus whenever you re-summon your pet. Not exactly ideal...

Then I realized it was pretty moot being even if it did work reliably there would still be the issue of pets following you through cell changes. Like if you entered a dungeon, I am guessing that would count as the reference going "out of scope," so there wouldn't really be a way to have them come in with you.
User avatar
Manny(BAKE)
 
Posts: 3407
Joined: Thu Oct 25, 2007 9:14 am

Post » Fri Nov 18, 2011 1:40 pm

The variables with the FormIDs of out of scope refs are not actually set to zero. As far as I can figure it, when you use it, the engine checks where the reference is at the moment. (you can check it yourself with http://cs.elderscrolls.com/constwiki/index.php/IsFormValid)

If not in memory the engine returns zero, but the variable still holds the proper FormID (you can even see it with http://cs.elderscrolls.com/constwiki/index.php/GetRawFormIDString )

When the reference is loaded (as when the player goes to the same cell) the engine returns the FormID stored in the variable.

This limitation does not apply to persistent references, of course, as these are always in memory, regardless of whether its cell is loaded or not.


As for when the player changes cells, the previous cell remains in memory for a while, so non-persistent references inside will not go out of scope immediately. The cell will be unloaded when the engine needs to reuse the memory it occupies. (there will be a problem with computers with very small memories. ABO determined, some time ago, that in these systems, the cell just left is unloaded immediately)
User avatar
Johnny
 
Posts: 3390
Joined: Fri Jul 06, 2007 11:32 am

Post » Fri Nov 18, 2011 8:51 am

I'd suggest you forget the idea of the adopted creature being the exact one, and just put one of everything (with its own persistent reference) in the holding cell. When you "convert" a creature, swap it for the matching one and let the original reset itself out of existence.
User avatar
sw1ss
 
Posts: 3461
Joined: Wed Nov 28, 2007 8:02 pm

Post » Fri Nov 18, 2011 4:58 pm

I'd suggest you forget the idea of the adopted creature being the exact one, and just put one of everything (with its own persistent reference) in the holding cell. When you "convert" a creature, swap it for the matching one and let the original reset itself out of existence.

Yeah, that's more or less how I did it for Master Summon. I had a cell with copies of every creature on the list as persistent refs, and just called them to the player and sent them back as appropriate. No save bloat that way either.

It was just a lot of work, because every creature needs its own variables and menu scripts. I was kinda going for a catch-all to bring in mods like WAC and such, without all the extra scripting and compatibility patches.

No worries though, I'll have plenty to keep me busy translating the latest OWCND. Thanks for the help and suggestions! :)
User avatar
herrade
 
Posts: 3469
Joined: Thu Apr 05, 2007 1:09 pm


Return to IV - Oblivion