From 2230c855aeb201df0754ad4c3d16e85dfbcba680 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Mon, 21 Aug 2023 02:14:25 -0400 Subject: [PATCH 1/5] Some quake improvements - Use easing functions for quake intensity - Camera distance takes Z height into account --- src/p_spec.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index a9dc3760f..3d7fda055 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -47,6 +47,7 @@ #include "k_respawn.h" #include "k_terrain.h" #include "acs/interface.h" +#include "m_easing.h" #ifdef HW3SOUND #include "hardware/hw3sound.h" @@ -9411,17 +9412,20 @@ void P_DoQuakeOffset(UINT8 view, mappoint_t *viewPos, mappoint_t *offset) ir = quake->intensity; // Modulate with time remaining. - ir = FixedMul(ir, 2 * FRACUNIT * (quake->time + 1) / quake->startTime); + ir = Easing_InOutSine(FRACUNIT * (quake->time + 1) / quake->startTime, ir, 0); // Modulate with distance from epicenter, if it exists. if (quake->radius > 0 && quake->epicenter != NULL) { fixed_t epidist = P_AproxDistance( - viewPos->x - quake->epicenter->x, - viewPos->y - quake->epicenter->y + P_AproxDistance( + viewPos->x - quake->epicenter->x, + viewPos->y - quake->epicenter->y + ), + viewPos->z - quake->epicenter->z ); - ir = FixedMul(ir, FixedDiv(max(0, quake->radius - epidist), quake->radius)); + ir = Easing_InOutSine(min(FRACUNIT, FixedDiv(epidist, quake->radius)), ir, 0); } addZ += ir; From e6a19362fc7e19ffb9a38c8b4f98a60b5fa32fcd Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Wed, 20 Sep 2023 23:43:59 -0400 Subject: [PATCH 2/5] Center mobj quake on the z axis --- src/p_spec.c | 2 +- src/p_tick.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 3d7fda055..d658a7648 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -9390,7 +9390,7 @@ void P_StartQuakeFromMobj(tic_t time, fixed_t intensity, fixed_t radius, mobj_t quake->epicenter = (mappoint_t *)Z_Malloc(sizeof(mappoint_t), PU_LEVEL, NULL); quake->epicenter->x = mobj->x; quake->epicenter->y = mobj->y; - quake->epicenter->z = mobj->z; + quake->epicenter->z = mobj->z + (mobj->height / 2); } void P_DoQuakeOffset(UINT8 view, mappoint_t *viewPos, mappoint_t *offset) diff --git a/src/p_tick.c b/src/p_tick.c index 737ff9ba2..f411aa382 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -1026,7 +1026,7 @@ void P_Ticker(boolean run) { quake->epicenter->x = quake->mobj->x; quake->epicenter->y = quake->mobj->y; - quake->epicenter->z = quake->mobj->z; + quake->epicenter->z = quake->mobj->z + (quake->mobj->height / 2); } quake = quake->next; From ca0b5902ba1ee80db48fbaab1e2ebc033033e748 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sat, 23 Sep 2023 06:11:40 -0400 Subject: [PATCH 3/5] Fix use of easing functions, add distance buffer --- src/p_spec.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index d658a7648..dd73fcd7d 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -9412,20 +9412,24 @@ void P_DoQuakeOffset(UINT8 view, mappoint_t *viewPos, mappoint_t *offset) ir = quake->intensity; // Modulate with time remaining. - ir = Easing_InOutSine(FRACUNIT * (quake->time + 1) / quake->startTime, ir, 0); + const fixed_t timeEase = (FRACUNIT * ((quake->startTime - quake->time) - 1)) / quake->startTime; + ir = Easing_InCubic(timeEase, ir, 0); // Modulate with distance from epicenter, if it exists. if (quake->radius > 0 && quake->epicenter != NULL) { - fixed_t epidist = P_AproxDistance( + const fixed_t distBuffer = 256 * mapobjectscale; // add a small buffer zone before it starts to drop off + const fixed_t epidist = P_AproxDistance( P_AproxDistance( viewPos->x - quake->epicenter->x, viewPos->y - quake->epicenter->y ), viewPos->z - quake->epicenter->z - ); + ) - distBuffer; - ir = Easing_InOutSine(min(FRACUNIT, FixedDiv(epidist, quake->radius)), ir, 0); + + const fixed_t distEase = min(FixedDiv(max(epidist, 0), quake->radius), FRACUNIT); + ir = Easing_InCubic(distEase, ir, 0); } addZ += ir; From 91955b1383227886eed5404f885225a28b41667a Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sat, 23 Sep 2023 06:22:47 -0400 Subject: [PATCH 4/5] Broly screen shake is done on the source object Screen shake was being done from the Broly vfx, which does scaling shenanigans so it caused Proximity Mine explosions to make the camera go apeshit. I'm also pretty sure the hitlag calcs Proximity Mine did for the broly effect was wrong, not sure though? I'm trying something else and I think it's better. --- src/k_collide.cpp | 14 ++++++-------- src/k_kart.c | 7 +++++++ src/objects/broly.c | 2 ++ src/p_enemy.c | 3 +-- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/k_collide.cpp b/src/k_collide.cpp index b897873a8..0d1d46348 100644 --- a/src/k_collide.cpp +++ b/src/k_collide.cpp @@ -305,7 +305,7 @@ static inline BlockItReturn_t PIT_SSMineExplode(mobj_t *thing) lagadded = (thing->hitlag - oldhitlag); - if (lagadded > 0) + if (lagadded > minehitlag) { minehitlag = lagadded; } @@ -337,19 +337,17 @@ tic_t K_MineExplodeAttack(mobj_t *actor, fixed_t size, boolean spin) // Set this flag to ensure that the inital action won't be triggered twice. actor->flags2 |= MF2_DEBRIS; + if (minehitlag == 0) + { + minehitlag = actor->hitlag; + } + // Set this flag to ensure the hitbox timer doesn't get extended with every player hit actor->flags |= MF_NOHITLAGFORME; actor->hitlag = 0; // same deal if (!spin) { - if (minehitlag == 0) - { - minehitlag = actor->hitlag; - } - - Obj_SpawnBrolyKi(actor, minehitlag); - return minehitlag; } diff --git a/src/k_kart.c b/src/k_kart.c index c4c48c630..4afe202ff 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -4499,6 +4499,11 @@ void K_MineFlashScreen(mobj_t *source) INT32 pnum; player_t *p; + if (P_MobjWasRemoved(source)) + { + return; + } + S_StartSound(source, sfx_s3k4e); P_StartQuakeFromMobj(12, 55 * source->scale, MINEQUAKEDIST * source->scale, source); @@ -4608,6 +4613,8 @@ void K_SpawnMineExplosion(mobj_t *source, UINT8 color, tic_t delay) truc->hitlag += delay; truc->renderflags |= RF_DONTDRAW; } + + Obj_SpawnBrolyKi(source, delay); } #undef MINEQUAKEDIST diff --git a/src/objects/broly.c b/src/objects/broly.c index d8e2c8ffd..f67847ad1 100644 --- a/src/objects/broly.c +++ b/src/objects/broly.c @@ -37,6 +37,8 @@ Obj_SpawnBrolyKi x = P_SpawnMobjFromMobj( source, 0, 0, 0, MT_BROLY); + P_SetTarget(&x->target, source); + // Shrink into center of source object. x->z = (source->z + source->height / 2); diff --git a/src/p_enemy.c b/src/p_enemy.c index b8bedfc5e..31f43f371 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -13063,12 +13063,11 @@ void A_SSMineExplode(mobj_t *actor) void A_SSMineFlash(mobj_t *actor) { - K_MineFlashScreen(actor); + K_MineFlashScreen(actor->target); } void A_LandMineExplode(mobj_t *actor) { - mobj_t *expl; INT32 colour = SKINCOLOR_KETCHUP; // we spell words properly here INT32 i; From 15a87a8a7737149efd3ca6488090eb913af28750 Mon Sep 17 00:00:00 2001 From: toaster Date: Tue, 26 Sep 2023 21:34:08 +0100 Subject: [PATCH 5/5] P_DoQuakeOffset: Prevent two calls to FixedDiv --- src/p_spec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index dd73fcd7d..336342889 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -9428,7 +9428,8 @@ void P_DoQuakeOffset(UINT8 view, mappoint_t *viewPos, mappoint_t *offset) ) - distBuffer; - const fixed_t distEase = min(FixedDiv(max(epidist, 0), quake->radius), FRACUNIT); + fixed_t distEase = FixedDiv(max(epidist, 0), quake->radius); + distEase = min(distEase, FRACUNIT); ir = Easing_InCubic(distEase, ir, 0); }