Dealing with characters and corpses
Posted: Thu Jan 20, 2022 12:17 am
I've lately developed a morbid interest in corpses (especially corpses of characters) and want to know as much as possible about them.
But there are some limitations that make it impossible to get the data I need:
Usually, a character will be connected to a player. When a player is killed,
But characters are not necessarily connected to a player. They could be completely independent entities (these are not relevant in my case, just mentioning them for the sake of completeness), and they may also be associated with a player. I want to get character.associated_player, but there is no way to do that:
In my opinion, it would be best if the problem was solved in vanilla. I've several ideas:

Usually, a character will be connected to a player. When a player is killed,
- on_pre_player_ died,
- on_player_ died,
- on_entity_ died, and
- on_post_entity_ died
But characters are not necessarily connected to a player. They could be completely independent entities (these are not relevant in my case, just mentioning them for the sake of completeness), and they may also be associated with a player. I want to get character.associated_player, but there is no way to do that:
- on_player_died won't be triggered when an associated character dies.
- In on_entity_died, both entity.player and entity.associated_player are nil.
- From on_post_entity_died, one could get corpse.character_corpse_player_index, but there is no equivalent for associated players.
In my opinion, it would be best if the problem was solved in vanilla. I've several ideas:
- Add corpse.character_corpse_associated_player_index (on_post_entity_died). This seems to be the easiest way.
- Raise on_entity_died before on_player_died. Hopefully, this would preserve entity.player and entity.associated_player, but it could have unintended effects.
- Add a new event on_pre_entity_died, which would be raised before on_player_died.
- Add new events on_player_associated_character and on_player_disassociated_character.