diff --git a/src/k_kart.c b/src/k_kart.c index 5566f2c50..1bf599fc7 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -4766,7 +4766,7 @@ void K_RepairOrbitChain(mobj_t *orbit) } // Then recount to make sure item amount is correct - if (orbit->target && orbit->target->player) + if (orbit->target && orbit->target->player) // !P_MobjWasRemoved(orbit->target) { INT32 num = 0; diff --git a/src/p_inter.c b/src/p_inter.c index 30cf829a1..3266f820f 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -1462,48 +1462,11 @@ boolean P_CheckRacers(void) return false; } -/** Kills an object. - * - * \param target The victim. - * \param inflictor The attack weapon. May be NULL (environmental damage). - * \param source The attacker. May be NULL. - * \todo Cleanup, refactor, split up. - * \sa P_DamageMobj - */ -void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) +static void P_UpdateRemovedOrbital(mobj_t *target, mobj_t *inflictor, mobj_t *source) { - mobjtype_t item; - mobj_t *mo; - int ms; - - if (target->flags & (MF_ENEMY|MF_BOSS)) - target->momx = target->momy = target->momz = 0; - - // SRB2kart - if (target->type != MT_PLAYER && !(target->flags & MF_MONITOR) - && !(target->type == MT_ORBINAUT || target->type == MT_ORBINAUT_SHIELD - || target->type == MT_JAWZ || target->type == MT_JAWZ_DUD || target->type == MT_JAWZ_SHIELD - || target->type == MT_BANANA || target->type == MT_BANANA_SHIELD - || target->type == MT_EGGMANITEM || target->type == MT_EGGMANITEM_SHIELD - || target->type == MT_BALLHOG || target->type == MT_SPB)) // kart dead items - target->flags |= MF_NOGRAVITY; // Don't drop Tails 03-08-2000 - else - target->flags &= ~MF_NOGRAVITY; // lose it if you for whatever reason have it, I'm looking at you shields - // - - if (target->flags2 & MF2_NIGHTSPULL) - P_SetTarget(&target->tracer, NULL); - - // dead target is no more shootable - target->flags &= ~(MF_SHOOTABLE|MF_FLOAT|MF_SPECIAL); - target->flags2 &= ~(MF2_SKULLFLY|MF2_NIGHTSPULL); - target->health = 0; // This makes it easy to check if something's dead elsewhere. - - if (LUA_HookMobjDeath(target, inflictor, source) || P_MobjWasRemoved(target)) - return; - // SRB2kart // I wish I knew a better way to do this + //if (!P_MobjWasRemoved(target->target) && target->target->player && !P_MobjWasRemoved(target->target->player->mo)) if (target->target && target->target->player && target->target->player->mo) { if (target->target->player->kartstuff[k_eggmanheld] && target->type == MT_EGGMANITEM_SHIELD) @@ -1517,7 +1480,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) { if (target->movedir != 0 && target->movedir < (UINT16)target->target->player->kartstuff[k_itemamount]) { - if (target->target->hnext) + if (target->target->hnext) // !P_MobjWasRemoved(target->target->hnext)) K_KillBananaChain(target->target->hnext, inflictor, source); target->target->player->kartstuff[k_itemamount] = 0; @@ -1546,14 +1509,60 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) P_SetTarget(&target->target->hnext, NULL); } } - // Above block does not clean up rocket sneakers when a player dies, so we need to do it here target->target is null when using rocket sneakers +} + + +/** Kills an object. + * + * \param target The victim. + * \param inflictor The attack weapon. May be NULL (environmental damage). + * \param source The attacker. May be NULL. + * \todo Cleanup, refactor, split up. + * \sa P_DamageMobj + */ +void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) +{ + mobjtype_t item; + mobj_t *mo; + int ms; + + if (target->flags & (MF_ENEMY|MF_BOSS)) + target->momx = target->momy = target->momz = 0; + + // SRB2kart + if (target->type != MT_PLAYER + && !(target->flags & MF_MONITOR) + && !(target->type == MT_ORBINAUT || target->type == MT_ORBINAUT_SHIELD + || target->type == MT_JAWZ || target->type == MT_JAWZ_DUD || target->type == MT_JAWZ_SHIELD + || target->type == MT_BANANA || target->type == MT_BANANA_SHIELD + || target->type == MT_EGGMANITEM || target->type == MT_EGGMANITEM_SHIELD + || target->type == MT_BALLHOG || target->type == MT_SPB)) // kart dead items + target->flags |= MF_NOGRAVITY; // Don't drop Tails 03-08-2000 + else + target->flags &= ~MF_NOGRAVITY; // lose it if you for whatever reason have it, I'm looking at you shields + // + + if (target->flags2 & MF2_NIGHTSPULL) + P_SetTarget(&target->tracer, NULL); + + // dead target is no more shootable + target->flags &= ~(MF_SHOOTABLE|MF_FLOAT|MF_SPECIAL); + target->flags2 &= ~(MF2_SKULLFLY|MF2_NIGHTSPULL); + target->health = 0; // This makes it easy to check if something's dead elsewhere. + + if (LUA_HookMobjDeath(target, inflictor, source) || P_MobjWasRemoved(target)) + return; + + P_UpdateRemovedOrbital(target, inflictor, source); + if (target->player) + { + // Above block does not clean up rocket sneakers when a player dies, so we need to do it here target->target is null when using rocket sneakers K_DropRocketSneaker(target->player); - // Let EVERYONE know what happened to a player! 01-29-2002 Tails - if (target->player && !target->player->spectator) - { - target->flags2 &= ~MF2_DONTDRAW; + // Let EVERYONE know what happened to a player! 01-29-2002 Tails + if (!target->player->spectator) + target->flags2 &= ~MF2_DONTDRAW; } // if killed by a player @@ -1563,6 +1572,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) { P_SetTarget(&target->target, source); source->player->numboxes++; + if (cv_itemrespawn.value && (netgame || multiplayer)) { target->fuse = cv_itemrespawntime.value*TICRATE + 2; // Random box generation @@ -1580,35 +1590,41 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) target->player->playerstate = PST_DEAD; - if (cv_fading.value && P_IsLocalPlayer(target->player)) + if (P_IsLocalPlayer(target->player)) { - if (netgame || multiplayer) - ms = cv_respawntime.value * 1000; - else - ms = 1000; + if (cv_fading.value) + { + if (netgame || multiplayer) + ms = cv_respawntime.value * 1000; + else + ms = 1000; - /* - If the time spent with the music paused is less than half - a second, continue playing the song (just mute it). - */ - if ((ms - cv_respawnfademusicout.value) < 500) - S_FadeMusic(0, cv_respawnfademusicout.value); - else - S_FadeOutStopMusic(cv_respawnfademusicout.value); - } + /* + * If the time spent with the music paused is less than half + * a second, continue playing the song (just mute it). + */ + if ((ms - cv_respawnfademusicout.value) < 500) + S_FadeMusic(0, cv_respawnfademusicout.value); + else + S_FadeOutStopMusic(cv_respawnfademusicout.value); + } - for (UINT8 i = 0; i <= splitscreen; i++) - { - if (target->player == P_GetLocalPlayerForNum(i)) + if (target->player == &players[consoleplayer]) { // don't die in auto map, // switch view prior to dying - if (i == 0 && automapactive) + if (automapactive) AM_Stop(); + } - // added : 22-02-98: recenter view for next life... - localaiming[i] = 0; - break; + for (UINT8 i = 0; i <= splitscreen; i++) + { + if (target->player == P_GetLocalPlayerForNum(i)) + { + // added : 22-02-98: recenter view for next life... + localaiming[i] = 0; + break; + } } }