From 84000a0add2643b68f9b603d699f45ccc6fed7fd Mon Sep 17 00:00:00 2001 From: Lachlan Date: Sat, 4 Jul 2020 04:00:28 +0800 Subject: [PATCH] P_Earthquake: Use P_RadiusAttack in favor of thinker iteration --- src/p_map.c | 2 +- src/p_user.c | 45 ++++++--------------------------------------- 2 files changed, 7 insertions(+), 40 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index acfffc901..a8cb33f1b 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -3377,7 +3377,7 @@ static void PTR_GlideClimbTraverse(line_t *li) slidemo->player->climbing = 5; if (slidemo->player->powers[pw_super]) { - P_Earthquake(slidemo, slidemo, 256*slidemo->scale); + P_Earthquake(slidemo, slidemo, 256*FRACUNIT); S_StartSound(slidemo, sfx_s3k49); } } diff --git a/src/p_user.c b/src/p_user.c index beb2eedb1..f973a7726 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2357,7 +2357,7 @@ boolean P_PlayerHitFloor(player_t *player, boolean dorollstuff) player->mo->momy = ((player->mo->momy - player->cmomy)/2) + player->cmomy; if (player->powers[pw_super]) { - P_Earthquake(player->mo, player->mo, 256*player->mo->scale); + P_Earthquake(player->mo, player->mo, 256*FRACUNIT); S_StartSound(player->mo, sfx_s3k49); } else @@ -8990,14 +8990,13 @@ void P_NukeEnemies(mobj_t *inflictor, mobj_t *source, fixed_t radius) // // P_Earthquake // Used for Super Knuckles' landing - damages enemies within the given radius -// If inflictor is grounded, only grounded enemies are hurt // void P_Earthquake(mobj_t *inflictor, mobj_t *source, fixed_t radius) { - const fixed_t ns = radius/12; + const fixed_t scaledradius = FixedMul(radius, inflictor->scale); + const fixed_t ns = scaledradius/12; mobj_t *mo; angle_t fa; - thinker_t *think; INT32 i; boolean grounded = P_IsObjectOnGround(inflictor); @@ -9023,44 +9022,12 @@ void P_Earthquake(mobj_t *inflictor, mobj_t *source, fixed_t radius) if (inflictor->player && P_IsLocalPlayer(inflictor->player)) { quake.epicenter = NULL; - quake.intensity = 8*FRACUNIT; + quake.intensity = 8*inflictor->scale; quake.time = 8; - quake.radius = radius; + quake.radius = scaledradius; } - for (think = thlist[THINK_MOBJ].next; think != &thlist[THINK_MOBJ]; think = think->next) - { - if (think->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; - - mo = (mobj_t *)think; - - if (grounded && !P_IsObjectOnGround(mo)) - continue; - - if (!(mo->flags & MF_SHOOTABLE) && !(mo->type == MT_EGGGUARD || mo->type == MT_MINUS)) - continue; - - if (mo->flags & MF_MONITOR) - continue; // Monitors cannot be 'nuked'. - - if (mo->type == MT_PLAYER) - continue; // Don't hurt players - - if (abs(inflictor->x - mo->x) > radius || abs(inflictor->y - mo->y) > radius || abs(inflictor->z - mo->z) > radius) - continue; // Workaround for possible integer overflow in the below -Red - - if (P_AproxDistance(P_AproxDistance(inflictor->x - mo->x, inflictor->y - mo->y), inflictor->z - mo->z) > radius) - continue; - - if (mo->type == MT_MINUS && !(mo->flags & (MF_SPECIAL|MF_SHOOTABLE))) - mo->flags = (mo->flags & ~MF_NOCLIPTHING)|MF_SPECIAL|MF_SHOOTABLE; - - if (mo->type == MT_EGGGUARD && mo->tracer) //nuke Egg Guard's shield! - P_KillMobj(mo->tracer, inflictor, source, 0); - - P_DamageMobj(mo, inflictor, source, 1, 0); - } + P_RadiusAttack(inflictor, source, radius, 0); } //