From 2a4a0f24d436e6ef466ddadae421c1a0631a0dd6 Mon Sep 17 00:00:00 2001 From: Sryder Date: Tue, 13 Mar 2018 10:40:02 +0000 Subject: [PATCH] Fix Bombs Use reactiontime instead of health so chain reactions can occur when multiple bombs are layered. Make the check for nearby players happen BEFORE the spawning of explosion objects. Remove MF_NOCLIPTHING and MF_MISSILE from bombs so they don't try and die when they hit the floor sometimes. --- src/info.c | 6 +++--- src/p_enemy.c | 26 ++++++++++++++------------ src/p_mobj.c | 12 +++++++++--- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/src/info.c b/src/info.c index 23bdee72..f7b6fed7 100644 --- a/src/info.c +++ b/src/info.c @@ -14924,10 +14924,10 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { // MT_BOMBITEM -1, // doomednum S_BOMBAIR, // spawnstate - 105, // spawnhealth + 1, // spawnhealth S_NULL, // seestate sfx_tossed, // seesound - 8, // reactiontime + 105, // reactiontime sfx_None, // attacksound S_NULL, // painstate 288*FRACUNIT, // painchance @@ -14944,7 +14944,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 100, // mass 1, // damage sfx_bomb, // activesound - MF_BOUNCE|MF_NOCLIPTHING|MF_MISSILE|MF_SHOOTABLE, // flags + MF_BOUNCE|MF_SHOOTABLE, // flags S_NULL // raisestate }, diff --git a/src/p_enemy.c b/src/p_enemy.c index 9767edbc..788cafa1 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -8273,20 +8273,11 @@ void A_BobombExplode(mobj_t *actor) type = (mobjtype_t)locvar1; - for (d = 0; d < 16; d++) - K_SpawnKartExplosion(actor->x, actor->y, actor->z, actor->info->painchance + 32*FRACUNIT, 32, type, d*(ANGLE_45/4), true, false, actor->target); // 32 <-> 64 - - if (actor->target->player) - K_SpawnBobombExplosion(actor, actor->target->player->skincolor); - else - K_SpawnBobombExplosion(actor, SKINCOLOR_RED); - - P_SpawnMobj(actor->x, actor->y, actor->z, MT_BOMBEXPLOSIONSOUND); - - //S_StartSound(actor, sfx_prloop); - for (th = thinkercap.next; th != &thinkercap; th = th->next) { + if (P_MobjWasRemoved(actor)) + return; // There's the possibility these can chain react onto themselves after they've already died if there are enough all in one spot + if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; @@ -8313,6 +8304,17 @@ void A_BobombExplode(mobj_t *actor) continue; } } + + for (d = 0; d < 16; d++) + K_SpawnKartExplosion(actor->x, actor->y, actor->z, actor->info->painchance + 32*FRACUNIT, 32, type, d*(ANGLE_45/4), true, false, actor->target); // 32 <-> 64 + + if (actor->target && actor->target->player) + K_SpawnBobombExplosion(actor, actor->target->player->skincolor); + else + K_SpawnBobombExplosion(actor, SKINCOLOR_RED); + + P_SpawnMobj(actor->x, actor->y, actor->z, MT_BOMBEXPLOSIONSOUND); + return; } //} diff --git a/src/p_mobj.c b/src/p_mobj.c index 3f7ffb88..353f7844 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -7970,17 +7970,23 @@ void P_MobjThinker(mobj_t *mobj) case MT_BOMBITEM: if (mobj->momx || mobj->momy) P_SpawnGhostMobj(mobj); - if (mobj->z <= mobj->floorz) + if (P_IsObjectOnGround(mobj)) { - if (mobj->health > mobj->info->spawnhealth-1) + if (mobj->reactiontime >= mobj->info->reactiontime) { if (mobj->state == &states[S_BOMBAIR]) P_SetMobjState(mobj, S_BOMBITEM); mobj->momx = mobj->momy = 0; S_StartSound(mobj, mobj->info->activesound); + mobj->reactiontime--; } - mobj->health--; + } + if (mobj->reactiontime && mobj->reactiontime < mobj->info->reactiontime) + { + mobj->reactiontime--; + if (!mobj->reactiontime) + P_KillMobj(mobj, NULL, NULL); } if (mobj->threshold > 0) mobj->threshold--;