Add and use an "instant" parameter for P_SetScale

This commit is contained in:
Zwip-Zwap Zapony 2024-01-02 17:51:43 +01:00
parent 3992e83e8f
commit 564d18b1ea
10 changed files with 194 additions and 258 deletions

View file

@ -589,8 +589,9 @@ void B_RespawnBot(INT32 playernum)
} }
else else
P_SetMobjState(tails, S_PLAY_FALL); P_SetMobjState(tails, S_PLAY_FALL);
P_SetScale(tails, sonic->scale); P_SetScale(tails, sonic->scale, false);
tails->destscale = sonic->destscale; tails->destscale = sonic->destscale;
tails->old_scale = sonic->old_scale;
} }
void B_HandleFlightIndicator(player_t *player) void B_HandleFlightIndicator(player_t *player)

View file

@ -771,7 +771,7 @@ void G_GhostTicker(void)
{ {
g->mo->destscale = READFIXED(g->p); g->mo->destscale = READFIXED(g->p);
if (g->mo->destscale != g->mo->scale) if (g->mo->destscale != g->mo->scale)
P_SetScale(g->mo, g->mo->destscale); P_SetScale(g->mo, g->mo->destscale, false);
} }
if (xziptic & EZT_THOKMASK) if (xziptic & EZT_THOKMASK)
{ // Let's only spawn ONE of these per frame, thanks. { // Let's only spawn ONE of these per frame, thanks.
@ -810,7 +810,7 @@ void G_GhostTicker(void)
mobj->frame = (states[mobjinfo[type].spawnstate].frame & FF_FRAMEMASK) | tr_trans60<<FF_TRANSSHIFT; mobj->frame = (states[mobjinfo[type].spawnstate].frame & FF_FRAMEMASK) | tr_trans60<<FF_TRANSSHIFT;
mobj->color = g->mo->color; mobj->color = g->mo->color;
mobj->skin = g->mo->skin; mobj->skin = g->mo->skin;
P_SetScale(mobj, (mobj->destscale = g->mo->scale)); P_SetScale(mobj, g->mo->scale, true);
if (type == MT_THOK) // spintrail-specific modification for MT_THOK if (type == MT_THOK) // spintrail-specific modification for MT_THOK
{ {
@ -926,7 +926,7 @@ void G_GhostTicker(void)
else else
follow->destscale = g->mo->destscale; follow->destscale = g->mo->destscale;
if (follow->destscale != follow->scale) if (follow->destscale != follow->scale)
P_SetScale(follow, follow->destscale); P_SetScale(follow, follow->destscale, false);
P_UnsetThingPosition(follow); P_UnsetThingPosition(follow);
temp = (g->version < 0x000e) ? READINT16(g->p)<<8 : READFIXED(g->p); temp = (g->version < 0x000e) ? READINT16(g->p)<<8 : READFIXED(g->p);
@ -1079,7 +1079,7 @@ void G_ReadMetalTic(mobj_t *metal)
{ {
metal->destscale = READFIXED(metal_p); metal->destscale = READFIXED(metal_p);
if (metal->destscale != metal->scale) if (metal->destscale != metal->scale)
P_SetScale(metal, metal->destscale); P_SetScale(metal, metal->destscale, false);
} }
if (xziptic & EZT_THOKMASK) if (xziptic & EZT_THOKMASK)
{ // Let's only spawn ONE of these per frame, thanks. { // Let's only spawn ONE of these per frame, thanks.
@ -1117,7 +1117,7 @@ void G_ReadMetalTic(mobj_t *metal)
mobj->angle = metal->angle; mobj->angle = metal->angle;
mobj->color = metal->color; mobj->color = metal->color;
mobj->skin = metal->skin; mobj->skin = metal->skin;
P_SetScale(mobj, (mobj->destscale = metal->scale)); P_SetScale(mobj, metal->scale, true);
if (type == MT_THOK) // spintrail-specific modification for MT_THOK if (type == MT_THOK) // spintrail-specific modification for MT_THOK
{ {
@ -1184,7 +1184,7 @@ void G_ReadMetalTic(mobj_t *metal)
else else
follow->destscale = metal->destscale; follow->destscale = metal->destscale;
if (follow->destscale != follow->scale) if (follow->destscale != follow->scale)
P_SetScale(follow, follow->destscale); P_SetScale(follow, follow->destscale, false);
P_UnsetThingPosition(follow); P_UnsetThingPosition(follow);
temp = (metalversion < 0x000e) ? READINT16(metal_p)<<8 : READFIXED(metal_p); temp = (metalversion < 0x000e) ? READINT16(metal_p)<<8 : READFIXED(metal_p);

View file

@ -925,13 +925,14 @@ static int lib_pSetScale(lua_State *L)
{ {
mobj_t *mobj = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); mobj_t *mobj = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
fixed_t newscale = luaL_checkfixed(L, 2); fixed_t newscale = luaL_checkfixed(L, 2);
boolean instant = lua_optboolean(L, 3);
NOHUD NOHUD
INLEVEL INLEVEL
if (!mobj) if (!mobj)
return LUA_ErrInvalid(L, "mobj_t"); return LUA_ErrInvalid(L, "mobj_t");
if (newscale < FRACUNIT/100) if (newscale < FRACUNIT/100)
newscale = FRACUNIT/100; newscale = FRACUNIT/100;
P_SetScale(mobj, newscale); P_SetScale(mobj, newscale, instant);
return 0; return 0;
} }

View file

@ -732,7 +732,7 @@ static int mobj_set(lua_State *L)
return luaL_error(L, "mobj.type %d out of range (0 - %d).", newtype, NUMMOBJTYPES-1); return luaL_error(L, "mobj.type %d out of range (0 - %d).", newtype, NUMMOBJTYPES-1);
mo->type = newtype; mo->type = newtype;
mo->info = &mobjinfo[newtype]; mo->info = &mobjinfo[newtype];
P_SetScale(mo, mo->scale); P_SetScale(mo, mo->scale, false);
break; break;
} }
case mobj_info: case mobj_info:
@ -806,9 +806,7 @@ static int mobj_set(lua_State *L)
fixed_t scale = luaL_checkfixed(L, 3); fixed_t scale = luaL_checkfixed(L, 3);
if (scale < FRACUNIT/100) if (scale < FRACUNIT/100)
scale = FRACUNIT/100; scale = FRACUNIT/100;
mo->destscale = scale; P_SetScale(mo, scale, true);
P_SetScale(mo, scale);
mo->old_scale = scale;
break; break;
} }
case mobj_destscale: case mobj_destscale:

View file

@ -1219,8 +1219,7 @@ static void P_FaceStabFlume(mobj_t *actor)
if (P_MobjWasRemoved(flume)) if (P_MobjWasRemoved(flume))
return; return;
flume->destscale = actor->scale*3; P_SetScale(flume, 3*actor->scale, true);
P_SetScale(flume, flume->destscale);
P_SetTarget(&flume->target, actor); P_SetTarget(&flume->target, actor);
flume->sprite = SPR_JETF; flume->sprite = SPR_JETF;
flume->frame = FF_FULLBRIGHT; flume->frame = FF_FULLBRIGHT;
@ -1337,8 +1336,7 @@ void A_FaceStabHurl(mobj_t *actor)
{ {
hwork = hwork->hnext; hwork = hwork->hnext;
hwork->angle = actor->angle + ANGLE_90; hwork->angle = actor->angle + ANGLE_90;
hwork->destscale = FixedSqrt(step*basesize); P_SetScale(hwork, FixedSqrt(step*basesize), true);
P_SetScale(hwork, hwork->destscale);
hwork->fuse = 2; hwork->fuse = 2;
P_MoveOrigin(hwork, actor->x + xo*(15-step), actor->y + yo*(15-step), actor->z + (actor->height - hwork->height)/2 + (P_MobjFlip(actor)*(8<<FRACBITS))); P_MoveOrigin(hwork, actor->x + xo*(15-step), actor->y + yo*(15-step), actor->z + (actor->height - hwork->height)/2 + (P_MobjFlip(actor)*(8<<FRACBITS)));
} }
@ -2453,7 +2451,7 @@ void A_VultureBlast(mobj_t *actor)
if (P_MobjWasRemoved(dust)) if (P_MobjWasRemoved(dust))
continue; continue;
P_SetScale(dust, 4*FRACUNIT); P_SetScale(dust, 4*FRACUNIT, true);
dust->destscale = FRACUNIT; dust->destscale = FRACUNIT;
dust->scalespeed = 4*FRACUNIT/TICRATE; dust->scalespeed = 4*FRACUNIT/TICRATE;
dust->fuse = TICRATE; dust->fuse = TICRATE;
@ -2523,7 +2521,7 @@ void A_VultureFly(mobj_t *actor)
dust = P_SpawnMobj(actor->x + P_RandomFixed() - FRACUNIT/2, actor->y + P_RandomFixed() - FRACUNIT/2, actor->z + actor->height/2 + P_RandomFixed() - FRACUNIT/2, MT_PARTICLE); dust = P_SpawnMobj(actor->x + P_RandomFixed() - FRACUNIT/2, actor->y + P_RandomFixed() - FRACUNIT/2, actor->z + actor->height/2 + P_RandomFixed() - FRACUNIT/2, MT_PARTICLE);
if (!P_MobjWasRemoved(dust)) if (!P_MobjWasRemoved(dust))
{ {
P_SetScale(dust, 2*FRACUNIT); P_SetScale(dust, 2*FRACUNIT, true);
dust->destscale = FRACUNIT/3; dust->destscale = FRACUNIT/3;
dust->scalespeed = FRACUNIT/40; dust->scalespeed = FRACUNIT/40;
dust->fuse = TICRATE*2; dust->fuse = TICRATE*2;
@ -2732,15 +2730,9 @@ void A_LobShot(mobj_t *actor)
return; return;
if (actor->type == MT_BLACKEGGMAN) if (actor->type == MT_BLACKEGGMAN)
{ P_SetScale(shot, actor->scale/2, true);
shot->destscale = actor->scale/2;
P_SetScale(shot, actor->scale/2);
}
else else
{ P_SetScale(shot, actor->scale, true);
shot->destscale = actor->scale;
P_SetScale(shot, actor->scale);
}
P_SetTarget(&shot->target, actor); // where it came from P_SetTarget(&shot->target, actor); // where it came from
@ -3185,8 +3177,7 @@ void A_Boss1Laser(mobj_t *actor)
if (!P_MobjWasRemoved(point)) if (!P_MobjWasRemoved(point))
{ {
point->angle = actor->angle; point->angle = actor->angle;
point->destscale = actor->scale; P_SetScale(point, actor->scale, true);
P_SetScale(point, point->destscale);
P_SetTarget(&point->target, actor); P_SetTarget(&point->target, actor);
P_MobjCheckWater(point); P_MobjCheckWater(point);
if (point->eflags & (MFE_UNDERWATER|MFE_TOUCHWATER)) if (point->eflags & (MFE_UNDERWATER|MFE_TOUCHWATER))
@ -3197,7 +3188,8 @@ void A_Boss1Laser(mobj_t *actor)
mobj_t *steam = P_SpawnMobj(x, y, point->watertop - size*mobjinfo[MT_DUST].height, MT_DUST); mobj_t *steam = P_SpawnMobj(x, y, point->watertop - size*mobjinfo[MT_DUST].height, MT_DUST);
if (P_MobjWasRemoved(steam)) if (P_MobjWasRemoved(steam))
continue; continue;
P_SetScale(steam, size*actor->scale); P_SetScale(steam, size*actor->scale, false);
steam->old_scale = steam->scale;
P_SetObjectMomZ(steam, FRACUNIT + 2*P_RandomFixed(), true); P_SetObjectMomZ(steam, FRACUNIT + 2*P_RandomFixed(), true);
P_InstaThrust(steam, FixedAngle(P_RandomKey(360)*FRACUNIT), 2*P_RandomFixed()); P_InstaThrust(steam, FixedAngle(P_RandomKey(360)*FRACUNIT), 2*P_RandomFixed());
if (point->info->painsound) if (point->info->painsound)
@ -3570,8 +3562,7 @@ void A_BossScream(mobj_t *actor)
return; return;
if (actor->eflags & MFE_VERTICALFLIP) if (actor->eflags & MFE_VERTICALFLIP)
mo->flags2 |= MF2_OBJECTFLIP; mo->flags2 |= MF2_OBJECTFLIP;
mo->destscale = actor->scale; P_SetScale(mo, actor->scale, true);
P_SetScale(mo, mo->destscale);
if (actor->info->deathsound) if (actor->info->deathsound)
S_StartSound(mo, actor->info->deathsound); S_StartSound(mo, actor->info->deathsound);
} }
@ -4164,7 +4155,7 @@ static void P_DoBoss5Death(mobj_t *mo)
MT_FSGNB); MT_FSGNB);
if (!P_MobjWasRemoved(pole)) if (!P_MobjWasRemoved(pole))
{ {
P_SetScale(pole, (pole->destscale = 2*FRACUNIT)); P_SetScale(pole, 2*FRACUNIT, true);
pole->momx = P_ReturnThrustX(pole, pole->angle, speed); pole->momx = P_ReturnThrustX(pole, pole->angle, speed);
pole->momy = P_ReturnThrustY(pole, pole->angle, speed); pole->momy = P_ReturnThrustY(pole, pole->angle, speed);
P_SetTarget(&pole->tracer, P_SpawnMobj( P_SetTarget(&pole->tracer, P_SpawnMobj(
@ -4174,7 +4165,7 @@ static void P_DoBoss5Death(mobj_t *mo)
if (!P_MobjWasRemoved(pole->tracer)) if (!P_MobjWasRemoved(pole->tracer))
{ {
pole->tracer->flags |= MF_NOCLIPTHING; pole->tracer->flags |= MF_NOCLIPTHING;
P_SetScale(pole->tracer, (pole->tracer->destscale = 2*FRACUNIT)); P_SetScale(pole->tracer, 2*FRACUNIT, true);
pole->angle = pole->tracer->angle = mo->tracer->angle; pole->angle = pole->tracer->angle = mo->tracer->angle;
pole->tracer->momx = pole->momx; pole->tracer->momx = pole->momx;
pole->tracer->momy = pole->momy; pole->tracer->momy = pole->momy;
@ -4713,10 +4704,7 @@ void A_BubbleSpawn(mobj_t *actor)
bubble = P_SpawnMobj(actor->x, actor->y, actor->z + (actor->height / 2), MT_MEDIUMBUBBLE); bubble = P_SpawnMobj(actor->x, actor->y, actor->z + (actor->height / 2), MT_MEDIUMBUBBLE);
if (bubble) if (bubble)
{ P_SetScale(bubble, actor->scale, true);
bubble->destscale = actor->scale;
P_SetScale(bubble, actor->scale);
}
} }
// Function: A_FanBubbleSpawn // Function: A_FanBubbleSpawn
@ -4759,10 +4747,7 @@ void A_FanBubbleSpawn(mobj_t *actor)
bubble = P_SpawnMobj(actor->x, actor->y, hz, MT_MEDIUMBUBBLE); bubble = P_SpawnMobj(actor->x, actor->y, hz, MT_MEDIUMBUBBLE);
if (bubble) if (bubble)
{ P_SetScale(bubble, actor->scale, true);
bubble->destscale = actor->scale;
P_SetScale(bubble, actor->scale);
}
} }
// Function: A_BubbleRise // Function: A_BubbleRise
@ -5039,8 +5024,7 @@ void A_ThrownRing(mobj_t *actor)
P_SetTarget(&ring->target, actor); P_SetTarget(&ring->target, actor);
ring->color = actor->color; //copy color ring->color = actor->color; //copy color
*/ */
ring->destscale = actor->scale; P_SetScale(ring, actor->scale, true);
P_SetScale(ring, actor->scale);
} }
} }
@ -5619,8 +5603,7 @@ void A_JetbThink(mobj_t *actor)
if (!P_MobjWasRemoved(bomb)) if (!P_MobjWasRemoved(bomb))
{ {
P_SetTarget(&bomb->target, actor); P_SetTarget(&bomb->target, actor);
bomb->destscale = actor->scale; P_SetScale(bomb, actor->scale, true);
P_SetScale(bomb, actor->scale);
actor->reactiontime = TICRATE; // one second actor->reactiontime = TICRATE; // one second
S_StartSound(actor, actor->info->attacksound); S_StartSound(actor, actor->info->attacksound);
} }
@ -5794,7 +5777,8 @@ void A_MinusDigging(mobj_t *actor)
if (P_MobjWasRemoved(par)) if (P_MobjWasRemoved(par))
return; return;
P_SetMobjState(par, actor->info->raisestate); P_SetMobjState(par, actor->info->raisestate);
P_SetScale(par, actor->scale*2); P_SetScale(par, 2*actor->scale, false);
par->old_scale = par->scale;
if (actor->eflags & MFE_VERTICALFLIP) if (actor->eflags & MFE_VERTICALFLIP)
par->eflags |= MFE_VERTICALFLIP; par->eflags |= MFE_VERTICALFLIP;
return; return;
@ -5867,7 +5851,8 @@ void A_MinusPopup(mobj_t *actor)
continue; continue;
P_Thrust(rock, ani*i, FRACUNIT); P_Thrust(rock, ani*i, FRACUNIT);
P_SetObjectMomZ(rock, 3*FRACUNIT, false); P_SetObjectMomZ(rock, 3*FRACUNIT, false);
P_SetScale(rock, rock->scale/3); P_SetScale(rock, rock->scale/3, false);
rock->old_scale = rock->scale;
} }
P_RadiusAttack(actor, actor, 2*actor->radius, 0, true); P_RadiusAttack(actor, actor, 2*actor->radius, 0, true);
if (actor->tracer) if (actor->tracer)
@ -5906,7 +5891,8 @@ void A_MinusCheck(mobj_t *actor)
continue; continue;
P_Thrust(rock, ani*i, FRACUNIT); P_Thrust(rock, ani*i, FRACUNIT);
P_SetObjectMomZ(rock, 3*FRACUNIT, false); P_SetObjectMomZ(rock, 3*FRACUNIT, false);
P_SetScale(rock, rock->scale/3); P_SetScale(rock, rock->scale/3, false);
rock->old_scale = rock->scale;
} }
} }
} }
@ -8227,8 +8213,9 @@ void A_EggShield(mobj_t *actor)
else else
actor->z = actor->target->z; actor->z = actor->target->z;
P_SetScale(actor, actor->target->scale, false);
actor->destscale = actor->target->destscale; actor->destscale = actor->target->destscale;
P_SetScale(actor, actor->target->scale); actor->old_scale = actor->target->old_scale;
actor->floorz = actor->target->floorz; actor->floorz = actor->target->floorz;
actor->ceilingz = actor->target->ceilingz; actor->ceilingz = actor->target->ceilingz;
@ -8509,7 +8496,7 @@ void A_Boss3ShockThink(mobj_t *actor)
P_SetTarget(&snew->target, actor->target); P_SetTarget(&snew->target, actor->target);
snew->fuse = actor->fuse; snew->fuse = actor->fuse;
P_SetScale(snew, actor->scale); P_SetScale(snew, actor->scale, true);
snew->destscale = actor->destscale; snew->destscale = actor->destscale;
snew->scalespeed = actor->scalespeed; snew->scalespeed = actor->scalespeed;
@ -8708,8 +8695,7 @@ void A_SmokeTrailer(mobj_t *actor)
if (P_MobjWasRemoved(th)) if (P_MobjWasRemoved(th))
return; return;
P_SetObjectMomZ(th, FRACUNIT, false); P_SetObjectMomZ(th, FRACUNIT, false);
th->destscale = actor->scale; P_SetScale(th, actor->scale, true);
P_SetScale(th, actor->scale);
th->tics -= P_RandomByte() & 3; th->tics -= P_RandomByte() & 3;
if (th->tics < 1) if (th->tics < 1)
th->tics = 1; th->tics = 1;
@ -9453,8 +9439,7 @@ void A_BossJetFume(mobj_t *actor)
if (!P_MobjWasRemoved(filler)) if (!P_MobjWasRemoved(filler))
{ {
P_SetTarget(&filler->target, actor); P_SetTarget(&filler->target, actor);
filler->destscale = actor->scale; P_SetScale(filler, actor->scale, true);
P_SetScale(filler, filler->destscale);
if (actor->eflags & MFE_VERTICALFLIP) if (actor->eflags & MFE_VERTICALFLIP)
filler->flags2 |= MF2_OBJECTFLIP; filler->flags2 |= MF2_OBJECTFLIP;
filler->fuse = 56; filler->fuse = 56;
@ -9471,8 +9456,7 @@ void A_BossJetFume(mobj_t *actor)
if (!P_MobjWasRemoved(filler)) if (!P_MobjWasRemoved(filler))
{ {
P_SetTarget(&filler->target, actor); P_SetTarget(&filler->target, actor);
filler->destscale = actor->scale; P_SetScale(filler, actor->scale, true);
P_SetScale(filler, filler->destscale);
if (actor->eflags & MFE_VERTICALFLIP) if (actor->eflags & MFE_VERTICALFLIP)
filler->flags2 |= MF2_OBJECTFLIP; filler->flags2 |= MF2_OBJECTFLIP;
filler->fuse = 57; filler->fuse = 57;
@ -9485,7 +9469,7 @@ void A_BossJetFume(mobj_t *actor)
{ {
P_SetTarget(&filler->target, actor); P_SetTarget(&filler->target, actor);
filler->destscale = actor->scale; filler->destscale = actor->scale;
P_SetScale(filler, filler->destscale); P_SetScale(filler, actor->scale, true);
if (actor->eflags & MFE_VERTICALFLIP) if (actor->eflags & MFE_VERTICALFLIP)
filler->flags2 |= MF2_OBJECTFLIP; filler->flags2 |= MF2_OBJECTFLIP;
filler->fuse = 58; filler->fuse = 58;
@ -9506,8 +9490,7 @@ void A_BossJetFume(mobj_t *actor)
filler = P_SpawnMobj(jetx, jety, jetz, MT_PROPELLER); filler = P_SpawnMobj(jetx, jety, jetz, MT_PROPELLER);
P_SetTarget(&filler->target, actor); P_SetTarget(&filler->target, actor);
filler->destscale = actor->scale; P_SetScale(filler, actor->scale, true);
P_SetScale(filler, filler->destscale);
if (actor->eflags & MFE_VERTICALFLIP) if (actor->eflags & MFE_VERTICALFLIP)
filler->flags2 |= MF2_OBJECTFLIP; filler->flags2 |= MF2_OBJECTFLIP;
filler->angle = actor->angle - ANGLE_180; filler->angle = actor->angle - ANGLE_180;
@ -9522,7 +9505,7 @@ void A_BossJetFume(mobj_t *actor)
P_SetTarget(&filler->target, actor); P_SetTarget(&filler->target, actor);
filler->fuse = 59; filler->fuse = 59;
P_SetTarget(&actor->tracer, filler); P_SetTarget(&actor->tracer, filler);
P_SetScale(filler, (filler->destscale = actor->scale/3)); P_SetScale(filler, actor->scale/3, true);
if (actor->eflags & MFE_VERTICALFLIP) if (actor->eflags & MFE_VERTICALFLIP)
filler->flags2 |= MF2_OBJECTFLIP; filler->flags2 |= MF2_OBJECTFLIP;
filler->color = SKINCOLOR_ICY; filler->color = SKINCOLOR_ICY;
@ -9541,8 +9524,7 @@ void A_BossJetFume(mobj_t *actor)
{ {
P_SetTarget(&filler->target, actor); P_SetTarget(&filler->target, actor);
// Boss 4 already uses its tracer for other things // Boss 4 already uses its tracer for other things
filler->destscale = actor->scale; P_SetScale(filler, actor->scale, true);
P_SetScale(filler, filler->destscale);
if (actor->eflags & MFE_VERTICALFLIP) if (actor->eflags & MFE_VERTICALFLIP)
filler->flags2 |= MF2_OBJECTFLIP; filler->flags2 |= MF2_OBJECTFLIP;
} }
@ -9564,8 +9546,7 @@ void A_BossJetFume(mobj_t *actor)
{ {
filler->movefactor = movefactor; filler->movefactor = movefactor;
P_SetTarget(&filler->target, actor); P_SetTarget(&filler->target, actor);
filler->destscale = actor->scale; P_SetScale(filler, actor->scale, true);
P_SetScale(filler, filler->destscale);
if (actor->eflags & MFE_VERTICALFLIP) if (actor->eflags & MFE_VERTICALFLIP)
filler->flags2 |= MF2_OBJECTFLIP; filler->flags2 |= MF2_OBJECTFLIP;
} }
@ -9811,12 +9792,13 @@ void A_ToggleFlameJet(mobj_t* actor)
// var1 = Angle adjustment (aka orbit speed) // var1 = Angle adjustment (aka orbit speed)
// var2: // var2:
// Bits 1-10: height offset, max 1023 // Bits 1-10: height offset, max 1023
// Bits 11-16: X radius factor (max 63, default 20) // Bits 11-16: X radius factor (max 63, default 32)
// Bit 17: set if object is Nightopian Helper // Bit 17: set if object is Nightopian Helper
// Bit 18: set to define X/Y/Z rotation factor // Bit 18: set to define X/Y/Z rotation factor
// Bits 19-20: Unused // Bit 19: set to not sync scale to player
// Bit 20: Unused
// Bits 21-26: Y radius factor (max 63, default 32) // Bits 21-26: Y radius factor (max 63, default 32)
// Bits 27-32: Z radius factor (max 63, default 32) // Bits 27-32: Z radius factor (max 63, default 20)
// //
// If MF_GRENADEBOUNCE is flagged on mobj, use actor->threshold to define X/Y/Z radius factor, max 1023 each: // If MF_GRENADEBOUNCE is flagged on mobj, use actor->threshold to define X/Y/Z radius factor, max 1023 each:
// Bits 1-10: X factor // Bits 1-10: X factor
@ -9857,6 +9839,12 @@ void A_OrbitNights(mobj_t* actor)
} }
else else
{ {
if (!donotrescale)
{
P_SetScale(actor, actor->target->scale, true);
actor->old_scale = actor->target->old_scale;
}
actor->extravalue1 += var1; actor->extravalue1 += var1;
P_UnsetThingPosition(actor); P_UnsetThingPosition(actor);
{ {
@ -9884,9 +9872,6 @@ void A_OrbitNights(mobj_t* actor)
else else
actor->flags2 &= ~MF2_DONTDRAW; actor->flags2 &= ~MF2_DONTDRAW;
} }
if (!donotrescale && actor->destscale != actor->target->destscale)
actor->destscale = actor->target->destscale;
} }
} }
@ -11135,9 +11120,10 @@ void A_SetScale(mobj_t *actor)
return; return;
} }
if ((locvar2 & 65535) == 0)
P_SetScale(target, locvar1, true); // this instantly changes current scale to var1 if used, if not destscale will alter scale to var1 over time
else
target->destscale = locvar1; // destination scale target->destscale = locvar1; // destination scale
if (!(locvar2 & 65535))
P_SetScale(target, locvar1); // this instantly changes current scale to var1 if used, if not destscale will alter scale to var1 anyway
} }
// Function: A_RemoteDamage // Function: A_RemoteDamage
@ -11281,8 +11267,7 @@ void A_TrapShot(mobj_t *actor)
if (actor->eflags & MFE_VERTICALFLIP) if (actor->eflags & MFE_VERTICALFLIP)
missile->flags2 |= MF2_OBJECTFLIP; missile->flags2 |= MF2_OBJECTFLIP;
missile->destscale = actor->scale; P_SetScale(missile, actor->scale, true);
P_SetScale(missile, actor->scale);
if (missile->info->seesound) if (missile->info->seesound)
S_StartSound(missile, missile->info->seesound); S_StartSound(missile, missile->info->seesound);
@ -11356,8 +11341,7 @@ void A_VileTarget(mobj_t *actor)
fog->eflags |= MFE_VERTICALFLIP; fog->eflags |= MFE_VERTICALFLIP;
fog->flags2 |= MF2_OBJECTFLIP; fog->flags2 |= MF2_OBJECTFLIP;
} }
fog->destscale = actor->target->scale; P_SetScale(fog, actor->target->scale, true);
P_SetScale(fog, fog->destscale);
P_SetTarget(&actor->tracer, fog); P_SetTarget(&actor->tracer, fog);
P_SetTarget(&fog->target, actor); P_SetTarget(&fog->target, actor);
@ -11390,8 +11374,7 @@ void A_VileTarget(mobj_t *actor)
fog->eflags |= MFE_VERTICALFLIP; fog->eflags |= MFE_VERTICALFLIP;
fog->flags2 |= MF2_OBJECTFLIP; fog->flags2 |= MF2_OBJECTFLIP;
} }
fog->destscale = players[i].mo->scale; P_SetScale(fog, players[i].mo->scale, true);
P_SetScale(fog, fog->destscale);
if (players[i].mo == actor->target) // We only care to track the fog targeting who we REALLY hate right now if (players[i].mo == actor->target) // We only care to track the fog targeting who we REALLY hate right now
P_SetTarget(&actor->tracer, fog); P_SetTarget(&actor->tracer, fog);
@ -11548,8 +11531,8 @@ void A_VileFire(mobj_t *actor)
return; return;
// keep to same scale and gravity as tracer ALWAYS // keep to same scale and gravity as tracer ALWAYS
actor->destscale = dest->scale; P_SetScale(actor, dest->scale, true);
P_SetScale(actor, actor->destscale); actor->old_scale = dest->old_scale;
if (dest->eflags & MFE_VERTICALFLIP) if (dest->eflags & MFE_VERTICALFLIP)
{ {
actor->eflags |= MFE_VERTICALFLIP; actor->eflags |= MFE_VERTICALFLIP;
@ -12729,8 +12712,7 @@ void A_LightBeamReset(mobj_t *actor)
if (LUA_CallAction(A_LIGHTBEAMRESET, actor)) if (LUA_CallAction(A_LIGHTBEAMRESET, actor))
return; return;
actor->destscale = FRACUNIT + P_SignedRandom()*FRACUNIT/256; P_SetScale(actor, FRACUNIT + P_SignedRandom()*FRACUNIT/256, true);
P_SetScale(actor, actor->destscale);
if (!actor->spawnpoint) if (!actor->spawnpoint)
return; // this can't work properly welp return; // this can't work properly welp
@ -13315,7 +13297,7 @@ void A_DoNPCSkid(mobj_t *actor)
{ {
particle->tics = 10; particle->tics = 10;
P_SetScale(particle, 2*actor->scale/3); P_SetScale(particle, 2*actor->scale/3, true);
particle->destscale = actor->scale; particle->destscale = actor->scale;
P_SetObjectMomZ(particle, FRACUNIT, false); P_SetObjectMomZ(particle, FRACUNIT, false);
} }
@ -13738,7 +13720,7 @@ static void P_DustRing(mobjtype_t mobjtype, UINT32 div, fixed_t x, fixed_t y, fi
continue; continue;
dust->angle = ang*i + ANGLE_90; dust->angle = ang*i + ANGLE_90;
P_SetScale(dust, FixedMul(initscale, scale)); P_SetScale(dust, FixedMul(initscale, scale), true);
dust->destscale = FixedMul(4*FRACUNIT + P_RandomFixed(), scale); dust->destscale = FixedMul(4*FRACUNIT + P_RandomFixed(), scale);
dust->scalespeed = scale/24; dust->scalespeed = scale/24;
P_Thrust(dust, ang*i, speed + FixedMul(P_RandomFixed(), scale)); P_Thrust(dust, ang*i, speed + FixedMul(P_RandomFixed(), scale));
@ -13877,7 +13859,8 @@ void A_DustDevilThink(mobj_t *actor)
while (layer && !P_MobjWasRemoved(layer)) { while (layer && !P_MobjWasRemoved(layer)) {
angle_t fa = layer->angle >> ANGLETOFINESHIFT; angle_t fa = layer->angle >> ANGLETOFINESHIFT;
P_MoveOrigin(layer, layer->x + 5 * FixedMul(scale, FINECOSINE(fa)), layer->y + 5 * FixedMul(scale, FINESINE(fa)), layer->z); P_MoveOrigin(layer, layer->x + 5 * FixedMul(scale, FINECOSINE(fa)), layer->y + 5 * FixedMul(scale, FINESINE(fa)), layer->z);
layer->scale = scale; P_SetScale(layer, scale, true);
layer->old_scale = actor->old_scale;
layer->angle += ANG10 / 2; layer->angle += ANG10 / 2;
layer->momx = actor->momx; layer->momx = actor->momx;
layer->momy = actor->momy; layer->momy = actor->momy;
@ -13891,8 +13874,7 @@ void A_DustDevilThink(mobj_t *actor)
if (!P_MobjWasRemoved(dust)) if (!P_MobjWasRemoved(dust))
{ {
P_SetMobjState(dust, dust->info->spawnstate + P_RandomRange(0, 2)); P_SetMobjState(dust, dust->info->spawnstate + P_RandomRange(0, 2));
dust->destscale = scale * 3; P_SetScale(dust, 3 * scale, true);
P_SetScale(dust, dust->destscale);
} }
} }
@ -13911,6 +13893,7 @@ void A_DustDevilThink(mobj_t *actor)
layer = P_SpawnMobj(px, py, pz, MT_DUSTLAYER); layer = P_SpawnMobj(px, py, pz, MT_DUSTLAYER);
if (P_MobjWasRemoved(layer)) if (P_MobjWasRemoved(layer))
continue; continue;
P_SetScale(layer, scale, true);
layer->momz = 5 * scale; layer->momz = 5 * scale;
layer->angle = ANGLE_90 + ANGLE_90*i; layer->angle = ANGLE_90 + ANGLE_90*i;
layer->extravalue1 = TICRATE * 3; layer->extravalue1 = TICRATE * 3;
@ -14530,8 +14513,7 @@ void A_MinecartSparkThink(mobj_t *actor)
continue; continue;
trail->tics = 2; trail->tics = 2;
trail->sprite = actor->sprite; trail->sprite = actor->sprite;
P_SetScale(trail, trail->scale/4); P_SetScale(trail, trail->scale/4, true);
trail->destscale = trail->scale;
} }
} }
@ -14654,8 +14636,16 @@ void A_FireShrink(mobj_t *actor)
if (LUA_CallAction(A_FIRESHRINK, actor)) if (LUA_CallAction(A_FIRESHRINK, actor))
return; return;
if (locvar2 == 0)
{
P_SetScale(actor, locvar1, true);
actor->scalespeed = FRACUNIT/12; // Reset scalespeed to the default
}
else
{
actor->destscale = locvar1; actor->destscale = locvar1;
actor->scalespeed = FRACUNIT/locvar2; actor->scalespeed = FRACUNIT/locvar2;
}
} }
// Function: A_SpawnPterabytes // Function: A_SpawnPterabytes

