@@ -149,7 +149,19 @@ static void thing_killed_by_player(Gamep g, Levelsp v, Levelp l, Thingp me, Thin
149149
150150 if ((it != nullptr ) && thing_is_loggable (me)) {
151151 auto the_thing = capitalize_first (thing_name_long_the (g, v, l, me));
152- auto by_player = thing_name_long (g, v, l, it);
152+
153+ std::string by_player;
154+ auto *player = thing_player (g);
155+ auto *fired_by = thing_fired_by_get (g, v, l, it);
156+ if (fired_by != nullptr ) {
157+ if (fired_by == player) {
158+ by_player = " your " + thing_name_long (g, v, l, it);
159+ } else {
160+ by_player = thing_name_apostrophize_the (g, v, l, fired_by) + " " + thing_name_long (g, v, l, it);
161+ }
162+ } else {
163+ by_player = thing_name_long_the (g, v, l, it);
164+ }
153165
154166 switch (e.event_type ) {
155167 case THING_EVENT_SHOVED : //
@@ -201,15 +213,20 @@ static auto thing_get_killer(Gamep g, Levelsp v, Levelp l, ThingEvent &e) -> Thi
201213 auto *killer = e.source ;
202214
203215 if (killer == nullptr ) {
204- return killer ;
216+ return nullptr ;
205217 }
206218
207219 auto *fired_by = thing_fired_by_get (g, v, l, killer);
208220 if (fired_by != nullptr ) {
209221 return fired_by;
210222 }
211223
212- return thing_owner (g, v, l, killer);
224+ auto owner = thing_owner (g, v, l, killer);
225+ if (owner != nullptr ) {
226+ return owner;
227+ }
228+
229+ return killer;
213230}
214231
215232//
@@ -242,12 +259,14 @@ void thing_dead(Gamep g, Levelsp v, Levelp l, Thingp me, ThingEvent &e)
242259 THING_DBG (me, " %s: dead" , to_string (g, v, l, e).c_str ());
243260 }
244261
262+ auto *killer = thing_get_killer (g, v, l, e);
263+
245264 //
246265 // Call this prior to setting death, else we are told that we killed an already dead thing
247266 //
248267 if (thing_is_player (me)) {
249268 thing_killed_player (g, v, l, me, e);
250- } else if ((e. source != nullptr ) && thing_is_player (e. source )) {
269+ } else if (killer && thing_is_player (killer )) {
251270 thing_killed_by_player (g, v, l, me, e);
252271 }
253272
@@ -393,7 +412,6 @@ void thing_dead(Gamep g, Levelsp v, Levelp l, Thingp me, ThingEvent &e)
393412 //
394413 // Give score bonus to the player
395414 //
396- auto *killer = thing_get_killer (g, v, l, e);
397415 if ((killer != nullptr ) && (killer != me) && thing_is_player (killer)) {
398416 auto bonus = tp_score_value_get (tp);
399417 (void ) thing_score_incr (g, v, l, killer, bonus);
0 commit comments