From 896b29f002fd07099371ff2ec067a0cc4d96e371 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 1 Nov 2020 22:33:42 -0800 Subject: [PATCH 1/2] Replace special handling for picking up items from below with MF_PICKUPFROMBELOW --- src/info.c | 2 +- src/k_collide.c | 31 ------------------------------- src/k_collide.h | 1 - src/p_inter.c | 38 ++++++++++++++++++++++++++++++++++---- src/p_map.c | 21 --------------------- src/p_mobj.h | 2 ++ 6 files changed, 37 insertions(+), 58 deletions(-) diff --git a/src/info.c b/src/info.c index 8640268b6..b7124449b 100644 --- a/src/info.c +++ b/src/info.c @@ -22769,7 +22769,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 100, // mass 0, // damage sfx_None, // activesound - MF_SLIDEME|MF_DONTENCOREMAP, // flags + MF_SLIDEME|MF_SPECIAL|MF_PICKUPFROMBELOW|MF_DONTENCOREMAP, // flags S_NULL // raisestate }, diff --git a/src/k_collide.c b/src/k_collide.c index 282fa0072..963ec4e64 100644 --- a/src/k_collide.c +++ b/src/k_collide.c @@ -404,34 +404,3 @@ boolean K_SMKIceBlockCollide(mobj_t *t1, mobj_t *t2) K_KartBouncing(t2, t1, false, true); return false; } - -boolean K_FloatingItemCollide(mobj_t *t1, mobj_t *t2) -{ - player_t * player = t2->player; - - if (t1->flags2 & MF2_NIGHTSPULL) - return true; - - if (! player) - return true; - - if (!P_CanPickupItem(player, 3) || (player->kartstuff[k_itemamount] && player->kartstuff[k_itemtype] != t1->threshold)) - return true; - - if ((gametyperules & GTR_BUMPERS) && player->bumpers <= 0) - return true; - - player->kartstuff[k_itemtype] = t1->threshold; - player->kartstuff[k_itemamount] += t1->movecount; - if (player->kartstuff[k_itemamount] > 255) - player->kartstuff[k_itemamount] = 255; - - S_StartSound(t1, t1->info->deathsound); - - P_SetTarget(&t1->tracer, t2); - t1->flags2 |= MF2_NIGHTSPULL; - t1->destscale = mapobjectscale>>4; - t1->scalespeed <<= 1; - - return false; -} diff --git a/src/k_collide.h b/src/k_collide.h index fed8969d6..86f643b3f 100644 --- a/src/k_collide.h +++ b/src/k_collide.h @@ -12,6 +12,5 @@ boolean K_MineExplosionCollide(mobj_t *t1, mobj_t *t2); boolean K_KitchenSinkCollide(mobj_t *t1, mobj_t *t2); boolean K_FallingRockCollide(mobj_t *t1, mobj_t *t2); boolean K_SMKIceBlockCollide(mobj_t *t1, mobj_t *t2); -boolean K_FloatingItemCollide(mobj_t *t1, mobj_t *t2); #endif diff --git a/src/p_inter.c b/src/p_inter.c index e8157543f..d990a0bb3 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -182,15 +182,24 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) if (heightcheck) { + fixed_t toucher_bottom = toucher->z; + fixed_t special_bottom = special->z; + + if (toucher->flags & MF_PICKUPFROMBELOW) + toucher_bottom -= toucher->height; + + if (special->flags & MF_PICKUPFROMBELOW) + special_bottom -= special->height; + if (toucher->momz < 0) { - if (toucher->z + toucher->momz > special->z + special->height) + if (toucher_bottom + toucher->momz > special->z + special->height) return; - } else if (toucher->z > special->z + special->height) + } else if (toucher_bottom > special->z + special->height) return; if (toucher->momz > 0) { - if (toucher->z + toucher->height + toucher->momz < special->z) + if (toucher->z + toucher->height + toucher->momz < special_bottom) return; - } else if (toucher->z + toucher->height < special->z) + } else if (toucher->z + toucher->height < special_bottom) return; } @@ -231,6 +240,27 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) P_SetObjectMomZ(player->mo, 12<mo, player->mo->angle, 20<kartstuff[k_itemamount] && player->kartstuff[k_itemtype] != special->threshold)) + return; + + if ((gametyperules & GTR_BUMPERS) && player->bumpers <= 0) + return; + + player->kartstuff[k_itemtype] = special->threshold; + player->kartstuff[k_itemamount] += special->movecount; + if (player->kartstuff[k_itemamount] > 255) + player->kartstuff[k_itemamount] = 255; + + S_StartSound(special, special->info->deathsound); + + P_SetTarget(&special->tracer, toucher); + special->flags2 |= MF2_NIGHTSPULL; + special->destscale = mapobjectscale>>4; + special->scalespeed <<= 1; + + special->flags &= ~MF_SPECIAL; + return; case MT_RANDOMITEM: if (!P_CanPickupItem(player, 1)) return; diff --git a/src/p_map.c b/src/p_map.c index 0b8c7f577..7a0958f7f 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -970,27 +970,6 @@ static boolean PIT_CheckThing(mobj_t *thing) return K_FallingRockCollide(thing, tmthing); } - if (tmthing->type == MT_FLOATINGITEM) - { - // see if it went over / under - if (tmthing->z - tmthing->height > thing->z + thing->height) - return true; // overhead - if (tmthing->z + tmthing->height < thing->z) // extended hitbox - return true; // underneath - - return K_FloatingItemCollide(tmthing, thing); - } - else if (thing->type == MT_FLOATINGITEM) - { - // see if it went over / under - if (tmthing->z > thing->z + thing->height) - return true; // overhead - if (tmthing->z + tmthing->height < thing->z - thing->height) // extended hitbox - return true; // underneath - - return K_FloatingItemCollide(thing, tmthing); - } - //} if ((thing->type == MT_SPRINGSHELL || thing->type == MT_YELLOWSHELL) && thing->health > 0 diff --git a/src/p_mobj.h b/src/p_mobj.h index 9cafcefa7..5c205a758 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -157,6 +157,8 @@ typedef enum MF_RUNSPAWNFUNC = 1<<27, // Don't remap in Encore mode. (Not a drawflag so that it's settable by mobjinfo.) MF_DONTENCOREMAP = 1<<28, + // Hitbox extends just as far below as above. + MF_PICKUPFROMBELOW = 1<<29, // free: to and including 1<<31 } mobjflag_t; From 6370919e0594a37ceea8b1bf954c8e5d9f61b769 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 1 Nov 2020 22:34:14 -0800 Subject: [PATCH 2/2] Pick up emeralds from below --- src/info.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/info.c b/src/info.c index b7124449b..1b9f58220 100644 --- a/src/info.c +++ b/src/info.c @@ -8226,7 +8226,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 16, // mass 0, // damage sfx_None, // activesound - MF_SPECIAL, // flags + MF_SPECIAL|MF_PICKUPFROMBELOW, // flags S_NULL // raisestate },