Jump to content

[modding] moving objects and dead NPCs off-cell


Recommended Posts

Posted

Hi,

 

I am working on a mechanism to save some objects (statics) and dead NPCs into a json file (object base and location) then restore them from the json. Purpose is to give the mod users the option to restore these objects after cleaning their saves for mod version update.

 

- json storing and data retrieval works fine

- spawning the saved actors and objects works fine in the cell the player is calling the function from

- what is not working is moving the objects to their original cell

 

Meaning that this:

 

victim_ref.setposition(victim_x[victim_i], victim_y[victim_i], victim_z[victim_i])

 

works just fine if x, y, z are in the current cell; if they belong to a different cell, the spawns disappear from their spawn location (the player) and never "reach" the destination position

 

Trying the same thing using a marker doesn't work either

 

    objectreference gallow_ref = player.placeatme(gallow_base[gallow_i])
    objectreference marker_ref = player.placeatMe(Game.GetFormFromFile(0x00000034, "Skyrim.esm"))    ; marker variant 
    marker_ref.setposition(gallow_x[gallow_i], gallow_y[gallow_i], gallow_z[gallow_i])
    marker_ref.setangle(0, 0, gallow_z_angle[gallow_i])
    gallow_ref.moveto(marker_ref)
    utility.wait(0.5)
    marker_ref.delete()

 

Objects spawn then disappear, never reaching their intended placement.

 

The only other idea I guess would be to keep track of distinct cells to repopulate, teleport the player to each cell sequentially, and run the spawns locally, but it sounds very CTD-prone - the centeroncell documentation warns of crashes and suggests moveto instead

 

Any other solutions?

 

Thx

 

Posted

If I get you right, your issue is that you cant spawn objects in Cells that arent currently loaded? 

SetPosition X/Y/Z isnt working because each Worldspace has their own X/Y/Z coordinates. Meaning a Coordinate 42/13/17 in Tamriel is not equal to the Position 42/13/17 in Blackreach etc

 

Does your mod care if the objects are there right away or na? 

Cant you just save the specific Cell ID in the json and check if the cell ID is present everytime the player changes a cell and if so, place the objects when the player loads the cell?

Posted
13 minutes ago, Scrab said:

If I get you right, your issue is that you cant spawn objects in Cells that arent currently loaded? 

 

Correct

 

Quote

SetPosition X/Y/Z isnt working because each Worldspace has their own X/Y/Z coordinates. Meaning a Coordinate 42/13/17 in Tamriel is not equal to the Position 42/13/17 in Blackreach etc

 

I had no idea about this

 

Quote

Does your mod care if the objects are there right away or na? 

 

No, I guess not

 

Quote

Cant you just save the specific Cell ID in the json and check if the cell ID is present everytime the player changes a cell and if so, place the objects when the player loads the cell?

 

Yep, I think that's the proper way to handle this. I'll need to look into jsonutil for a function which alters values (set some flag to each saved object whether it's already been re-built), but other than that yes, I think this is the right approach

 

Thanks!

Archived

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

  • Recently Browsing   0 members

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