Merge branch 'fix-shakes' into 'master'

Some quake improvements

See merge request KartKrew/Kart!1523
This commit is contained in:
toaster 2023-09-26 20:36:04 +00:00
commit 36f7c57ca5
6 changed files with 33 additions and 18 deletions

View file

@ -305,7 +305,7 @@ static inline BlockItReturn_t PIT_SSMineExplode(mobj_t *thing)
lagadded = (thing->hitlag - oldhitlag); lagadded = (thing->hitlag - oldhitlag);
if (lagadded > 0) if (lagadded > minehitlag)
{ {
minehitlag = lagadded; 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. // Set this flag to ensure that the inital action won't be triggered twice.
actor->flags2 |= MF2_DEBRIS; 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 // Set this flag to ensure the hitbox timer doesn't get extended with every player hit
actor->flags |= MF_NOHITLAGFORME; actor->flags |= MF_NOHITLAGFORME;
actor->hitlag = 0; // same deal actor->hitlag = 0; // same deal
if (!spin) if (!spin)
{ {
if (minehitlag == 0)
{
minehitlag = actor->hitlag;
}
Obj_SpawnBrolyKi(actor, minehitlag);
return minehitlag; return minehitlag;
} }

View file

@ -4499,6 +4499,11 @@ void K_MineFlashScreen(mobj_t *source)
INT32 pnum; INT32 pnum;
player_t *p; player_t *p;
if (P_MobjWasRemoved(source))
{
return;
}
S_StartSound(source, sfx_s3k4e); S_StartSound(source, sfx_s3k4e);
P_StartQuakeFromMobj(12, 55 * source->scale, MINEQUAKEDIST * source->scale, source); 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->hitlag += delay;
truc->renderflags |= RF_DONTDRAW; truc->renderflags |= RF_DONTDRAW;
} }
Obj_SpawnBrolyKi(source, delay);
} }
#undef MINEQUAKEDIST #undef MINEQUAKEDIST

View file

@ -37,6 +37,8 @@ Obj_SpawnBrolyKi
x = P_SpawnMobjFromMobj( x = P_SpawnMobjFromMobj(
source, 0, 0, 0, MT_BROLY); source, 0, 0, 0, MT_BROLY);
P_SetTarget(&x->target, source);
// Shrink into center of source object. // Shrink into center of source object.
x->z = (source->z + source->height / 2); x->z = (source->z + source->height / 2);

View file

@ -13059,12 +13059,11 @@ void A_SSMineExplode(mobj_t *actor)
void A_SSMineFlash(mobj_t *actor) void A_SSMineFlash(mobj_t *actor)
{ {
K_MineFlashScreen(actor); K_MineFlashScreen(actor->target);
} }
void A_LandMineExplode(mobj_t *actor) void A_LandMineExplode(mobj_t *actor)
{ {
mobj_t *expl; mobj_t *expl;
INT32 colour = SKINCOLOR_KETCHUP; // we spell words properly here INT32 colour = SKINCOLOR_KETCHUP; // we spell words properly here
INT32 i; INT32 i;

View file

@ -47,6 +47,7 @@
#include "k_respawn.h" #include "k_respawn.h"
#include "k_terrain.h" #include "k_terrain.h"
#include "acs/interface.h" #include "acs/interface.h"
#include "m_easing.h"
// Not sure if this is necessary, but it was in w_wad.c, so I'm putting it here too -Shadow Hog // Not sure if this is necessary, but it was in w_wad.c, so I'm putting it here too -Shadow Hog
#include <errno.h> #include <errno.h>
@ -9385,7 +9386,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 = (mappoint_t *)Z_Malloc(sizeof(mappoint_t), PU_LEVEL, NULL);
quake->epicenter->x = mobj->x; quake->epicenter->x = mobj->x;
quake->epicenter->y = mobj->y; 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) void P_DoQuakeOffset(UINT8 view, mappoint_t *viewPos, mappoint_t *offset)
@ -9407,17 +9408,25 @@ void P_DoQuakeOffset(UINT8 view, mappoint_t *viewPos, mappoint_t *offset)
ir = quake->intensity; ir = quake->intensity;
// Modulate with time remaining. // Modulate with time remaining.
ir = FixedMul(ir, 2 * FRACUNIT * (quake->time + 1) / quake->startTime); 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. // Modulate with distance from epicenter, if it exists.
if (quake->radius > 0 && quake->epicenter != NULL) 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
viewPos->x - quake->epicenter->x, const fixed_t epidist = P_AproxDistance(
viewPos->y - quake->epicenter->y P_AproxDistance(
); viewPos->x - quake->epicenter->x,
viewPos->y - quake->epicenter->y
),
viewPos->z - quake->epicenter->z
) - distBuffer;
ir = FixedMul(ir, FixedDiv(max(0, quake->radius - epidist), quake->radius));
fixed_t distEase = FixedDiv(max(epidist, 0), quake->radius);
distEase = min(distEase, FRACUNIT);
ir = Easing_InCubic(distEase, ir, 0);
} }
addZ += ir; addZ += ir;

View file

@ -1026,7 +1026,7 @@ void P_Ticker(boolean run)
{ {
quake->epicenter->x = quake->mobj->x; quake->epicenter->x = quake->mobj->x;
quake->epicenter->y = quake->mobj->y; 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; quake = quake->next;