Jump to content

Reappearing, respawning items


mcneifen

Recommended Posts

There seems to be a bug with a mod I'm tinkering with that causes items to reappear in a cell. The mod creates them using:

Obj = ...PlaceAtMe(ItemForm,1,FALSE,TRUE)
Obj.SetPosition(...)
Obj.Enable()
Obj.SetActorOwner(...Player.GetActorBase())

I pick the objects up in the conventional manner, leave the cell a ways, and then return to find duplicated items laying on the ground.

 

What is causing this to occur? What might be a potential remedy?

 

Is object "persistence" part of the issue? Could .Delete() or .DeleteWhenAble() help resolve this? Is there a garbage-collection trick that could be invoked so that designated items when picked up do not respawn?

 

Note that these items respawn relatively quickly, within a few in-game hours. It is on a different schedule than the usual cell reset.

Link to comment
Share on other sites

PlaceAtMe will always create a new instance. Limiting when it is called will reduce the frequency. If say it were called from the OnCellAttach event, it could invariably produce a new instance almost every time you visit that cell. If instead OnCellLoad were used, then it may only produce a new instance after the cell has been flushed from memory and needs to be loaded again. But that is all speculation at this time. Perhaps others might know a bit more...

Link to comment
Share on other sites

The lines of code I quoted can be traced to a UIExtensions menu event trigger, rather than OnCellAttach. It's in a script that extends ActiveMagicEffect. But the frequency does match OnCellAttach. I have noticed that I have to leave a few cells away in order for the items to respawn.

 

That said, if the items are already present on the ground, more are not summoned. Only if they are picked up do they respawn.

 

Besides the issue of littering, I am afeared this will eventually tank my save file(s).

Link to comment
Share on other sites

Adding to the above, I am noticing that the PlaceAtMe command is not what is creating the respawned items (A debugging message would've appeared). It's as if the cell has reprogrammed itself that they should be there.

Link to comment
Share on other sites

MarkForDelete with the console seems to be working in-game, preventing the items from reappearing. What I'd like to do, however, is to write a script such as:

OnCellAttach()

     scan cell for all of X form
     
     foreach form
          MarkForDelete each instance of that form

Now, how do I convert that pseudocode to papyrus?

 

Bonus points if it only uses MarkForDelete on objects with dynamically-allocated object references (i.e. the ones starting with "ff"). Since that is what the troublesome PlaceAtMe function is generating, that means I can clean those up without deleting the objects that are meant to be there.

Edited by mcneifen
Link to comment
Share on other sites

  • Recently Browsing   0 members

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