Capsules FINALLY spawn properly on FOFs, and aerial capsules scale from the bottoms instead of their centers

This commit is contained in:
lachablock 2021-06-21 15:10:57 +10:00
parent 90269c1a91
commit baae615d08
2 changed files with 25 additions and 9 deletions

View file

@ -284,7 +284,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
if ((gametyperules & GTR_BUMPERS) && player->bumpers <= 0) if ((gametyperules & GTR_BUMPERS) && player->bumpers <= 0)
return; return;
if (special->scale < special->destscale) // don't break it while it's respawning if (special->scale < special->extravalue1) // don't break it while it's respawning
return; return;
S_StartSound(toucher, special->info->deathsound); S_StartSound(toucher, special->info->deathsound);

View file

@ -6139,6 +6139,21 @@ static boolean P_MobjRegularThink(mobj_t *mobj)
break; break;
} }
case MT_ITEMCAPSULE: case MT_ITEMCAPSULE:
// scale the capsule
if (mobj->scale < mobj->extravalue1)
{
fixed_t oldHeight = mobj->height;
if ((mobj->extravalue1 - mobj->scale) < mobj->scalespeed)
P_SetScale(mobj, mobj->destscale = mobj->extravalue1);
else
P_SetScale(mobj, mobj->destscale = mobj->scale + mobj->scalespeed);
if (mobj->eflags & MFE_VERTICALFLIP)
mobj->z -= (mobj->height - oldHeight);
}
// update & animate capsule
if (!P_MobjWasRemoved(mobj->tracer)) if (!P_MobjWasRemoved(mobj->tracer))
{ {
mobj_t *part = mobj->tracer; mobj_t *part = mobj->tracer;
@ -9434,17 +9449,18 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
mobj->movecount = 1; mobj->movecount = 1;
#endif #endif
// set starting scale
mobj->scalespeed >>= 1;
P_SetScale(mobj, mapobjectscale >> 4);
if (mobj->eflags & MFE_VERTICALFLIP)
mobj->z += (oldHeight - mobj->height);
// grounded/aerial properties // grounded/aerial properties
P_CheckPosition(mobj, mobj->x, mobj->y); // look for FOFs P_AdjustMobjFloorZ_FFloors(mobj, mobj->subsector->sector, 0);
if (!P_IsObjectOnGround(mobj)) if (!P_IsObjectOnGround(mobj))
mobj->flags |= MF_NOGRAVITY; mobj->flags |= MF_NOGRAVITY;
// set starting scale
mobj->extravalue1 = mobj->scale; // this acts as the capsule's destscale; we're avoiding P_MobjScaleThink because we want aerial capsules not to scale from their center
mobj->scalespeed >>= 1;
P_SetScale(mobj, mobj->destscale = mapobjectscale >> 4);
if (mobj->eflags & MFE_VERTICALFLIP)
mobj->z += (oldHeight - mobj->height);
break; break;
} }
case MT_KARMAHITBOX: case MT_KARMAHITBOX:
@ -11718,7 +11734,7 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj, boolean
// Ambush = double size (grounded) / half size (aerial) // Ambush = double size (grounded) / half size (aerial)
if (!(mthing->options & MTF_AMBUSH) == !P_IsObjectOnGround(mobj)) if (!(mthing->options & MTF_AMBUSH) == !P_IsObjectOnGround(mobj))
{ {
mobj->destscale = min(mobj->destscale << 1, FixedDiv(64*FRACUNIT, mobj->info->radius)); // don't make them larger than the blockmap can handle mobj->extravalue1 = min(mobj->extravalue1 << 1, FixedDiv(64*FRACUNIT, mobj->info->radius)); // don't make them larger than the blockmap can handle
mobj->scalespeed <<= 1; mobj->scalespeed <<= 1;
} }
break; break;