Jump to content

Using OnCellDetach to remove ObjectReference : Is this the Preferred Way?


tamtastic

Recommended Posts

Hello All,

 

I have a spell that melts bodies into a puddle of goo, thus revealing the skull of the body. Normally the puddle of goo despawns pretty quickly when in an exterior space, but it can persist in interior spaces that are visited frequently. There can be many gelatinous puddles at a time. A user asked me about this as well. Upon some reflecting, I have decided I want to add a script that will "Evaporate" the gelatinous puddles once the cell is no longer in use.

 

I am testing the following script that is attached to the gelatinous goo, and it does despawn that object reference as soon as the cell is unloaded.

 

It works, but is this a good/safe way of doing it?

Scriptname dw02EvaporateGelatinousGoo extends ObjectReference  
; ====== Events
Event OnUnLoad()
   disable()
   deletewhenable()
endEvent
	
Event OnCellDetach()
  disable()
  deletewhenable()
EndEvent

Thank you for any thoughts or feedback.

 

This is the mod, btw:

https://www.nexusmods.com/skyrimspecialedition/mods/58248

Edited by tamtastic
Link to comment
Share on other sites

Seems to have been a topic of debate over the years. Personally I avoid deleting actors unless I spawned them at runtime and know they arent tied to anything. The real issue is when you purge a ref the game expects to be there later, even if dead. Just has a way of being able to screw up aliases, quests, and in some cases, spawning systems

 

In short its most likely safe most of the time so long as it isnt someone unique or otherwise important to the game

 

SetCriticalStage() is often seen as an alternative and bestTM practice to use for sanitizing refs

Link to comment
Share on other sites

  • Recently Browsing   0 members

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