on_pre_player_died/on_player_died cause

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
User avatar
DaCyclops
Long Handed Inserter
Long Handed Inserter
Posts: 85
Joined: Mon Aug 25, 2014 12:37 am
Contact:

on_pre_player_died/on_player_died cause

Post 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.....

Rseding91
Factorio Staff
Factorio Staff
Posts: 13209
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: on_pre_player_died/on_player_died cause

Post 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.
If you want to get ahold of me I'm almost always on Discord.

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: on_pre_player_died/on_player_died cause

Post 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!)

Rseding91
Factorio Staff
Factorio Staff
Posts: 13209
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: on_pre_player_died/on_player_died cause

Post 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.
If you want to get ahold of me I'm almost always on Discord.

User avatar
DaCyclops
Long Handed Inserter
Long Handed Inserter
Posts: 85
Joined: Mon Aug 25, 2014 12:37 am
Contact:

Re: on_pre_player_died/on_player_died cause

Post 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.

Post Reply

Return to “Modding interface requests”