From 8770d76a4efcb60efd37ee7f1a0aad88681466fb Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 18 Feb 2023 14:39:43 -0800 Subject: [PATCH 1/3] Add P_SpawnMobjFromMobjUnscaled, does not scale offsets --- src/p_local.h | 1 + src/p_mobj.c | 23 +++++++++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/p_local.h b/src/p_local.h index 4824da84b..bf847fbca 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -330,6 +330,7 @@ boolean P_CheckDeathPitCollide(mobj_t *mo); boolean P_CheckSolidLava(mobj_t *mobj, ffloor_t *rover); void P_AdjustMobjFloorZ_FFloors(mobj_t *mo, sector_t *sector, UINT8 motype); +mobj_t *P_SpawnMobjFromMobjUnscaled(mobj_t *mobj, fixed_t xofs, fixed_t yofs, fixed_t zofs, mobjtype_t type); mobj_t *P_SpawnMobjFromMobj(mobj_t *mobj, fixed_t xofs, fixed_t yofs, fixed_t zofs, mobjtype_t type); mobj_t *P_SpawnMissile(mobj_t *source, mobj_t *dest, mobjtype_t type); diff --git a/src/p_mobj.c b/src/p_mobj.c index f8c6ec400..a22fe9036 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -14156,18 +14156,14 @@ fixed_t P_ScaleFromMap(fixed_t n, fixed_t scale) } // -// P_SpawnMobjFromMobj +// P_SpawnMobjFromMobjUnscaled // Spawns an object with offsets relative to the position of another object. // Scale, gravity flip, etc. is taken into account automatically. // -mobj_t *P_SpawnMobjFromMobj(mobj_t *mobj, fixed_t xofs, fixed_t yofs, fixed_t zofs, mobjtype_t type) +mobj_t *P_SpawnMobjFromMobjUnscaled(mobj_t *mobj, fixed_t xofs, fixed_t yofs, fixed_t zofs, mobjtype_t type) { mobj_t *newmobj; - xofs = FixedMul(xofs, mobj->scale); - yofs = FixedMul(yofs, mobj->scale); - zofs = FixedMul(zofs, mobj->scale); - newmobj = P_SpawnMobj(mobj->x + xofs, mobj->y + yofs, mobj->z + zofs, type); if (!newmobj) return NULL; @@ -14220,6 +14216,21 @@ mobj_t *P_SpawnMobjFromMobj(mobj_t *mobj, fixed_t xofs, fixed_t yofs, fixed_t zo return newmobj; } +// +// P_SpawnMobjFromMobj +// Spawns an object with offsets relative to the position of another object. +// Scale, gravity flip, etc. is taken into account automatically. +// The offsets are automatically scaled by source object's scale. +// +mobj_t *P_SpawnMobjFromMobj(mobj_t *mobj, fixed_t xofs, fixed_t yofs, fixed_t zofs, mobjtype_t type) +{ + xofs = FixedMul(xofs, mobj->scale); + yofs = FixedMul(yofs, mobj->scale); + zofs = FixedMul(zofs, mobj->scale); + + return P_SpawnMobjFromMobjUnscaled(mobj, xofs, yofs, zofs, type); +} + // // P_GetMobjHead & P_GetMobjFeet // Returns the top and bottom of an object, follows appearance, not physics, From 8fae89cb9aba45d0faedf055452a6c5c8079705f Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 18 Feb 2023 14:40:27 -0800 Subject: [PATCH 2/3] Make K_SpawnMagicianParticles offsets consistent across different mobj scales --- src/k_kart.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 787c4aff9..c0486b91e 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -1978,10 +1978,10 @@ void K_SpawnMagicianParticles(mobj_t *mo, int spread) else ang += ANGLE_90; - dust = P_SpawnMobjFromMobj(mo, - FixedMul(mo->radius, FINECOSINE(ang >> ANGLETOFINESHIFT)), - FixedMul(mo->radius, FINESINE(ang >> ANGLETOFINESHIFT)), - target->height, (i%3 == 0) ? MT_SIGNSPARKLE : MT_SPINDASHDUST + dust = P_SpawnMobjFromMobjUnscaled(mo, + FixedMul(mo->radius / 4, FINECOSINE(ang >> ANGLETOFINESHIFT)), + FixedMul(mo->radius / 4, FINESINE(ang >> ANGLETOFINESHIFT)), + target->height / 4, (i%3 == 0) ? MT_SIGNSPARKLE : MT_SPINDASHDUST ); flip = P_MobjFlip(dust); From ba908edf55b9f2c79d9f5d87ef123bfbfb0291d8 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 18 Feb 2023 14:02:05 -0800 Subject: [PATCH 3/3] Add player sprzoff to Heavy Magician Box --- src/k_kart.c | 3 ++- src/p_mobj.c | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index c0486b91e..f8c69cc94 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -1978,10 +1978,11 @@ void K_SpawnMagicianParticles(mobj_t *mo, int spread) else ang += ANGLE_90; + // sprzoff for Garden Top!! dust = P_SpawnMobjFromMobjUnscaled(mo, FixedMul(mo->radius / 4, FINECOSINE(ang >> ANGLETOFINESHIFT)), FixedMul(mo->radius / 4, FINESINE(ang >> ANGLETOFINESHIFT)), - target->height / 4, (i%3 == 0) ? MT_SIGNSPARKLE : MT_SPINDASHDUST + (target->height / 4) + target->sprzoff, (i%3 == 0) ? MT_SIGNSPARKLE : MT_SPINDASHDUST ); flip = P_MobjFlip(dust); diff --git a/src/p_mobj.c b/src/p_mobj.c index a22fe9036..738ce4f4e 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -8091,6 +8091,9 @@ static boolean P_MobjRegularThink(mobj_t *mobj) zoff = mobj->radius*4; } + // Necessary to "ride" on Garden Top + zoff += mobj->target->sprzoff; + if (mobj->flags2 & MF2_AMBUSH) { P_SetOrigin(mobj, destx, desty, mobj->target->z + zoff);