Death interception (i.e. keeping the player from being killed) requires the use of several tricks. Also there is a problem if more than one mod tried to do death interception at the same time. Accordingly, Cobl provides a centralized death handling facility to handle the mechanics and sort out conflicts between would-be death handlers.
The central death handling utility is the cobMortQ quest/script. For mods to make use of this, they must:
- Set fEssentialHealthPercentRegain to 0. This must be done in the mod or death handling will not work!
- Create a quest script which registers as either or real or fake death handler with cobMortQ.
- Note: since only one death handler script can be registered at a time, an attempt to register may fail.
- Once successfully registered, watch for cobMortQ.state to equal 20. At that point do you death handling thing.
- If you do it quickly enough, just set cobMortQ.state to 30 when done.
- If youre death handling will take a while (e.g., if it takes you a while to an afterlife realm), you should keep setting wrMortQ.timer to -10, until you're ready to re-enter normal life. At that point set cobMortQ.state to 30.
- Note that when active (after successfully registering your script), you'll need to set fQuestDelayTime for your quest script to 1 second or better. (0.25 seconds is recommended.)
- For more info, see cobMortQS and cobMortTestQS scripts.
- Auto De-registration
- When registering your death handler, you need to set the appropriate token ref to a reference. This reference must be a permanent ref that belongs to your mod! The reason for doing this is that if the user deactivates your mod, then the token ref will become equal to 0 in gameplay. Hence, deactivating the mod will auto-deregister it.
- Note that if, instead of using a ref owned by your mod, you used one owned by Oblivion.esm, this auto-deregistration would not occur.
- See Extras\Cobl Mort Demo.esp for a fairly simple example.
- Just move mod to Data directory and activate it -- it will start running immediately. To de-activate it, just de-activate the mod.
- For a slightly more complicated example, see Wrye Shivering Death.
- In this mod, the cobMortQ.stage is forced to stay at state 20 until the player exits the "afterlife" realm.