diff --git a/src/doom/p_inter.c b/src/doom/p_inter.c index 15e0729827..cbc1968a78 100644 --- a/src/doom/p_inter.c +++ b/src/doom/p_inter.c @@ -742,11 +742,36 @@ P_KillMobj if (target->player) source->player->frags[target->player-players]++; } - else if (!netgame && (target->flags & MF_COUNTKILL) ) + else if (target->flags & MF_COUNTKILL) { // count all monster deaths, // even those caused by other monsters - players[0].killcount++; + if (!netgame) + { + players[0].killcount++; + } + else // netgame + { + if (!deathmatch) + { + if (target->lastenemy && target->lastenemy->health > 0 && target->lastenemy->player) + { + target->lastenemy->player->killcount++; + } + else + { + // add kill to first player who is still ingame + for (unsigned int plridx = 0; plridx < MAXPLAYERS; plridx++) + { + if (playeringame[plridx]) + { + players[plridx].killcount++; + break; + } + } + } + } + } } if (target->player) @@ -976,6 +1001,10 @@ P_DamageMobj { // if not intent on another player, // chase after this one + if ( !target->lastenemy || target->lastenemy->health <= 0 + || !target->lastenemy->player) + target->lastenemy = target->target; + target->target = source; target->threshold = BASETHRESHOLD; if (target->state == &states[target->info->spawnstate] diff --git a/src/doom/p_mobj.c b/src/doom/p_mobj.c index 53a1d600d6..f3cf95b653 100644 --- a/src/doom/p_mobj.c +++ b/src/doom/p_mobj.c @@ -680,6 +680,8 @@ P_SpawnMobjSafe mobj->oldz = mobj->z; mobj->oldangle = mobj->angle; + mobj->lastenemy = NULL; + // [crispy] height of the spawnstate's first sprite in pixels if (!info->actualheight) { diff --git a/src/doom/p_mobj.h b/src/doom/p_mobj.h index 87f1a25113..e00929829b 100644 --- a/src/doom/p_mobj.h +++ b/src/doom/p_mobj.h @@ -293,6 +293,9 @@ typedef struct mobj_s fixed_t oldz; angle_t oldangle; + // last known enemy + struct mobj_s* lastenemy; + } mobj_t;