Update capsule parts

- The pieces do the positioning, instead of the capsule itself. This makes it so that the parts update after the capsule has applied its momentum.
- Use proper inradius instead, so the sides line up.
- Because of the above change, the capsule as a whole is bigger. This means...
- Increased hitbox again
- Changed a few of the sprites
This commit is contained in:
Sally Coolatta 2022-12-03 04:25:34 -05:00
parent d6bd869b92
commit 226cb7d736
2 changed files with 107 additions and 66 deletions

View file

@ -28661,7 +28661,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] =
S_NULL, // xdeathstate
sfx_None, // deathsound
0, // speed
56<<FRACBITS, // radius
64<<FRACBITS, // radius
144<<FRACBITS, // height
0, // display offset
100, // mass

View file

@ -6384,15 +6384,121 @@ static void P_MobjSceneryThink(mobj_t *mobj)
break;
case MT_BATTLECAPSULE_PIECE:
if (mobj->extravalue2)
{
mobj->frame |= FF_VERTICALFLIP;
}
else
{
mobj->frame &= ~FF_VERTICALFLIP;
}
if (mobj->flags2 & MF2_OBJECTFLIP)
{
mobj->eflags |= MFE_VERTICALFLIP;
}
if (mobj->tics > 0)
{
// Despawning.
mobj->renderflags ^= RF_DONTDRAW;
}
else
{
statenum_t state = (statenum_t)(mobj->state - states);
mobj_t *owner = mobj->target;
fixed_t newx, newy, newz;
SINT8 flip;
if (owner == NULL || P_MobjWasRemoved(owner) == true)
{
// Exit early.
break;
}
newx = owner->x;
newy = owner->y;
newz = P_GetMobjFeet(owner);
flip = P_MobjFlip(owner); // Flying capsules needs flipped sprites, but not flipped gravity
if (owner->extravalue1)
{
flip = -flip;
newz += owner->height;
}
mobj->scale = owner->scale;
mobj->destscale = owner->destscale;
mobj->scalespeed = owner->scalespeed;
mobj->extravalue2 = owner->extravalue1;
mobj->flags2 = (mobj->flags2 & ~MF2_OBJECTFLIP) | (owner->flags2 & MF2_OBJECTFLIP);
switch (state)
{
case S_BATTLECAPSULE_TOP:
{
newz += (80 * owner->scale * flip);
break;
}
case S_BATTLECAPSULE_BUTTON:
{
newz += (120 * owner->scale * flip);
break;
}
case S_BATTLECAPSULE_SUPPORT:
case S_BATTLECAPSULE_SUPPORTFLY:
case S_KARMAWHEEL:
{
fixed_t offx = 36 * owner->scale;
fixed_t offy = 36 * owner->scale;
if (mobj->extravalue1 & 1)
{
offx = -offx;
}
if (mobj->extravalue1 > 1)
{
offy = -offy;
}
newx += offx;
newy += offy;
break;
}
case S_BATTLECAPSULE_SIDE1:
case S_BATTLECAPSULE_SIDE2:
{
#define inradius 3797355 // Precalculated
#ifndef inradius
fixed_t inradius = FixedDiv(48 << FRACBITS, 2 * FINETANGENT((((ANGLE_180 / 8) + ANGLE_90) >> ANGLETOFINESHIFT) & 4095));
#endif
fixed_t offset = FixedMul(inradius, owner->scale);
angle_t angle = (ANGLE_45 * mobj->extravalue1);
newx += FixedMul(offset, FINECOSINE(angle >> ANGLETOFINESHIFT));
newy += FixedMul(offset, FINESINE(angle >> ANGLETOFINESHIFT));
newz += (12 * owner->scale * flip);
mobj->angle = angle + ANGLE_90;
break;
#undef inradius
}
default:
{
break;
}
}
mobj->momx = newx - mobj->x;
mobj->momy = newy - mobj->y;
mobj->momz = newz - mobj->z;
}
break;
case MT_SPINDASHWIND:
case MT_DRIFTELECTRICSPARK:
@ -9039,8 +9145,6 @@ static boolean P_MobjRegularThink(mobj_t *mobj)
{
SINT8 realflip = P_MobjFlip(mobj);
SINT8 flip = realflip; // Flying capsules needs flipped sprites, but not flipped gravity
fixed_t bottom;
mobj_t *cur;
if (mobj->extravalue1)
{
@ -9145,69 +9249,6 @@ static boolean P_MobjRegularThink(mobj_t *mobj)
}
}
}
if (flip == -1)
bottom = mobj->z + mobj->height;
else
bottom = mobj->z;
cur = mobj->hnext;
// Move each piece to the proper position
while (cur && !P_MobjWasRemoved(cur))
{
fixed_t newx = mobj->x + mobj->momx;
fixed_t newy = mobj->y + mobj->momy;
fixed_t newz = bottom + mobj->momz;
statenum_t state = (statenum_t)(cur->state-states);
cur->scale = mobj->scale;
cur->destscale = mobj->destscale;
cur->scalespeed = mobj->scalespeed;
cur->extravalue2 = mobj->extravalue1;
cur->flags2 = (cur->flags2 & ~MF2_OBJECTFLIP)|(mobj->flags2 & MF2_OBJECTFLIP);
if (state == S_BATTLECAPSULE_TOP)
newz += (80 * mobj->scale * flip);
else if (state == S_BATTLECAPSULE_BUTTON)
newz += (108 * mobj->scale * flip);
else if (state == S_BATTLECAPSULE_SUPPORT
|| state == S_BATTLECAPSULE_SUPPORTFLY
|| state == S_KARMAWHEEL)
{
fixed_t offx = 28 * mobj->scale;
fixed_t offy = 28 * mobj->scale;
if (cur->extravalue1 & 1)
offx = -offx;
if (cur->extravalue1 > 1)
offy = -offy;
newx += offx;
newy += offy;
}
else if (state == S_BATTLECAPSULE_SIDE1
|| state == S_BATTLECAPSULE_SIDE2)
{
fixed_t offset = 48 * mobj->scale;
angle_t angle = (ANGLE_45 * cur->extravalue1);
newx += FixedMul(offset, FINECOSINE(angle >> ANGLETOFINESHIFT));
newy += FixedMul(offset, FINESINE(angle >> ANGLETOFINESHIFT));
newz += (12 * mobj->scale * flip);
cur->angle = angle + ANGLE_90;
}
cur->momx = newx - cur->x;
cur->momy = newy - cur->y;
cur->momz = newz - cur->z;
cur = cur->hnext;
}
}
break;
case MT_RANDOMITEM: