DEATH HOOK

Archive of the older Feature Request Forum Posts

Moderator: POL Developer

Locked
User avatar
OldnGrey
POL Expert
Posts: 657
Joined: Sat Feb 04, 2006 6:26 pm

DEATH HOOK

Post by OldnGrey » Fri Nov 07, 2008 4:46 pm

A while back I thought I had convinced the Devs that a death hook would be a useful thing.
And AUSTIN PROMISED..... "Oldngrey is SO getting his death hook".

/me sits and mentally lists all the cool things you can do with a death hook.

Re-graphic and undo mods. (A real pain currently)
Record their killer.
Refuse them death and do something else with the poor victim.
Do other things to them and THEN allow them death by core.

User avatar
Austin
Former Developer
Posts: 615
Joined: Wed Jan 25, 2006 2:30 am

Re: DEATH HOOK

Post by Austin » Fri Nov 07, 2008 4:50 pm

Fine! I was aiming for retirement, though. I promised that... 2 years ago? Isn't there a statute of limitations on promises?
My ratio of fulfilled promises to unfulfilled was admirable. ¬_¬

Okay lay it out

Function arguments? Should receive the mobile dying?

Some way to make a corpse for the mobile?

Returns 1 the hook handled it. 0 the core uses the code first, then does the usual internal death code?

User avatar
ncrsn
Grandmaster Poster
Posts: 255
Joined: Fri Feb 10, 2006 12:15 am

Re: DEATH HOOK

Post by ncrsn » Fri Nov 07, 2008 4:55 pm

While I see the benefits of this one, I am forced to once again wonder...

Code: Select all

/*
    DamageMobile
    
    Function to use instead of the ApplyDamage-functions.
*/

function DamageMobile( mobile, damage )
    // General checks for invulnerable etc.
    ...
    
    if (GetVital(mobile, "Life") <= damage)
        // Mobile is going to die.
        // Do the death hook stuff:
        // Cancel this if you wish to,
        // amongst other options.
    endif
    
    ...
    // Apply damage as normal
endfunction
Why wouldn't that work as a like?

I can think of couple of reasons why this would be more complex than a solution offered by core, but, it's still already existing solution, has been for years, to me, so I wonder, why the hassle.

Don't get me wrong, in the end I'm fine with all the new features that ease the scripting process.

User avatar
Austin
Former Developer
Posts: 615
Joined: Wed Jan 25, 2006 2:30 am

Re: DEATH HOOK

Post by Austin » Fri Nov 07, 2008 5:14 pm

OldnGrey, you do the engineering

You want a CanDie hook to determine if the mobile can die when the hit points expire?
Or an OnDeath hook when the mobile is dead?

It could be possible to do both in a single one. Methods needed would be

1. A way to make a corpse and optionally equip the mobile's stuff onto the corpse.
2. A way to make a mobile 'dead' and run the death/chrdeath scripts (or make them be run manually..)
3. I need beer

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

Re: DEATH HOOK

Post by OldnGrey » Fri Nov 07, 2008 5:29 pm

I will try.


define the hook in a cfg somewhere.... your call.

when a player is about to die ie hp == 0, the core function is called as it does now. If the hook is present the hook is called with only the mobileref. The player is NOT dead at this point.
If the hook exits with a 1, then the core continues to kill the player and do its thing.
If a 0 is returned, then the core exits and the player is not killed.

I can see we might need to have the mobile hp set to 1 to prevent this from looping forever?

User avatar
Austin
Former Developer
Posts: 615
Joined: Wed Jan 25, 2006 2:30 am

Re: DEATH HOOK

Post by Austin » Fri Nov 07, 2008 6:04 pm

Here is what I am thinking

Code: Select all

use uo;

exported function DeathHook(mobile)
   // Mobile has reached 0 hit points, create a corpse where the mobile is.
   // Strip the equipment from the mobile to the corpse.
   var corpse := CreateCorpseForMobile(mobile, mobile.x, mobile.y, mobile.z, mobile.realm);
   corpse.TakeContentsFromOwner(); // Uses corpse.ownerserial?

   // Make the mobile officially dead (would run death.ecl / chrdeath.ecl scripts?)
   mobile.SetDead(1);

   // tell the core to not do anything else
   return 1;
endfunction

What OldnGrey sorta wants would look like

Code: Select all

exported function DeathHook(mobile)
   return 1;
endfunction

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

Re: DEATH HOOK

Post by OldnGrey » Fri Nov 07, 2008 7:27 pm

I can see the first being trememdously useful.
My needs were specific - ie I really did want to deal with graphics befor they died to stop problems with non-monochrome death screen and not getting priv to walkthrough closed gates etc. And I did want the chance to modify the player in other ways before they died. Then just return control to the core to process death OR simply exit back to the game and deny them death.

But...

Your ideas of being able to actually script the death 'process' ourselves before death/chrdeath is called now has a lot of appeal.

So it's no longer just my idea.... it's open for everyone to offer their thoughts now :)
All you ever promised was a death hook. This is a lot more.
And for all to witness this is Austin promising a death hook:
http://forums.polserver.com/viewtopic.p ... hook#p5639

Yukiko
Distro Developer
Posts: 2728
Joined: Thu Feb 02, 2006 1:41 pm
Location: San Antonio, Texas
Contact:

Re: DEATH HOOK

Post by Yukiko » Fri Nov 07, 2008 11:45 pm

Yukiko Wrote:
I don't get enough fiber in my diet.
I have never seen a "statue of limitations" on anything however I will keep my eyes open for one carved or sculpted on top of a pile of promises.

*grins*

Keep up the good work Austin.

User avatar
Austin
Former Developer
Posts: 615
Joined: Wed Jan 25, 2006 2:30 am

Re: DEATH HOOK

Post by Austin » Sat Nov 08, 2008 11:24 am

Note: Prune board posts more than a month old.
Call it the Espionage Protection Act. Promises lost.

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

Re: DEATH HOOK

Post by OldnGrey » Sat Nov 08, 2008 5:54 pm

I have the sneaking suspicion Austin edits his posts to save his butt. :)

I am more than willing to let Austin mess with my Avatar if it means getting this hook.

User avatar
taxman
Journeyman Poster
Posts: 63
Joined: Tue Apr 18, 2006 11:10 pm

Re: DEATH HOOK

Post by taxman » Mon Nov 10, 2008 2:52 am

Austin wrote:You want a CanDie hook to determine if the mobile can die when the hit points expire?
I'm not OldnGrey but I like this variant of hook.

Yukiko
Distro Developer
Posts: 2728
Joined: Thu Feb 02, 2006 1:41 pm
Location: San Antonio, Texas
Contact:

Re: DEATH HOOK

Post by Yukiko » Tue Nov 18, 2008 1:59 pm

Hey!

No fair editing posts Austin!
*sticks tongue out at you*

Locked