View file

@ -2765,8 +2765,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget
mo = P_SpawnMobj(target->x, target->y, target->z, MT_EXTRALARGEBUBBLE); mo = P_SpawnMobj(target->x, target->y, target->z, MT_EXTRALARGEBUBBLE);
if (P_MobjWasRemoved(mo)) if (P_MobjWasRemoved(mo))
break; break;
mo->destscale = target->scale; P_SetScale(mo, target->scale, true);
P_SetScale(mo, mo->destscale);
P_SetMobjState(mo, mo->info->raisestate); P_SetMobjState(mo, mo->info->raisestate);
break; break;
@ -3957,8 +3956,7 @@ void P_PlayerRingBurst(player_t *player, INT32 num_rings)
mo->fuse = 8*TICRATE; mo->fuse = 8*TICRATE;
P_SetTarget(&mo->target, player->mo); P_SetTarget(&mo->target, player->mo);
mo->destscale = player->mo->scale; P_SetScale(mo, player->mo->scale, true);
P_SetScale(mo, player->mo->scale);
// Angle offset by player angle, then slightly offset by amount of rings // Angle offset by player angle, then slightly offset by amount of rings
fa = ((i*FINEANGLES/16) + va - ((num_rings-1)*FINEANGLES/32)) & FINEMASK; fa = ((i*FINEANGLES/16) + va - ((num_rings-1)*FINEANGLES/32)) & FINEMASK;
@ -4094,8 +4092,7 @@ void P_PlayerWeaponPanelBurst(player_t *player)
mo->flags &= ~(MF_NOGRAVITY|MF_NOCLIPHEIGHT); mo->flags &= ~(MF_NOGRAVITY|MF_NOCLIPHEIGHT);
P_SetTarget(&mo->target, player->mo); P_SetTarget(&mo->target, player->mo);
mo->fuse = 12*TICRATE; mo->fuse = 12*TICRATE;
mo->destscale = player->mo->scale; P_SetScale(mo, player->mo->scale, true);
P_SetScale(mo, player->mo->scale);
// Angle offset by player angle // Angle offset by player angle
fa = ((i*FINEANGLES/16) + (player->mo->angle>>ANGLETOFINESHIFT)) & FINEMASK; fa = ((i*FINEANGLES/16) + (player->mo->angle>>ANGLETOFINESHIFT)) & FINEMASK;
@ -4183,8 +4180,7 @@ void P_PlayerWeaponAmmoBurst(player_t *player)
player->powers[power] = 0; player->powers[power] = 0;
mo->fuse = 12*TICRATE; mo->fuse = 12*TICRATE;
mo->destscale = player->mo->scale; P_SetScale(mo, player->mo->scale, true);
P_SetScale(mo, player->mo->scale);
// Angle offset by player angle // Angle offset by player angle
fa = ((i*FINEANGLES/16) + (player->mo->angle>>ANGLETOFINESHIFT)) & FINEMASK; fa = ((i*FINEANGLES/16) + (player->mo->angle>>ANGLETOFINESHIFT)) & FINEMASK;
@ -4231,8 +4227,7 @@ void P_PlayerWeaponPanelOrAmmoBurst(player_t *player)
mo->flags &= ~(MF_NOGRAVITY|MF_NOCLIPHEIGHT); \ mo->flags &= ~(MF_NOGRAVITY|MF_NOCLIPHEIGHT); \
P_SetTarget(&mo->target, player->mo); \ P_SetTarget(&mo->target, player->mo); \
mo->fuse = 12*TICRATE; \ mo->fuse = 12*TICRATE; \
mo->destscale = player->mo->scale; \ P_SetScale(mo, player->mo->scale, true); \
P_SetScale(mo, player->mo->scale); \
mo->momx = FixedMul(FINECOSINE(fa),ns); \ mo->momx = FixedMul(FINECOSINE(fa),ns); \
if (!(twodlevel || (player->mo->flags2 & MF2_TWOD))) \ if (!(twodlevel || (player->mo->flags2 & MF2_TWOD))) \
mo->momy = FixedMul(FINESINE(fa),ns); \ mo->momy = FixedMul(FINESINE(fa),ns); \
@ -4254,8 +4249,7 @@ void P_PlayerWeaponPanelOrAmmoBurst(player_t *player)
mo->flags &= ~(MF_NOGRAVITY|MF_NOCLIPHEIGHT); \ mo->flags &= ~(MF_NOGRAVITY|MF_NOCLIPHEIGHT); \
P_SetTarget(&mo->target, player->mo); \ P_SetTarget(&mo->target, player->mo); \
mo->fuse = 12*TICRATE; \ mo->fuse = 12*TICRATE; \
mo->destscale = player->mo->scale; \ P_SetScale(mo, player->mo->scale, true); \
P_SetScale(mo, player->mo->scale); \
mo->momx = FixedMul(FINECOSINE(fa),ns); \ mo->momx = FixedMul(FINECOSINE(fa),ns); \
if (!(twodlevel || (player->mo->flags2 & MF2_TWOD))) \ if (!(twodlevel || (player->mo->flags2 & MF2_TWOD))) \
mo->momy = FixedMul(FINESINE(fa),ns); \ mo->momy = FixedMul(FINESINE(fa),ns); \

