Page 1 of 1

on_pre_player_died/on_player_died cause

Posted: Thu Aug 04, 2016 3:25 am
by DaCyclops
Is it possible to return the entity and force that "caused" the death when a player dies (or pre-dies)? I would love to be able to perform something based on the identify of the killer (and some other crazy things) when someone dies. I have a couple of ideas revolving around player death, and they would work best if I could actually tell WHY someone died.

Something like returning "poison-capsule" belonging to "(lua table for player force)" if you poison yourself to death, or "big-worm" belonging to "(lua table for biter force)" if you dont run away quick enough from the big worms. or "droid-smg" belonging to "(lua table for player force)" if you accidentally piss off your Robot Army assistants.....

Re: on_pre_player_died/on_player_died cause

Posted: Thu Aug 04, 2016 7:14 am
by Rseding91
The killing entity isn't always known when something dies. There also isn't always a killing entity around anymore when something dies.

So.. maybe but not likely.

Re: on_pre_player_died/on_player_died cause

Posted: Thu Aug 04, 2016 9:35 am
by DaveMcW
You can hack around it by tracking the last hit in the on_entity_damaged event. (Which is itself a hack... fun times!)

Re: on_pre_player_died/on_player_died cause

Posted: Thu Aug 04, 2016 10:20 am
by Rseding91
DaveMcW wrote:You can hack around it by tracking the last hit in the on_entity_damaged event. (Which is itself a hack... fun times!)
There is no on entity damaged event.

Re: on_pre_player_died/on_player_died cause

Posted: Fri Aug 05, 2016 12:24 am
by DaCyclops
Methinks he means on_entity_died... if there was an "on_entity_damaged" it could lead to the BEST lag generation...


You have a point. Ive been killed by now-dead Worms before. And technically, killing yourself with fire WOULD be a now-dead entity killing you... :P

Maybe if instead of passing the actual Entity table, it passed a table that was {attack_source = "medium-spitter", attack_force = "biters" } of the entity that used the attack? Maybe the entity table could be an optional additional value IF the entity is still alive, or nil if dead.