From 3e78ba17ace16b342b91c48a229a1061a2d0dda3 Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Tue, 29 Jul 2025 17:55:18 -0400 Subject: [PATCH 1/2] Bubble shield mash limit --- src/p_mobj.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 4c5eeb34f..dbcbc0a14 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -9821,6 +9821,10 @@ static boolean P_MobjRegularThink(mobj_t *mobj) mobj->flags = MF_NOCLIP|MF_NOCLIPHEIGHT|MF_NOCLIPTHING|MF_NOGRAVITY|MF_DONTENCOREMAP; mobj->extravalue1 = 1; + // Mash speed limit + if (mobj->cusval) + mobj->cusval--; + mobj->cvmem /= 2; mobj->momz = 0; mobj->destscale = ((8*mobj->tracer->scale)>>2) + (mobj->tracer->scale>>3); @@ -9856,7 +9860,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) mobj->tracer->y + P_ReturnThrustY(NULL, mobj->tracer->angle+ANGLE_90, (mobj->cvmem)<tracer->z - (4*mobj->tracer->scale) + (P_RandomRange(PR_ITEM_BUBBLE, -abs(mobj->cvmem), abs(mobj->cvmem))<movecount > 4*TICRATE) + if (mobj->movecount > 3*TICRATE) { S_StartSound(mobj->tracer, sfx_s3k77); mobj->tracer->flags &= ~MF_NOGRAVITY; @@ -9877,8 +9881,17 @@ static boolean P_MobjRegularThink(mobj_t *mobj) if ((player->cmd.turning > 0 && lastsign < 0) || (player->cmd.turning < 0 && lastsign > 0)) { - mobj->movecount += (TICRATE/2); + UINT8 mashpwr = TICRATE/2; + mobj->movecount += (mashpwr) - (mobj->cusval*2); mobj->cvmem = 8*lastsign; + mobj->cusval = mashpwr/2; // Mash speed limit. + // The value of this var, as set here, is the highest useful speed + // (in tics) that you can mash out of bubble trap. As configured + // here, it's 4 inputs per second. + // If you're here to change this, make sure that when cusval = this + // value, the "movecount" line above adds 0. I would have hooked that + // math up before leaving, but integer precision is a drag here and + // you probably have to use even divisors of mashpwr. S_StartSound(mobj, sfx_s3k7a); } From 8c0f07ad6d95002be2e59b23839832373c9a6615 Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Tue, 29 Jul 2025 19:08:29 -0400 Subject: [PATCH 2/2] Refactor bubble speed limit, trap duration 3.5sec, 6 inputs per second --- src/p_mobj.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index dbcbc0a14..645faf3ac 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -9822,8 +9822,13 @@ static boolean P_MobjRegularThink(mobj_t *mobj) mobj->extravalue1 = 1; // Mash speed limit + UINT8 MASHPWR = TICRATE/2; // Amount to deduct from timer when mashing + UINT8 MAXMASHFREQUENCY = 6; // Nerf fast mashing: allow optimal decay with X inputs per second + + UINT8 ticsbetweenmashing = TICRATE/MAXMASHFREQUENCY; + UINT8 decaypertic = MASHPWR / ticsbetweenmashing; if (mobj->cusval) - mobj->cusval--; + mobj->cusval = max(0, mobj->cusval - decaypertic); mobj->cvmem /= 2; mobj->momz = 0; @@ -9860,7 +9865,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) mobj->tracer->y + P_ReturnThrustY(NULL, mobj->tracer->angle+ANGLE_90, (mobj->cvmem)<tracer->z - (4*mobj->tracer->scale) + (P_RandomRange(PR_ITEM_BUBBLE, -abs(mobj->cvmem), abs(mobj->cvmem))<movecount > 3*TICRATE) + if (mobj->movecount > 7*TICRATE/2) { S_StartSound(mobj->tracer, sfx_s3k77); mobj->tracer->flags &= ~MF_NOGRAVITY; @@ -9881,17 +9886,11 @@ static boolean P_MobjRegularThink(mobj_t *mobj) if ((player->cmd.turning > 0 && lastsign < 0) || (player->cmd.turning < 0 && lastsign > 0)) { - UINT8 mashpwr = TICRATE/2; - mobj->movecount += (mashpwr) - (mobj->cusval*2); + // CONS_Printf("%d -> ", mobj->movecount); + mobj->movecount += MASHPWR - mobj->cusval; + // CONS_Printf("%d\n", mobj->movecount); mobj->cvmem = 8*lastsign; - mobj->cusval = mashpwr/2; // Mash speed limit. - // The value of this var, as set here, is the highest useful speed - // (in tics) that you can mash out of bubble trap. As configured - // here, it's 4 inputs per second. - // If you're here to change this, make sure that when cusval = this - // value, the "movecount" line above adds 0. I would have hooked that - // math up before leaving, but integer precision is a drag here and - // you probably have to use even divisors of mashpwr. + mobj->cusval = MASHPWR; // Mash speed limit. S_StartSound(mobj, sfx_s3k7a); }