View file

@ -917,7 +917,7 @@ void P_ExplodeMissile(mobj_t *mo)
explodemo = P_SpawnMobj(mo->x, mo->y, mo->z, MT_EXPLODE); explodemo = P_SpawnMobj(mo->x, mo->y, mo->z, MT_EXPLODE);
if (!P_MobjWasRemoved(explodemo)) if (!P_MobjWasRemoved(explodemo))
{ {
P_SetScale(explodemo, mo->scale); P_SetScale(explodemo, mo->scale, true);
explodemo->destscale = mo->destscale; explodemo->destscale = mo->destscale;
explodemo->momx += (P_RandomByte() % 32) * FixedMul(FRACUNIT/8, explodemo->scale); explodemo->momx += (P_RandomByte() % 32) * FixedMul(FRACUNIT/8, explodemo->scale);
explodemo->momy += (P_RandomByte() % 32) * FixedMul(FRACUNIT/8, explodemo->scale); explodemo->momy += (P_RandomByte() % 32) * FixedMul(FRACUNIT/8, explodemo->scale);
@ -926,7 +926,7 @@ void P_ExplodeMissile(mobj_t *mo)
explodemo = P_SpawnMobj(mo->x, mo->y, mo->z, MT_EXPLODE); explodemo = P_SpawnMobj(mo->x, mo->y, mo->z, MT_EXPLODE);
if (!P_MobjWasRemoved(explodemo)) if (!P_MobjWasRemoved(explodemo))
{ {
P_SetScale(explodemo, mo->scale); P_SetScale(explodemo, mo->scale, true);
explodemo->destscale = mo->destscale; explodemo->destscale = mo->destscale;
explodemo->momx += (P_RandomByte() % 64) * FixedMul(FRACUNIT/8, explodemo->scale); explodemo->momx += (P_RandomByte() % 64) * FixedMul(FRACUNIT/8, explodemo->scale);
explodemo->momy -= (P_RandomByte() % 64) * FixedMul(FRACUNIT/8, explodemo->scale); explodemo->momy -= (P_RandomByte() % 64) * FixedMul(FRACUNIT/8, explodemo->scale);
@ -935,7 +935,7 @@ void P_ExplodeMissile(mobj_t *mo)
explodemo = P_SpawnMobj(mo->x, mo->y, mo->z, MT_EXPLODE); explodemo = P_SpawnMobj(mo->x, mo->y, mo->z, MT_EXPLODE);
if (!P_MobjWasRemoved(explodemo)) if (!P_MobjWasRemoved(explodemo))
{ {
P_SetScale(explodemo, mo->scale); P_SetScale(explodemo, mo->scale, true);
explodemo->destscale = mo->destscale; explodemo->destscale = mo->destscale;
explodemo->momx -= (P_RandomByte() % 128) * FixedMul(FRACUNIT/8, explodemo->scale); explodemo->momx -= (P_RandomByte() % 128) * FixedMul(FRACUNIT/8, explodemo->scale);
explodemo->momy += (P_RandomByte() % 128) * FixedMul(FRACUNIT/8, explodemo->scale); explodemo->momy += (P_RandomByte() % 128) * FixedMul(FRACUNIT/8, explodemo->scale);
@ -944,7 +944,7 @@ void P_ExplodeMissile(mobj_t *mo)
explodemo = P_SpawnMobj(mo->x, mo->y, mo->z, MT_EXPLODE); explodemo = P_SpawnMobj(mo->x, mo->y, mo->z, MT_EXPLODE);
if (!P_MobjWasRemoved(explodemo)) if (!P_MobjWasRemoved(explodemo))
{ {
P_SetScale(explodemo, mo->scale); P_SetScale(explodemo, mo->scale, true);
explodemo->destscale = mo->destscale; explodemo->destscale = mo->destscale;
explodemo->momx -= (P_RandomByte() % 96) * FixedMul(FRACUNIT/8, explodemo->scale); explodemo->momx -= (P_RandomByte() % 96) * FixedMul(FRACUNIT/8, explodemo->scale);
explodemo->momy -= (P_RandomByte() % 96) * FixedMul(FRACUNIT/8, explodemo->scale); explodemo->momy -= (P_RandomByte() % 96) * FixedMul(FRACUNIT/8, explodemo->scale);
@ -3108,8 +3108,7 @@ boolean P_SceneryZMovement(mobj_t *mo)
continue; continue;
explodemo->momx += ((prandom & 0x0F) << (FRACBITS-2)) * (i & 2 ? -1 : 1); explodemo->momx += ((prandom & 0x0F) << (FRACBITS-2)) * (i & 2 ? -1 : 1);
explodemo->momy += ((prandom & 0xF0) << (FRACBITS-6)) * (i & 1 ? -1 : 1); explodemo->momy += ((prandom & 0xF0) << (FRACBITS-6)) * (i & 1 ? -1 : 1);
explodemo->destscale = mo->scale; P_SetScale(explodemo, mo->scale, true);
P_SetScale(explodemo, mo->scale);
} }
if (mo->threshold != 42) // Don't make pop sound if threshold is 42. if (mo->threshold != 42) // Don't make pop sound if threshold is 42.
@ -3135,7 +3134,7 @@ boolean P_SceneryZMovement(mobj_t *mo)
mobj_t *flower = P_SpawnMobjFromMobj(mo, 0, 0, 0, flowertype); mobj_t *flower = P_SpawnMobjFromMobj(mo, 0, 0, 0, flowertype);
if (flower) if (flower)
{ {
P_SetScale(flower, mo->scale/16); P_SetScale(flower, mo->scale/16, true);
flower->destscale = mo->scale; flower->destscale = mo->scale;
flower->scalespeed = mo->scale/8; flower->scalespeed = mo->scale/8;
} }
@ -3375,10 +3374,7 @@ void P_MobjCheckWater(mobj_t *mobj)
else else
splish = P_SpawnMobj(mobj->x, mobj->y, mobj->watertop, splishtype); splish = P_SpawnMobj(mobj->x, mobj->y, mobj->watertop, splishtype);
if (!P_MobjWasRemoved(splish)) if (!P_MobjWasRemoved(splish))
{ P_SetScale(splish, mobj->scale, true);
splish->destscale = mobj->scale;
P_SetScale(splish, mobj->scale);
}
} }
// skipping stone! // skipping stone!
@ -3417,10 +3413,7 @@ void P_MobjCheckWater(mobj_t *mobj)
else else
splish = P_SpawnMobj(mobj->x, mobj->y, mobj->watertop, splishtype); splish = P_SpawnMobj(mobj->x, mobj->y, mobj->watertop, splishtype);
if (!P_MobjWasRemoved(splish)) if (!P_MobjWasRemoved(splish))
{ P_SetScale(splish, mobj->scale, true);
splish->destscale = mobj->scale;
P_SetScale(splish, mobj->scale);
}
} }
} }
@ -3471,8 +3464,7 @@ void P_MobjCheckWater(mobj_t *mobj)
else else
bubble->momz = 0; bubble->momz = 0;
bubble->destscale = mobj->scale; P_SetScale(bubble, mobj->scale, true);
P_SetScale(bubble, mobj->scale);
} }
} }
} }
@ -5136,8 +5128,7 @@ static void P_Boss7Thinker(mobj_t *mobj)
mobj_t *smoke = P_SpawnMobj(mobj->x, mobj->y, mobj->z + mobj->height, MT_SMOKE); mobj_t *smoke = P_SpawnMobj(mobj->x, mobj->y, mobj->z + mobj->height, MT_SMOKE);
if (!P_MobjWasRemoved(smoke)) if (!P_MobjWasRemoved(smoke))
{ {
smoke->destscale = mobj->destscale; P_SetScale(smoke, mobj->destscale, true);
P_SetScale(smoke, smoke->destscale);
smoke->momz = FixedMul(FRACUNIT, smoke->scale); smoke->momz = FixedMul(FRACUNIT, smoke->scale);
} }
} }
@ -5586,7 +5577,7 @@ static void P_Boss9Thinker(mobj_t *mobj)
if (mobj->hprev) if (mobj->hprev)
{ {
mobj->hprev->destscale = FRACUNIT + (2*TICRATE - mobj->fuse)*(FRACUNIT/2)/TICRATE + FixedMul(FINECOSINE(angle>>ANGLETOFINESHIFT),FRACUNIT/2); mobj->hprev->destscale = FRACUNIT + (2*TICRATE - mobj->fuse)*(FRACUNIT/2)/TICRATE + FixedMul(FINECOSINE(angle>>ANGLETOFINESHIFT),FRACUNIT/2);
P_SetScale(mobj->hprev, mobj->hprev->destscale); P_SetScale(mobj->hprev, mobj->hprev->destscale, false);
P_MoveOrigin(mobj->hprev, mobj->x, mobj->y, mobj->z + mobj->height/2 - mobj->hprev->height/2); P_MoveOrigin(mobj->hprev, mobj->x, mobj->y, mobj->z + mobj->height/2 - mobj->hprev->height/2);
mobj->hprev->momx = mobj->momx; mobj->hprev->momx = mobj->momx;
@ -5612,8 +5603,8 @@ static void P_Boss9Thinker(mobj_t *mobj)
{ {
S_StopSound(missile); S_StopSound(missile);
if (mobj->extravalue1 >= 2) if (mobj->extravalue1 >= 2)
P_SetScale(missile, FRACUNIT>>1); P_SetScale(missile, FRACUNIT/2, true);
missile->destscale = missile->scale>>1; missile->destscale = missile->scale/2;
missile->fuse = TICRATE/2; missile->fuse = TICRATE/2;
missile->scalespeed = abs(missile->destscale - missile->scale)/missile->fuse; missile->scalespeed = abs(missile->destscale - missile->scale)/missile->fuse;
missile->z -= missile->height/2; missile->z -= missile->height/2;
@ -5636,7 +5627,7 @@ static void P_Boss9Thinker(mobj_t *mobj)
spread->angle = missile->angle+(ANGLE_11hh/2)*(i-2); spread->angle = missile->angle+(ANGLE_11hh/2)*(i-2);
P_InstaThrust(spread,spread->angle,-spread->info->speed); P_InstaThrust(spread,spread->angle,-spread->info->speed);
spread->momz = missile->momz; spread->momz = missile->momz;
P_SetScale(spread, missile->scale); P_SetScale(spread, missile->scale, true);
spread->destscale = missile->destscale; spread->destscale = missile->destscale;
spread->scalespeed = missile->scalespeed; spread->scalespeed = missile->scalespeed;
spread->fuse = missile->fuse; spread->fuse = missile->fuse;
@ -5660,7 +5651,7 @@ static void P_Boss9Thinker(mobj_t *mobj)
spread = P_SpawnMissile(mobj, mobj->target, missile->type); spread = P_SpawnMissile(mobj, mobj->target, missile->type);
if (P_MobjWasRemoved(spread)) if (P_MobjWasRemoved(spread))
continue; continue;
P_SetScale(spread, missile->scale); P_SetScale(spread, missile->scale, true);
spread->destscale = missile->destscale; spread->destscale = missile->destscale;
spread->fuse = missile->fuse; spread->fuse = missile->fuse;
spread->z -= spread->height/2; spread->z -= spread->height/2;
@ -5717,12 +5708,12 @@ static void P_Boss9Thinker(mobj_t *mobj)
{ {
if (mobj->health > mobj->info->damage) if (mobj->health > mobj->info->damage)
{ {
P_SetScale(missile, FRACUNIT/3); P_SetScale(missile, FRACUNIT/3, true);
missile->color = SKINCOLOR_MAGENTA; // sonic OVA/4 purple power missile->color = SKINCOLOR_MAGENTA; // sonic OVA/4 purple power
} }
else else
{ {
P_SetScale(missile, FRACUNIT/5); P_SetScale(missile, FRACUNIT/5, true);
missile->color = SKINCOLOR_SUNSET; // sonic cd electric power missile->color = SKINCOLOR_SUNSET; // sonic cd electric power
} }
missile->destscale = missile->scale*2; missile->destscale = missile->scale*2;
@ -5785,10 +5776,7 @@ static void P_Boss9Thinker(mobj_t *mobj)
if (!P_MobjWasRemoved(missile)) if (!P_MobjWasRemoved(missile))
{ {
if (mobj->extravalue1 >= 2) if (mobj->extravalue1 >= 2)
{ P_SetScale(missile, FRACUNIT/2, true);
missile->destscale = FRACUNIT>>1;
P_SetScale(missile, missile->destscale);
}
missile->fuse = 3*TICRATE; missile->fuse = 3*TICRATE;
missile->z -= missile->height/2; missile->z -= missile->height/2;
@ -5807,8 +5795,7 @@ static void P_Boss9Thinker(mobj_t *mobj)
spread->angle = missile->angle+(ANGLE_11hh/2)*(i-2); spread->angle = missile->angle+(ANGLE_11hh/2)*(i-2);
P_InstaThrust(spread,spread->angle,spread->info->speed); P_InstaThrust(spread,spread->angle,spread->info->speed);
spread->momz = missile->momz; spread->momz = missile->momz;
spread->destscale = FRACUNIT>>1; P_SetScale(spread, FRACUNIT/2, true);
P_SetScale(spread, spread->destscale);
spread->fuse = missile->fuse; spread->fuse = missile->fuse;
} }
P_InstaThrust(missile,missile->angle,missile->info->speed); P_InstaThrust(missile,missile->angle,missile->info->speed);
@ -5825,8 +5812,7 @@ static void P_Boss9Thinker(mobj_t *mobj)
spread = P_SpawnMissile(mobj, mobj->target, missile->type); spread = P_SpawnMissile(mobj, mobj->target, missile->type);
if (!P_MobjWasRemoved(spread)) if (!P_MobjWasRemoved(spread))
{ {
spread->destscale = FRACUNIT>>1; P_SetScale(spread, FRACUNIT/2, true);
P_SetScale(spread, spread->destscale);
spread->fuse = missile->fuse; spread->fuse = missile->fuse;
spread->z -= spread->height/2; spread->z -= spread->height/2;
} }
@ -6086,8 +6072,12 @@ static void P_Boss9Thinker(mobj_t *mobj)
whoosh->flags |= MF_NOCLIPHEIGHT; whoosh->flags |= MF_NOCLIPHEIGHT;
#endif #endif
if (!P_MobjWasRemoved(mobj->tracer))
{
P_SetMobjState(mobj->tracer, S_JETFUMEFLASH); P_SetMobjState(mobj->tracer, S_JETFUMEFLASH);
P_SetScale(mobj->tracer, mobj->scale << 1); P_SetScale(mobj->tracer, 2*mobj->scale, false);
mobj->tracer->old_scale = mobj->tracer->scale;
}
} }
else else
{ {
@ -6422,28 +6412,24 @@ void P_SpawnParaloop(fixed_t x, fixed_t y, fixed_t z, fixed_t radius, INT32 numb
// //
// Sets the sprite scaling // Sets the sprite scaling
// //
void P_SetScale(mobj_t *mobj, fixed_t newscale) void P_SetScale(mobj_t *mobj, fixed_t newscale, boolean instant)
{ {
player_t *player;
fixed_t oldscale;
if (!mobj) if (!mobj)
return; return;
oldscale = mobj->scale; //keep for adjusting stuff below if (mobj->player)
mobj->scale = newscale;
mobj->radius = FixedMul(FixedDiv(mobj->radius, oldscale), newscale);
mobj->height = FixedMul(FixedDiv(mobj->height, oldscale), newscale);
player = mobj->player;
if (player)
{ {
G_GhostAddScale(newscale); G_GhostAddScale(newscale);
player->viewheight = FixedMul(FixedDiv(player->viewheight, oldscale), newscale); // Nonono don't calculate viewheight elsewhere, this is the best place for it! // Nonono don't calculate viewheight elsewhere, this is the best place for it!
mobj->player->viewheight = FixedMul(FixedDiv(mobj->player->viewheight, mobj->scale), newscale);
} }
mobj->radius = FixedMul(FixedDiv(mobj->radius, mobj->scale), newscale);
mobj->height = FixedMul(FixedDiv(mobj->height, mobj->scale), newscale);
mobj->scale = newscale;
if (instant)
mobj->destscale = mobj->old_scale = newscale;
} }
void P_Attract(mobj_t *source, mobj_t *dest, boolean nightsgrab) // Home in on your target void P_Attract(mobj_t *source, mobj_t *dest, boolean nightsgrab) // Home in on your target
@ -6798,8 +6784,7 @@ static boolean P_ShieldLook(mobj_t *thing, shieldtype_t shield)
thing->flags |= MF_NOCLIPHEIGHT; thing->flags |= MF_NOCLIPHEIGHT;
thing->eflags = (thing->eflags & ~MFE_VERTICALFLIP)|(thing->target->eflags & MFE_VERTICALFLIP); thing->eflags = (thing->eflags & ~MFE_VERTICALFLIP)|(thing->target->eflags & MFE_VERTICALFLIP);
P_SetScale(thing, FixedMul(thing->target->scale, thing->target->player->shieldscale)); P_SetScale(thing, FixedMul(thing->target->scale, thing->target->player->shieldscale), true);
thing->destscale = thing->scale;
thing->old_scale = FixedMul(thing->target->old_scale, thing->target->player->shieldscale); thing->old_scale = FixedMul(thing->target->old_scale, thing->target->player->shieldscale);
#define NewMH(mobj) mobj->height // Ugly mobj-height and player-height defines, for the sake of prettier code #define NewMH(mobj) mobj->height // Ugly mobj-height and player-height defines, for the sake of prettier code
@ -7147,11 +7132,11 @@ static void P_MobjScaleThink(mobj_t *mobj)
correctionType = 2; // Correct Z position by moving down correctionType = 2; // Correct Z position by moving down
if (abs(mobj->scale - mobj->destscale) < mobj->scalespeed) if (abs(mobj->scale - mobj->destscale) < mobj->scalespeed)
P_SetScale(mobj, mobj->destscale); P_SetScale(mobj, mobj->destscale, false);
else if (mobj->scale < mobj->destscale) else if (mobj->scale < mobj->destscale)
P_SetScale(mobj, mobj->scale + mobj->scalespeed); P_SetScale(mobj, mobj->scale + mobj->scalespeed, false);
else if (mobj->scale > mobj->destscale) else if (mobj->scale > mobj->destscale)
P_SetScale(mobj, mobj->scale - mobj->scalespeed); P_SetScale(mobj, mobj->scale - mobj->scalespeed, false);
if (correctionType == 1) if (correctionType == 1)
mobj->z -= (mobj->height - oldheight)/2; mobj->z -= (mobj->height - oldheight)/2;
@ -7244,8 +7229,9 @@ static boolean P_DrownNumbersSceneryThink(mobj_t *mobj)
mobj->x = mobj->target->x; mobj->x = mobj->target->x;
mobj->y = mobj->target->y; mobj->y = mobj->target->y;
P_SetScale(mobj, mobj->target->scale, false);
mobj->destscale = mobj->target->destscale; mobj->destscale = mobj->target->destscale;
P_SetScale(mobj, mobj->target->scale); mobj->old_scale = mobj->target->old_scale;
if (mobj->target->eflags & MFE_VERTICALFLIP) if (mobj->target->eflags & MFE_VERTICALFLIP)
{ {
@ -7406,10 +7392,10 @@ static boolean P_ParticleGenSceneryThink(mobj_t *mobj)
(mobjtype_t)mobj->threshold); (mobjtype_t)mobj->threshold);
if (!P_MobjWasRemoved(spawn)) if (!P_MobjWasRemoved(spawn))
{ {
P_SetScale(spawn, mobj->scale); P_SetScale(spawn, mobj->scale, true);
spawn->momz = FixedMul(mobj->movefactor, spawn->scale);
spawn->destscale = spawn->scale/100; spawn->destscale = spawn->scale/100;
spawn->scalespeed = spawn->scale/mobj->health; spawn->scalespeed = spawn->scale/mobj->health;
spawn->momz = FixedMul(mobj->movefactor, spawn->scale);
spawn->tics = (tic_t)mobj->health; spawn->tics = (tic_t)mobj->health;
spawn->flags2 |= (mobj->flags2 & MF2_OBJECTFLIP); spawn->flags2 |= (mobj->flags2 & MF2_OBJECTFLIP);
spawn->angle += P_RandomKey(36)*ANG10; // irrelevant for default objects but might make sense for some custom ones spawn->angle += P_RandomKey(36)*ANG10; // irrelevant for default objects but might make sense for some custom ones
@ -7627,8 +7613,7 @@ static void P_RosySceneryThink(mobj_t *mobj)
mobj_t *cdlhrt = P_SpawnMobjFromMobj(mobj, 0, 0, mobj->height, MT_CDLHRT); mobj_t *cdlhrt = P_SpawnMobjFromMobj(mobj, 0, 0, mobj->height, MT_CDLHRT);
if (!P_MobjWasRemoved(cdlhrt)) if (!P_MobjWasRemoved(cdlhrt))
{ {
cdlhrt->destscale = (5*mobj->scale) >> 4; P_SetScale(cdlhrt, (5*mobj->scale) >> 4, true);
P_SetScale(cdlhrt, cdlhrt->destscale);
cdlhrt->fuse = (5*TICRATE) >> 1; cdlhrt->fuse = (5*TICRATE) >> 1;
cdlhrt->momz = mobj->scale; cdlhrt->momz = mobj->scale;
P_SetTarget(&cdlhrt->target, mobj); P_SetTarget(&cdlhrt->target, mobj);
@ -7882,8 +7867,9 @@ static void P_MobjSceneryThink(mobj_t *mobj)
mobj->eflags |= (mobj->target->eflags & MFE_VERTICALFLIP); mobj->eflags |= (mobj->target->eflags & MFE_VERTICALFLIP);
P_SetScale(mobj, mobj->target->scale, false);
mobj->destscale = mobj->target->destscale; mobj->destscale = mobj->target->destscale;
P_SetScale(mobj, mobj->target->scale); mobj->old_scale = mobj->target->old_scale;
if (!(mobj->eflags & MFE_VERTICALFLIP)) if (!(mobj->eflags & MFE_VERTICALFLIP))
mobj->z = mobj->target->z + mobj->target->height + FixedMul((16 + abs((signed)(leveltime % TICRATE) - TICRATE/2))*FRACUNIT, mobj->target->scale); mobj->z = mobj->target->z + mobj->target->height + FixedMul((16 + abs((signed)(leveltime % TICRATE) - TICRATE/2))*FRACUNIT, mobj->target->scale);
@ -8033,7 +8019,9 @@ static void P_MobjSceneryThink(mobj_t *mobj)
} }
P_SetThingPosition(mobj); P_SetThingPosition(mobj);
P_SetScale(mobj, mobj->target->scale); P_SetScale(mobj, mobj->target->scale, false);
mobj->destscale = mobj->target->destscale;
mobj->old_scale = mobj->target->old_scale;
} }
break; break;
case MT_TUTORIALFLOWER: case MT_TUTORIALFLOWER:
@ -8474,8 +8462,8 @@ static void P_ArrowThink(mobj_t *mobj)
if (!P_MobjWasRemoved(dust)) if (!P_MobjWasRemoved(dust))
{ {
dust->tics = 18; dust->tics = 18;
dust->scalespeed = 4096;
dust->destscale = FRACUNIT/32; dust->destscale = FRACUNIT/32;
dust->scalespeed = FRACUNIT/16;
} }
} }
} }
@ -9887,9 +9875,9 @@ static boolean P_MobjRegularThink(mobj_t *mobj)
traindust->frame = P_RandomRange(0, 8)|FF_TRANS90; traindust->frame = P_RandomRange(0, 8)|FF_TRANS90;
traindust->angle = mobj->angle; traindust->angle = mobj->angle;
traindust->tics = TICRATE*4; traindust->tics = TICRATE*4;
P_SetScale(traindust, FRACUNIT*6, true);
traindust->destscale = FRACUNIT*64; traindust->destscale = FRACUNIT*64;
traindust->scalespeed = FRACUNIT/24; traindust->scalespeed = FRACUNIT/24;
P_SetScale(traindust, FRACUNIT*6);
} }
break; break;
case MT_TRAINSTEAMSPAWNER: case MT_TRAINSTEAMSPAWNER:
@ -9900,9 +9888,9 @@ static boolean P_MobjRegularThink(mobj_t *mobj)
P_SetMobjState(steam, S_TRAINSTEAM); P_SetMobjState(steam, S_TRAINSTEAM);
steam->frame = P_RandomRange(0, 1)|FF_TRANS90; steam->frame = P_RandomRange(0, 1)|FF_TRANS90;
steam->tics = TICRATE*8; steam->tics = TICRATE*8;
P_SetScale(steam, FRACUNIT*16, true);
steam->destscale = FRACUNIT*64; steam->destscale = FRACUNIT*64;
steam->scalespeed = FRACUNIT/8; steam->scalespeed = FRACUNIT/8;
P_SetScale(steam, FRACUNIT*16);
steam->momx = P_SignedRandom()*32; steam->momx = P_SignedRandom()*32;
steam->momy = -64*FRACUNIT; steam->momy = -64*FRACUNIT;
steam->momz = 2*FRACUNIT; steam->momz = 2*FRACUNIT;
@ -10891,7 +10879,7 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type, ...)
if (titlemapinaction) mobj->flags &= ~MF_NOTHINK; if (titlemapinaction) mobj->flags &= ~MF_NOTHINK;
break; break;
case MT_LOCKONINF: case MT_LOCKONINF:
P_SetScale(mobj, (mobj->destscale = 3*mobj->scale)); P_SetScale(mobj, 3*mobj->scale, true);
break; break;
case MT_CYBRAKDEMON_NAPALM_BOMB_LARGE: case MT_CYBRAKDEMON_NAPALM_BOMB_LARGE:
mobj->fuse = mobj->info->painchance; mobj->fuse = mobj->info->painchance;
@ -10902,8 +10890,7 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type, ...)
if (P_MobjWasRemoved(spawn)) if (P_MobjWasRemoved(spawn))
break; break;
spawn->destscale = mobj->scale; P_SetScale(spawn, mobj->scale, true);
P_SetScale(spawn, mobj->scale);
P_SetTarget(&spawn->target, mobj); P_SetTarget(&spawn->target, mobj);
} }
break; break;
@ -10920,8 +10907,7 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type, ...)
if (P_MobjWasRemoved(spawn)) if (P_MobjWasRemoved(spawn))
break; break;
spawn->destscale = mobj->scale; P_SetScale(spawn, mobj->scale, true);
P_SetScale(spawn, mobj->scale);
P_SetTarget(&mobj->tracer, spawn); P_SetTarget(&mobj->tracer, spawn);
P_SetTarget(&spawn->target, mobj); P_SetTarget(&spawn->target, mobj);
} }
@ -10938,8 +10924,7 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type, ...)
if (P_MobjWasRemoved(ball)) if (P_MobjWasRemoved(ball))
continue; continue;
ball->destscale = mobj->scale; P_SetScale(ball, mobj->scale, true);
P_SetScale(ball, mobj->scale);
P_SetTarget(&ball->target, mobj); P_SetTarget(&ball->target, mobj);
ball->movedir = FixedAngle(FixedMul(FixedDiv(i<<FRACBITS, mobj->info->damage<<FRACBITS), 360<<FRACBITS)); ball->movedir = FixedAngle(FixedMul(FixedDiv(i<<FRACBITS, mobj->info->damage<<FRACBITS), 360<<FRACBITS));
ball->threshold = ball->radius + mobj->radius + FixedMul(ball->info->painchance, ball->scale); ball->threshold = ball->radius + mobj->radius + FixedMul(ball->info->painchance, ball->scale);
@ -10960,8 +10945,7 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type, ...)
if (P_MobjWasRemoved(ball)) if (P_MobjWasRemoved(ball))
continue; continue;
ball->destscale = mobj->scale; P_SetScale(ball, mobj->scale, true);
P_SetScale(ball, mobj->scale);
P_SetTarget(&lastball->tracer, ball); P_SetTarget(&lastball->tracer, ball);
P_SetTarget(&ball->target, mobj); P_SetTarget(&ball->target, mobj);
lastball = ball; lastball = ball;
@ -11821,7 +11805,7 @@ void P_SpawnPlayer(INT32 playernum)
p->awayviewtics = 0; p->awayviewtics = 0;
// set the scale to the mobj's destscale so settings get correctly set. if we don't, they sometimes don't. // set the scale to the mobj's destscale so settings get correctly set. if we don't, they sometimes don't.
P_SetScale(mobj, mobj->destscale); P_SetScale(mobj, mobj->destscale, true);
P_FlashPal(p, 0, 0); // Resets P_FlashPal(p, 0, 0); // Resets
// Set bounds accurately. // Set bounds accurately.
@ -11995,7 +11979,7 @@ void P_MovePlayerToStarpost(INT32 playernum)
z = p->starpostz << FRACBITS; z = p->starpostz << FRACBITS;
P_SetScale(mobj, (mobj->destscale = abs(p->starpostscale))); P_SetScale(mobj, abs(p->starpostscale), true);
if (p->starpostscale < 0) if (p->starpostscale < 0)
{ {
@ -13103,8 +13087,8 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj, boolean
if (P_MobjWasRemoved(corona)) if (P_MobjWasRemoved(corona))
break; break;
P_SetScale(corona, (corona->destscale = mobj->scale*3));
P_SetTarget(&mobj->tracer, corona); P_SetTarget(&mobj->tracer, corona);
P_SetScale(corona, 3*mobj->scale, true);
} }
break; break;
case MT_FLAMEHOLDER: case MT_FLAMEHOLDER:
@ -13122,8 +13106,8 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj, boolean
if (P_MobjWasRemoved(corona)) if (P_MobjWasRemoved(corona))
break; break;
P_SetScale(corona, (corona->destscale = flame->scale*3));
P_SetTarget(&flame->tracer, corona); P_SetTarget(&flame->tracer, corona);
P_SetScale(corona, 3*flame->scale, true);
} }
} }
break; break;
@ -13211,10 +13195,8 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj, boolean
case MT_DSZSTALAGMITE: case MT_DSZSTALAGMITE:
case MT_DSZ2STALAGMITE: case MT_DSZ2STALAGMITE:
case MT_KELP: case MT_KELP:
if (mthing->args[0]) { // make mobj twice as big as normal if (mthing->args[0]) // make mobj twice as big as normal
P_SetScale(mobj, 2*mobj->scale); // not 2*FRACUNIT in case of something like the old ERZ3 mode P_SetScale(mobj, 2*mobj->scale, true); // not 2*FRACUNIT in case of something like the old ERZ3 mode
mobj->destscale = mobj->scale;
}
break; break;
case MT_THZTREE: case MT_THZTREE:
{ // Spawn the branches { // Spawn the branches
@ -13293,10 +13275,7 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj, boolean
case MT_LAVAFALL: case MT_LAVAFALL:
mobj->fuse = 30 + mthing->args[0]; mobj->fuse = 30 + mthing->args[0];
if (mthing->args[1]) if (mthing->args[1])
{ P_SetScale(mobj, 2*mobj->scale, true);
P_SetScale(mobj, 2*mobj->scale);
mobj->destscale = mobj->scale;
}
break; break;
case MT_PYREFLY: case MT_PYREFLY:
//start on fire if args[0], otherwise behave normally //start on fire if args[0], otherwise behave normally
@ -13359,8 +13338,7 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj, boolean
break; break;
P_SetTarget(&elecmobj->target, mobj); P_SetTarget(&elecmobj->target, mobj);
elecmobj->angle = FixedAngle(mthing->angle << FRACBITS); elecmobj->angle = FixedAngle(mthing->angle << FRACBITS);
elecmobj->destscale = mobj->scale*2; P_SetScale(elecmobj, 2*mobj->scale, true);
P_SetScale(elecmobj, elecmobj->destscale);
} }
break; break;
case MT_STARPOST: case MT_STARPOST:
@ -13418,8 +13396,8 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj, boolean
return false; return false;
} }
base->angle = mobjangle + ANGLE_90; base->angle = mobjangle + ANGLE_90;
P_SetScale(base, mobj->scale, true);
base->destscale = mobj->destscale; base->destscale = mobj->destscale;
P_SetScale(base, mobj->scale);
P_SetTarget(&base->target, mobj); P_SetTarget(&base->target, mobj);
P_SetTarget(&mobj->tracer, base); P_SetTarget(&mobj->tracer, base);
} }
@ -13596,8 +13574,9 @@ static mobj_t *P_SpawnMobjFromMapThing(mapthing_t *mthing, fixed_t x, fixed_t y,
return NULL; return NULL;
mobj->spawnpoint = mthing; mobj->spawnpoint = mthing;
P_SetScale(mobj, FixedMul(mobj->scale, mthing->scale)); P_SetScale(mobj, FixedMul(mobj->scale, mthing->scale), false);
mobj->destscale = FixedMul(mobj->destscale, mthing->scale); mobj->destscale = FixedMul(mobj->destscale, mthing->scale);
mobj->old_scale = FixedMul(mobj->old_scale, mthing->scale);
mobj->spritexscale = mthing->spritexscale; mobj->spritexscale = mthing->spritexscale;
mobj->spriteyscale = mthing->spriteyscale; mobj->spriteyscale = mthing->spriteyscale;
@ -14050,8 +14029,7 @@ mobj_t *P_SpawnXYZMissile(mobj_t *source, mobj_t *dest, mobjtype_t type,
if (source->eflags & MFE_VERTICALFLIP) if (source->eflags & MFE_VERTICALFLIP)
th->flags2 |= MF2_OBJECTFLIP; th->flags2 |= MF2_OBJECTFLIP;
th->destscale = source->scale; P_SetScale(th, source->scale, true);
P_SetScale(th, source->scale);
speed = FixedMul(th->info->speed, th->scale); speed = FixedMul(th->info->speed, th->scale);
@ -14114,8 +14092,7 @@ mobj_t *P_SpawnAlteredDirectionMissile(mobj_t *source, mobjtype_t type, fixed_t
if (source->eflags & MFE_VERTICALFLIP) if (source->eflags & MFE_VERTICALFLIP)
th->flags2 |= MF2_OBJECTFLIP; th->flags2 |= MF2_OBJECTFLIP;
th->destscale = source->scale; P_SetScale(th, source->scale, true);
P_SetScale(th, source->scale);
speed = FixedMul(th->info->speed, th->scale); speed = FixedMul(th->info->speed, th->scale);
@ -14181,8 +14158,7 @@ mobj_t *P_SpawnPointMissile(mobj_t *source, fixed_t xa, fixed_t ya, fixed_t za,
if (source->eflags & MFE_VERTICALFLIP) if (source->eflags & MFE_VERTICALFLIP)
th->flags2 |= MF2_OBJECTFLIP; th->flags2 |= MF2_OBJECTFLIP;
th->destscale = source->scale; P_SetScale(th, source->scale, true);
P_SetScale(th, source->scale);
speed = FixedMul(th->info->speed, th->scale); speed = FixedMul(th->info->speed, th->scale);
@ -14253,8 +14229,7 @@ mobj_t *P_SpawnMissile(mobj_t *source, mobj_t *dest, mobjtype_t type)
if (source->eflags & MFE_VERTICALFLIP) if (source->eflags & MFE_VERTICALFLIP)
th->flags2 |= MF2_OBJECTFLIP; th->flags2 |= MF2_OBJECTFLIP;
th->destscale = source->scale; P_SetScale(th, source->scale, true);
P_SetScale(th, source->scale);
if (source->type == MT_METALSONIC_BATTLE && source->health < 4) if (source->type == MT_METALSONIC_BATTLE && source->health < 4)
speed = FixedMul(FixedMul(th->info->speed, 3*FRACUNIT/2), th->scale); speed = FixedMul(FixedMul(th->info->speed, 3*FRACUNIT/2), th->scale);
@ -14356,8 +14331,7 @@ mobj_t *P_SPMAngle(mobj_t *source, mobjtype_t type, angle_t angle, UINT8 allowai
if (source->eflags & MFE_VERTICALFLIP) if (source->eflags & MFE_VERTICALFLIP)
th->flags2 |= MF2_OBJECTFLIP; th->flags2 |= MF2_OBJECTFLIP;
th->destscale = source->scale; P_SetScale(th, source->scale, true);
P_SetScale(th, source->scale);
th->flags2 |= flags2; th->flags2 |= flags2;
@ -14439,8 +14413,8 @@ mobj_t *P_SpawnMobjFromMobj(mobj_t *mobj, fixed_t xofs, fixed_t yofs, fixed_t zo
newmobj->old_z2 = mobj->old_z2 + zofs; newmobj->old_z2 = mobj->old_z2 + zofs;
} }
P_SetScale(newmobj, mobj->scale, false);
newmobj->destscale = mobj->destscale; newmobj->destscale = mobj->destscale;
P_SetScale(newmobj, mobj->scale);
newmobj->old_x2 = mobj->old_x2 + xofs; newmobj->old_x2 = mobj->old_x2 + xofs;
newmobj->old_y2 = mobj->old_y2 + yofs; newmobj->old_y2 = mobj->old_y2 + yofs;

View file

@ -510,7 +510,7 @@ void P_SnowThinker(precipmobj_t *mobj);
void P_RainThinker(precipmobj_t *mobj); void P_RainThinker(precipmobj_t *mobj);
void P_NullPrecipThinker(precipmobj_t *mobj); void P_NullPrecipThinker(precipmobj_t *mobj);
void P_RemovePrecipMobj(precipmobj_t *mobj); void P_RemovePrecipMobj(precipmobj_t *mobj);
void P_SetScale(mobj_t *mobj, fixed_t newscale); void P_SetScale(mobj_t *mobj, fixed_t newscale, boolean instant);
void P_XYMovement(mobj_t *mo); void P_XYMovement(mobj_t *mo);
void P_RingXYMovement(mobj_t *mo); void P_RingXYMovement(mobj_t *mo);
void P_SceneryXYMovement(mobj_t *mo); void P_SceneryXYMovement(mobj_t *mo);

View file

@ -2037,8 +2037,7 @@ mobj_t *P_SpawnGhostMobj(mobj_t *mobj)
P_SetTarget(&ghost->target, mobj); P_SetTarget(&ghost->target, mobj);
P_SetTarget(&ghost->dontdrawforviewmobj, mobj); // Hide the ghost in first-person P_SetTarget(&ghost->dontdrawforviewmobj, mobj); // Hide the ghost in first-person
P_SetScale(ghost, mobj->scale); P_SetScale(ghost, mobj->scale, true);
ghost->destscale = mobj->scale;
if (mobj->eflags & MFE_VERTICALFLIP) if (mobj->eflags & MFE_VERTICALFLIP)
{ {
@ -2096,6 +2095,7 @@ mobj_t *P_SpawnGhostMobj(mobj_t *mobj)
ghost->old_pitch = mobj->old_pitch2; ghost->old_pitch = mobj->old_pitch2;
ghost->old_roll = mobj->old_roll2; ghost->old_roll = mobj->old_roll2;
ghost->old_spriteroll = mobj->old_spriteroll2; ghost->old_spriteroll = mobj->old_spriteroll2;
ghost->old_scale = mobj->old_scale2;
return ghost; return ghost;
} }
@ -2151,7 +2151,7 @@ void P_SpawnThokMobj(player_t *player)
mobj->eflags |= (player->mo->eflags & MFE_VERTICALFLIP); mobj->eflags |= (player->mo->eflags & MFE_VERTICALFLIP);
// scale // scale
P_SetScale(mobj, (mobj->destscale = player->mo->scale)); P_SetScale(mobj, player->mo->scale, true);
if (type == MT_THOK) // spintrail-specific modification for MT_THOK if (type == MT_THOK) // spintrail-specific modification for MT_THOK
{ {
@ -2215,8 +2215,7 @@ void P_SpawnSpinMobj(player_t *player, mobjtype_t type)
mobj->eflags |= (player->mo->eflags & MFE_VERTICALFLIP); mobj->eflags |= (player->mo->eflags & MFE_VERTICALFLIP);
// scale // scale
P_SetScale(mobj, player->mo->scale); P_SetScale(mobj, player->mo->scale, true);
mobj->destscale = player->mo->scale;
if (type == MT_THOK) // spintrail-specific modification for MT_THOK if (type == MT_THOK) // spintrail-specific modification for MT_THOK
{ {
@ -3035,9 +3034,8 @@ static void P_CheckUnderwaterAndSpaceTimer(player_t *player)
P_SetMobjState(numbermobj, numbermobj->info->spawnstate+timeleft); P_SetMobjState(numbermobj, numbermobj->info->spawnstate+timeleft);
P_SetTarget(&numbermobj->target, player->mo); P_SetTarget(&numbermobj->target, player->mo);
P_SetScale(numbermobj, player->mo->scale, true);
numbermobj->threshold = 40; numbermobj->threshold = 40;
numbermobj->destscale = player->mo->scale;
P_SetScale(numbermobj, player->mo->scale);
} }
} }
} }
@ -3099,10 +3097,7 @@ static void P_CheckInvincibilityTimer(player_t *player)
{ {
mobj_t *sparkle = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_IVSP); mobj_t *sparkle = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_IVSP);
if (!P_MobjWasRemoved(sparkle)) if (!P_MobjWasRemoved(sparkle))
{ P_SetScale(sparkle, player->mo->scale, true);
sparkle->destscale = player->mo->scale;
P_SetScale(sparkle, player->mo->scale);
}
} }
// Resume normal music stuff. // Resume normal music stuff.
@ -3177,8 +3172,7 @@ static void P_DoBubbleBreath(player_t *player)
if (bubble) if (bubble)
{ {
bubble->threshold = 42; bubble->threshold = 42;
bubble->destscale = player->mo->scale; P_SetScale(bubble, player->mo->scale, true);
P_SetScale(bubble, bubble->destscale);
} }
// Tails stirs up the water while flying in it // Tails stirs up the water while flying in it
@ -3200,20 +3194,14 @@ static void P_DoBubbleBreath(player_t *player)
player->mo->y + stirwatery, player->mo->y + stirwatery,
stirwaterz, MT_SMALLBUBBLE); stirwaterz, MT_SMALLBUBBLE);
if (!P_MobjWasRemoved(bubble)) if (!P_MobjWasRemoved(bubble))
{ P_SetScale(bubble, player->mo->scale, true);
bubble->destscale = player->mo->scale;
P_SetScale(bubble,bubble->destscale);
}
bubble = P_SpawnMobj( bubble = P_SpawnMobj(
player->mo->x - stirwaterx, player->mo->x - stirwaterx,
player->mo->y - stirwatery, player->mo->y - stirwatery,
stirwaterz, MT_SMALLBUBBLE); stirwaterz, MT_SMALLBUBBLE);
if (!P_MobjWasRemoved(bubble)) if (!P_MobjWasRemoved(bubble))
{ P_SetScale(bubble, player->mo->scale, true);
bubble->destscale = player->mo->scale;
P_SetScale(bubble,bubble->destscale);
}
} }
} }
@ -4421,10 +4409,7 @@ static void P_DoSuperStuff(player_t *player)
{ {
spark = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_SUPERSPARK); spark = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_SUPERSPARK);
if (!P_MobjWasRemoved(spark)) if (!P_MobjWasRemoved(spark))
{ P_SetScale(spark, player->mo->scale, true);
spark->destscale = player->mo->scale;
P_SetScale(spark, player->mo->scale);
}
} }
// Ran out of rings while super! // Ran out of rings while super!
@ -4674,8 +4659,7 @@ void P_DoSpinDashDust(player_t *player)
P_SetMobjState(particle, S_SPINDUST_FIRE1); P_SetMobjState(particle, S_SPINDUST_FIRE1);
P_SetTarget(&particle->target, player->mo); P_SetTarget(&particle->target, player->mo);
particle->destscale = (2*player->mo->scale)/3; P_SetScale(particle, (2*player->mo->scale)/3, true);
P_SetScale(particle, particle->destscale);
if (player->mo->eflags & MFE_VERTICALFLIP) // readjust z position if needed if (player->mo->eflags & MFE_VERTICALFLIP) // readjust z position if needed
particle->z = player->mo->z + player->mo->height - particle->height; particle->z = player->mo->z + player->mo->height - particle->height;
prandom[0] = P_RandomFixed()<<2; // P_RandomByte()<<10 prandom[0] = P_RandomFixed()<<2; // P_RandomByte()<<10
@ -5074,7 +5058,7 @@ void P_TwinSpinRejuvenate(player_t *player, mobjtype_t type)
if (!P_MobjWasRemoved(missile)) if (!P_MobjWasRemoved(missile))
{ {
P_SetTarget(&missile->target, player->mo); P_SetTarget(&missile->target, player->mo);
P_SetScale(missile, (missile->destscale >>= 1)); P_SetScale(missile, missile->destscale/2, true);
missile->angle = ang + movang; missile->angle = ang + movang;
missile->fuse = TICRATE/2; missile->fuse = TICRATE/2;
missile->extravalue2 = (99*FRACUNIT)/100; missile->extravalue2 = (99*FRACUNIT)/100;
@ -7414,9 +7398,8 @@ static void P_NiGHTSMovement(player_t *player)
firstmobj = P_SpawnMobj(player->mo->x + P_ReturnThrustX(player->mo, player->mo->angle+ANGLE_90, spawndist), player->mo->y + P_ReturnThrustY(player->mo, player->mo->angle+ANGLE_90, spawndist), z, MT_NIGHTSPARKLE); firstmobj = P_SpawnMobj(player->mo->x + P_ReturnThrustX(player->mo, player->mo->angle+ANGLE_90, spawndist), player->mo->y + P_ReturnThrustY(player->mo, player->mo->angle+ANGLE_90, spawndist), z, MT_NIGHTSPARKLE);
if (!P_MobjWasRemoved(firstmobj)) if (!P_MobjWasRemoved(firstmobj))
{ {
firstmobj->destscale = player->mo->scale;
P_SetTarget(&firstmobj->target, player->mo); P_SetTarget(&firstmobj->target, player->mo);
P_SetScale(firstmobj, player->mo->scale); P_SetScale(firstmobj, player->mo->scale, true);
// Superloop turns sparkles red // Superloop turns sparkles red
if (player->powers[pw_nights_superloop]) if (player->powers[pw_nights_superloop])
P_SetMobjState(firstmobj, mobjinfo[MT_NIGHTSPARKLE].seestate); P_SetMobjState(firstmobj, mobjinfo[MT_NIGHTSPARKLE].seestate);
@ -7424,10 +7407,8 @@ static void P_NiGHTSMovement(player_t *player)
secondmobj = P_SpawnMobj(player->mo->x + P_ReturnThrustX(player->mo, player->mo->angle-ANGLE_90, spawndist), player->mo->y + P_ReturnThrustY(player->mo, player->mo->angle-ANGLE_90, spawndist), z, MT_NIGHTSPARKLE); secondmobj = P_SpawnMobj(player->mo->x + P_ReturnThrustX(player->mo, player->mo->angle-ANGLE_90, spawndist), player->mo->y + P_ReturnThrustY(player->mo, player->mo->angle-ANGLE_90, spawndist), z, MT_NIGHTSPARKLE);
if (!P_MobjWasRemoved(secondmobj)) if (!P_MobjWasRemoved(secondmobj))
{ {
secondmobj->destscale = player->mo->scale;
P_SetTarget(&secondmobj->target, player->mo); P_SetTarget(&secondmobj->target, player->mo);
P_SetScale(secondmobj, player->mo->scale); P_SetScale(secondmobj, player->mo->scale, true);
// Superloop turns sparkles red // Superloop turns sparkles red
if (player->powers[pw_nights_superloop]) if (player->powers[pw_nights_superloop])
P_SetMobjState(secondmobj, mobjinfo[MT_NIGHTSPARKLE].seestate); P_SetMobjState(secondmobj, mobjinfo[MT_NIGHTSPARKLE].seestate);
@ -7442,7 +7423,7 @@ static void P_NiGHTSMovement(player_t *player)
{ {
helpermobj->fuse = player->mo->fuse = leveltime; helpermobj->fuse = player->mo->fuse = leveltime;
P_SetTarget(&helpermobj->target, player->mo); P_SetTarget(&helpermobj->target, player->mo);
P_SetScale(helpermobj, player->mo->scale); P_SetScale(helpermobj, player->mo->scale, false);
} }
} }
@ -7645,8 +7626,7 @@ static void P_NiGHTSMovement(player_t *player)
water->flags2 |= MF2_OBJECTFLIP; water->flags2 |= MF2_OBJECTFLIP;
water->eflags |= MFE_VERTICALFLIP; water->eflags |= MFE_VERTICALFLIP;
} }
water->destscale = player->mo->scale; P_SetScale(water, player->mo->scale, true);
P_SetScale(water, player->mo->scale);
} }
} }
@ -7886,8 +7866,7 @@ void P_ElementalFire(player_t *player, boolean cropcircle)
P_SetTarget(&flame->target, player->mo); P_SetTarget(&flame->target, player->mo);
flame->angle = travelangle + i*(ANGLE_MAX/numangles); flame->angle = travelangle + i*(ANGLE_MAX/numangles);
flame->fuse = TICRATE*7; // takes about an extra second to hit the ground flame->fuse = TICRATE*7; // takes about an extra second to hit the ground
flame->destscale = player->mo->scale; P_SetScale(flame, player->mo->scale, true);
P_SetScale(flame, player->mo->scale);
if (!(player->mo->flags2 & MF2_OBJECTFLIP) != !(player->powers[pw_gravityboots])) // take gravity boots into account if (!(player->mo->flags2 & MF2_OBJECTFLIP) != !(player->powers[pw_gravityboots])) // take gravity boots into account
flame->flags2 |= MF2_OBJECTFLIP; flame->flags2 |= MF2_OBJECTFLIP;
flame->eflags = (flame->eflags & ~MFE_VERTICALFLIP)|(player->mo->eflags & MFE_VERTICALFLIP); flame->eflags = (flame->eflags & ~MFE_VERTICALFLIP)|(player->mo->eflags & MFE_VERTICALFLIP);
@ -7924,8 +7903,7 @@ void P_ElementalFire(player_t *player, boolean cropcircle)
P_SetTarget(&flame->target, player->mo); P_SetTarget(&flame->target, player->mo);
flame->angle = travelangle; flame->angle = travelangle;
flame->fuse = TICRATE*6; flame->fuse = TICRATE*6;
flame->destscale = player->mo->scale; P_SetScale(flame, player->mo->scale, true);
P_SetScale(flame, player->mo->scale);
if (!(player->mo->flags2 & MF2_OBJECTFLIP) != !(player->powers[pw_gravityboots])) // take gravity boots into account if (!(player->mo->flags2 & MF2_OBJECTFLIP) != !(player->powers[pw_gravityboots])) // take gravity boots into account
flame->flags2 |= MF2_OBJECTFLIP; flame->flags2 |= MF2_OBJECTFLIP;
flame->eflags = (flame->eflags & ~MFE_VERTICALFLIP)|(player->mo->eflags & MFE_VERTICALFLIP); flame->eflags = (flame->eflags & ~MFE_VERTICALFLIP)|(player->mo->eflags & MFE_VERTICALFLIP);
@ -7973,8 +7951,7 @@ void P_SpawnSkidDust(player_t *player, fixed_t radius, boolean sound)
} }
particle->tics = 10; particle->tics = 10;
particle->destscale = (2*mo->scale)/3; P_SetScale(particle, (2*mo->scale)/3, true);
P_SetScale(particle, particle->destscale);
P_SetObjectMomZ(particle, FRACUNIT, false); P_SetObjectMomZ(particle, FRACUNIT, false);
if (mo->eflags & (MFE_TOUCHWATER|MFE_UNDERWATER)) // overrides fire version if (mo->eflags & (MFE_TOUCHWATER|MFE_UNDERWATER)) // overrides fire version
@ -8563,8 +8540,7 @@ void P_MovePlayer(player_t *player)
water->flags2 |= MF2_OBJECTFLIP; water->flags2 |= MF2_OBJECTFLIP;
water->eflags |= MFE_VERTICALFLIP; water->eflags |= MFE_VERTICALFLIP;
} }
water->destscale = player->mo->scale; P_SetScale(water, player->mo->scale, true);
P_SetScale(water, player->mo->scale);
} }
} }
@ -10998,8 +10974,7 @@ static void P_SpawnSparks(mobj_t *mo, angle_t maindir)
spark->momz = mo->momz + r3; spark->momz = mo->momz + r3;
P_Thrust(spark, R_PointToAngle2(mo->x, mo->y, spark->x, spark->y), 8*FRACUNIT); P_Thrust(spark, R_PointToAngle2(mo->x, mo->y, spark->x, spark->y), 8*FRACUNIT);
P_SetScale(spark, FRACUNIT/4); P_SetScale(spark, FRACUNIT/4, true);
spark->destscale = spark->scale;
spark->fuse = TICRATE/3; spark->fuse = TICRATE/3;
} }
@ -11470,8 +11445,9 @@ void P_DoTailsOverlay(player_t *player, mobj_t *tails)
tails->threshold = player->mo->z; tails->threshold = player->mo->z;
tails->movecount = player->panim; tails->movecount = player->panim;
tails->angle = horizangle; tails->angle = horizangle;
P_SetScale(tails, player->mo->scale); P_SetScale(tails, player->mo->scale, false);
tails->destscale = player->mo->destscale; tails->destscale = player->mo->destscale;
tails->old_scale = player->mo->old_scale;
tails->radius = player->mo->radius; tails->radius = player->mo->radius;
tails->height = player->mo->height; tails->height = player->mo->height;
zoffs = FixedMul(zoffs, tails->scale); zoffs = FixedMul(zoffs, tails->scale);
@ -11562,7 +11538,9 @@ void P_DoMetalJetFume(player_t *player, mobj_t *fume)
y = mo->y + radiusY + FixedMul(offsetH, factorY); y = mo->y + radiusY + FixedMul(offsetH, factorY);
z = mo->z + heightoffset + offsetV; z = mo->z + heightoffset + offsetV;
bubble = P_SpawnMobj(x, y, z, MT_SMALLBUBBLE); bubble = P_SpawnMobj(x, y, z, MT_SMALLBUBBLE);
bubble->scale = mo->scale >> 1; P_SetScale(bubble, mo->scale/2, true);
bubble->destscale = mo->scale;
bubble->scalespeed = FixedMul(bubble->scalespeed, mo->scale);
P_SetTarget(&bubble->dontdrawforviewmobj, mo); // Hide the bubble in first-person P_SetTarget(&bubble->dontdrawforviewmobj, mo); // Hide the bubble in first-person
} }
@ -11583,7 +11561,7 @@ void P_DoMetalJetFume(player_t *player, mobj_t *fume)
if (stat == fume->info->spawnstate) // If currently inivisble, activate! if (stat == fume->info->spawnstate) // If currently inivisble, activate!
{ {
P_SetMobjState(fume, (stat = fume->info->seestate)); P_SetMobjState(fume, (stat = fume->info->seestate));
P_SetScale(fume, mo->scale); P_SetScale(fume, mo->scale, false);
resetinterp = true; resetinterp = true;
} }
@ -11598,7 +11576,7 @@ void P_DoMetalJetFume(player_t *player, mobj_t *fume)
if (dashmode == DASHMODE_THRESHOLD && dashmode > (tic_t)fume->movecount) // If just about to enter dashmode, play the startup animation again if (dashmode == DASHMODE_THRESHOLD && dashmode > (tic_t)fume->movecount) // If just about to enter dashmode, play the startup animation again
{ {
P_SetMobjState(fume, (stat = fume->info->seestate)); P_SetMobjState(fume, (stat = fume->info->seestate));
P_SetScale(fume, mo->scale << 1); P_SetScale(fume, 2*mo->scale, true);
} }
fume->flags2 = (fume->flags2 & ~MF2_DONTDRAW) | (mo->flags2 & MF2_DONTDRAW); fume->flags2 = (fume->flags2 & ~MF2_DONTDRAW) | (mo->flags2 & MF2_DONTDRAW);
fume->destscale = (mo->scale + FixedDiv(player->speed, player->normalspeed)) / (underwater ? 6 : 3); fume->destscale = (mo->scale + FixedDiv(player->speed, player->normalspeed)) / (underwater ? 6 : 3);

View file

@ -374,7 +374,7 @@ static void SetSkin(player_t *player, INT32 skinnum)
player->mo->skin = skin; player->mo->skin = skin;
if (newcolor) if (newcolor)
player->mo->color = newcolor; player->mo->color = newcolor;
P_SetScale(player->mo, player->mo->scale); P_SetScale(player->mo, player->mo->scale, false);
player->mo->radius = radius; player->mo->radius = radius;
P_SetMobjState(player->mo, player->mo->state-states); // Prevent visual errors when switching between skins with differing number of frames P_SetMobjState(player->mo, player->mo->state-states); // Prevent visual errors when switching between skins with differing number of frames