Death hook & CreateCorpseFrom function

Archive of the older Feature Request Forum Posts
Locked
neizarr
Neophyte Poster
Posts: 30
Joined: Thu Dec 07, 2006 11:33 pm

Death hook & CreateCorpseFrom function

Post by neizarr »

It would be useful to be able to intercept death of any given mobile(PCs and NPCs) just before the mobile actually dies, and be able to cancel death from occurring.

Also, it would be useful to have a way to create a corpse from any given mobile, perhaps with the ability to specify the graphic to use for the corpse. Corpse creation would entail creating the given corpse, and moving all items worn by the mobile to it as if it was actually killed, though hair and beards would be copied instead of moved.

The first is useful if you want to do unique custom things with a NPC that maybe other shards don't typically want to do. For many of my NPCs I have numerous cprops on other items and mobiles that reference that NPC via it's serial, and we (like many shards) have a "knock out" system, but one that is in place for NPCs as well as PCs. NPCs for instance can be healed and woken up, just like players can be. Presently this is accomplished with creating a new NPC that is given the same skills stats, etc as the old one that died by saving that information to the corpse before death, but the one serious impact that it has for a NPC's death is that the serial changes, and other mechanisms on the shard which are set up to operate off that given NPC and reference it via serial, are all messed up because the NPC is getting a new serial. If a hook were present such that I could return 0 from it to specify the NPC actually dies, or return a positive value from it to specify it doesn't die and the # of hps it is given to stay alive, then that would be great and I could handle the rest in that script(move the npc to some npc heaven, restart it to stop it from any fighting it is doing, use the CreateCorpseFrom function to create a corpse from it at the location it was supposed to die at).

This could be useful I believe to others as well for various types of death systems that might work better and easier if they had some way to control death and how it actually happens, including preventing it altogether. Also various damage systems could be implimented which use this ability to override death and make for some alternative course of action once you go to 0 hps.

Hopefully this can be done fairly easily, it would be really handy for me at least, and I'm sure others could find a use for it too. Some NPCs you don't want to have lose their serial just because they die.
Marilla

Post by Marilla »

The idea of a Death Hook has already been discussed here, at length. If you want to find the discussion, do a search for it. I'd do the search for it, but if you're gonna be too lazy to search for it, so am I :razz:
neizarr
Neophyte Poster
Posts: 30
Joined: Thu Dec 07, 2006 11:33 pm

Post by neizarr »

Thanks, I read over it. I think I'm suggesting the same thing as was mentioned there, though nothing so esoteric as trying to change what death means. I just want the ability to pre-empt death from happening once the mobile reaches 0 hps and the ability to have a function to create a corpse from any given mobile just as if they had died.
User avatar
OldnGrey
POL Expert
Posts: 657
Joined: Sat Feb 04, 2006 6:26 pm

Post by OldnGrey »

The suggestion that Austin eventually agreed to do sometime in 098 was to have a hook that you could script that could refuse death and script something else, or let the core handle it normally.

As an aside this also lets us elegantly handle death when my character graphic is not 401 or 400.

Bring on 098.
User avatar
OldnGrey
POL Expert
Posts: 657
Joined: Sat Feb 04, 2006 6:26 pm

Post by OldnGrey »

Austin,
This is the death hook we were discussing.

Also see http://forums.polserver.com/viewtopic.p ... death+hook

*waves arms around*
Here it is!
Locked