tiny cleanup some stuff

This commit is contained in:
alufolie91 committed 2026-06-18 16:47:27 +02:00
1 parent 8de01bf5fe
commit 1b6bfda501
4 files changed
+133 -112

No files matched your search

+13 -8
View File
@@ -644,20 +644,22 @@ static int libd_drawScaled(lua_State *L)
// KART: draw patch on minimap from x, y coordinates on the map
static int libd_drawOnMinimap(lua_State *L)
{
fixed_t x, y, scale; // coordinates of the object
patch_t *patch; // patch we want to draw
UINT8 *colormap = NULL; // do we want to colormap this patch?
boolean centered; // the patch is centered and doesn't need readjusting on x/y coordinates.
fixed_t x, y, scale; // coordinates of the object
patch_t *patch; // patch we want to draw
UINT8 *colormap = NULL; // do we want to colormap this patch?
boolean centered; // the patch is centered and doesn't need readjusting on x/y coordinates.
huddrawlist_h list;
patch_t *AutomapPic = NULL;
drawinfo_t info;
// variables used to replicate k_kart's mmap drawer:
patch_t *AutomapPic;
// variables used for actually drawing the icon:
INT32 splitflags, minimaptrans;
fixed_t amnumxpos, amnumypos;
fixed_t amxpos, amypos;
INT32 mm_x, mm_y;
fixed_t patchw = 0, patchh = 0;
fixed_t patchw, patchh;
HUDONLY // only run this function in hud hooks
@@ -722,8 +724,11 @@ static int libd_drawOnMinimap(lua_State *L)
mm_y -= AutomapPic->topoffset;
// patch is supposedly already centered, don't butt in.
if (!centered)
if (centered)
{
patchw = patchh = 0; // patch is supposedly already centered, don't butt in.
}
else
{
// scale patch coords
patchw = (patch->width * scale / 2);
+2 -2
View File
@@ -2338,7 +2338,7 @@ void T_RaiseSector(levelspecthink_t *raise)
fixed_t origspeed = raise->vars[3];
// Slow down as you get closer to the bottom
raise->vars[3] = FixedMul(raise->vars[3],FixedDiv(raise->sector->ceilingheight - raise->vars[7], (raise->vars[5] - raise->vars[7])>>5));
raise->vars[3] = FixedMul(raise->vars[3], FixedDiv(raise->sector->ceilingheight - raise->vars[7], (raise->vars[5] - raise->vars[7])>>5));
if (raise->vars[3] <= origspeed/16)
raise->vars[3] = origspeed/16;
@@ -2349,7 +2349,7 @@ void T_RaiseSector(levelspecthink_t *raise)
{
fixed_t origspeed = raise->vars[3];
// Slow down as you get closer to the top
raise->vars[3] = FixedMul(raise->vars[3],FixedDiv(raise->vars[5] - raise->sector->ceilingheight, (raise->vars[5] - raise->vars[7])>>5));
raise->vars[3] = FixedMul(raise->vars[3], FixedDiv(raise->vars[5] - raise->sector->ceilingheight, (raise->vars[5] - raise->vars[7])>>5));
if (raise->vars[3] <= origspeed/16)
raise->vars[3] = origspeed/16;
+8 -4
View File
@@ -719,11 +719,11 @@ static boolean PIT_CheckThing(mobj_t *thing)
if (thing->type != MT_PLAYER)
return true;
if (thing->player && thing->player->powers[pw_flashing])
return true;
if (thing->type == MT_PLAYER && thing->player)
if (thing->player)
{
if (thing->player->powers[pw_flashing])
return true;
if (tmthing->state == &states[S_MINEEXPLOSION1])
K_ExplodePlayer(thing->player, tmthing->target, tmthing);
else
@@ -1077,6 +1077,7 @@ static boolean PIT_CheckThing(mobj_t *thing)
thing->momy -= FixedMul(PUSHACCEL, thing->scale);
tmthing->momy += FixedMul(PUSHACCEL, thing->scale);
}
if (tmthing->momx > 0 && tmthing->momx > FixedMul(4*FRACUNIT, thing->scale)
&& tmthing->momx > thing->momx)
{
@@ -1094,6 +1095,7 @@ static boolean PIT_CheckThing(mobj_t *thing)
thing->momx = FixedMul(thing->info->speed, thing->scale);
else if (thing->momx < -FixedMul(thing->info->speed, thing->scale))
thing->momx = -FixedMul(thing->info->speed, thing->scale);
if (thing->momy > FixedMul(thing->info->speed, thing->scale))
thing->momy = FixedMul(thing->info->speed, thing->scale);
else if (thing->momy < -FixedMul(thing->info->speed, thing->scale))
@@ -1105,6 +1107,7 @@ static boolean PIT_CheckThing(mobj_t *thing)
tmthing->momx = FixedMul(4*FRACUNIT, thing->scale);
else if (tmthing->momx < FixedMul(-4*FRACUNIT, thing->scale))
tmthing->momx = FixedMul(-4*FRACUNIT, thing->scale);
if (tmthing->momy > FixedMul(4*FRACUNIT, thing->scale))
tmthing->momy = FixedMul(4*FRACUNIT, thing->scale);
else if (tmthing->momy < FixedMul(-4*FRACUNIT, thing->scale))
@@ -1126,6 +1129,7 @@ static boolean PIT_CheckThing(mobj_t *thing)
P_TouchSpecialThing(thing, tmthing, true); // can remove thing
return true;
}
// check again for special pickup
if (tmthing->flags & MF_SPECIAL && thing->player)
{
+110 -98
View File
@@ -3045,7 +3045,8 @@ void P_MobjCheckWater(mobj_t *mobj)
if ((mobj->eflags & MFE_VERTICALFLIP) && mobj->ceilingz-mobj->waterbottom <= FixedMul(mobj->info->height, mobj->scale)>>1)
return;
if ((mobj->eflags & MFE_GOOWATER || wasingoo)) { // Decide what happens to your momentum when you enter/leave goopy water.
if ((mobj->eflags & MFE_GOOWATER || wasingoo)) // Decide what happens to your momentum when you enter/leave goopy water.
{
if (P_MobjFlip(mobj)*mobj->momz < 0) // You are entering the goo?
mobj->momz = FixedMul(mobj->momz, FixedDiv(2*FRACUNIT, 5*FRACUNIT)); // kill momentum significantly, to make the goo feel thick.
}
@@ -3059,6 +3060,7 @@ void P_MobjCheckWater(mobj_t *mobj)
{
// Spawn a splash
mobj_t *splish;
if (mobj->eflags & MFE_VERTICALFLIP)
{
splish = P_SpawnMobj(mobj->x, mobj->y, mobj->waterbottom-FixedMul(mobjinfo[MT_SPLISH].height, mobj->scale), MT_SPLISH);
@@ -3067,6 +3069,7 @@ void P_MobjCheckWater(mobj_t *mobj)
}
else
splish = P_SpawnMobj(mobj->x, mobj->y, mobj->watertop, MT_SPLISH);
splish->destscale = mobj->scale;
P_SetScale(splish, mobj->scale);
}
@@ -5256,9 +5259,9 @@ static void P_Boss9Thinker(mobj_t *mobj)
{
// Stunned after vector form
if (mobj->movedir > ANGLE_180)
mobj->angle -= FixedAngle(FixedMul(AngleFixed(InvAngle(mobj->movedir)),FixedDiv(mobj->reactiontime<<FRACBITS,24<<FRACBITS)));
mobj->angle -= FixedAngle(FixedMul(AngleFixed(InvAngle(mobj->movedir)), FixedDiv(mobj->reactiontime<<FRACBITS,24<<FRACBITS)));
else
mobj->angle += FixedAngle(FixedMul(AngleFixed(mobj->movedir),FixedDiv(mobj->reactiontime<<FRACBITS,24<<FRACBITS)));
mobj->angle += FixedAngle(FixedMul(AngleFixed(mobj->movedir), FixedDiv(mobj->reactiontime<<FRACBITS,24<<FRACBITS)));
mobj->reactiontime--;
@@ -5300,99 +5303,99 @@ static void P_Boss9Thinker(mobj_t *mobj)
// It's time to attack! What are we gonna do?!
switch(mobj->movecount)
{
case 0:
default:
// Fly up and prepare for an attack!
// We have to charge up first, so let's go up into the air
P_SetMobjState(mobj, mobj->info->raisestate);
if (mobj->floorz >= mobj->target->floorz)
mobj->watertop = mobj->floorz + 256*FRACUNIT;
else
mobj->watertop = mobj->target->floorz + 256*FRACUNIT;
break;
case 1:
{
// Okay, we're up? Good, time to gather energy...
if (mobj->health > mobj->info->damage)
{ // No more bubble if we're broken (pinch phase)
mobj_t *shield = P_SpawnMobj(mobj->x, mobj->y, mobj->z, MT_MSSHIELD_FRONT);
P_SetTarget(&mobj->tracer, shield);
P_SetTarget(&shield->target, mobj);
}
else
P_LinedefExecute(LE_PINCHPHASE, mobj, NULL);
mobj->fuse = 4*TICRATE;
mobj->flags |= MF_PAIN;
if (mobj->info->attacksound)
S_StartSound(mobj, mobj->info->attacksound);
A_FaceTarget(mobj);
break;
}
case 2:
// We're all charged and ready now! Unleash the fury!!
if (mobj->health > mobj->info->damage)
{
mobj_t *removemobj = mobj->tracer;
P_SetTarget(&mobj->tracer, mobj->hnext);
P_RemoveMobj(removemobj);
}
if (mobj->health <= mobj->info->damage)
{
// Attack 1: Pinball dash!
if (mobj->health == 1)
mobj->movedir = 0;
case 0:
default:
// Fly up and prepare for an attack!
// We have to charge up first, so let's go up into the air
P_SetMobjState(mobj, mobj->info->raisestate);
if (mobj->floorz >= mobj->target->floorz)
mobj->watertop = mobj->floorz + 256*FRACUNIT;
else
mobj->movedir = 2;
if (mobj->info->seesound)
S_StartSound(mobj, mobj->info->seesound);
P_SetMobjState(mobj, mobj->info->seestate);
if (mobj->movedir == 2)
mobj->threshold = 16; // bounce 16 times
else
mobj->threshold = 32; // bounce 32 times
mobj->watertop = mobj->target->floorz + 16*FRACUNIT;
P_LinedefExecute(LE_PINCHPHASE, mobj, NULL);
}
else
mobj->watertop = mobj->target->floorz + 256*FRACUNIT;
break;
case 1:
{
// Attack 2: Energy shot!
mobj->movedir = 1;
if (mobj->health >= 8)
mobj->extravalue1 = 0;
else if (mobj->health >= 5)
mobj->extravalue1 = 2;
else if (mobj->health >= 4)
mobj->extravalue1 = 1;
else
mobj->extravalue1 = 3;
switch(mobj->extravalue1)
{
case 0: // shoot once
case 2: // spread-shot
default:
mobj->threshold = 2;
break;
case 1: // shoot 3 times
mobj->threshold = 3*2;
break;
case 3: // shoot like a goddamn machinegun
mobj->threshold = 8*2;
break;
// Okay, we're up? Good, time to gather energy...
if (mobj->health > mobj->info->damage)
{ // No more bubble if we're broken (pinch phase)
mobj_t *shield = P_SpawnMobj(mobj->x, mobj->y, mobj->z, MT_MSSHIELD_FRONT);
P_SetTarget(&mobj->tracer, shield);
P_SetTarget(&shield->target, mobj);
}
else
P_LinedefExecute(LE_PINCHPHASE, mobj, NULL);
mobj->fuse = 4*TICRATE;
mobj->flags |= MF_PAIN;
if (mobj->info->attacksound)
S_StartSound(mobj, mobj->info->attacksound);
A_FaceTarget(mobj);
break;
}
break;
case 3:
// Return to idle.
mobj->watertop = mobj->target->floorz + 32*FRACUNIT;
P_SetMobjState(mobj, mobj->info->spawnstate);
mobj->flags &= ~MF_PAIN;
mobj->fuse = 10*TICRATE;
break;
case 2:
// We're all charged and ready now! Unleash the fury!!
if (mobj->health > mobj->info->damage)
{
mobj_t *removemobj = mobj->tracer;
P_SetTarget(&mobj->tracer, mobj->hnext);
P_RemoveMobj(removemobj);
}
if (mobj->health <= mobj->info->damage)
{
// Attack 1: Pinball dash!
if (mobj->health == 1)
mobj->movedir = 0;
else
mobj->movedir = 2;
if (mobj->info->seesound)
S_StartSound(mobj, mobj->info->seesound);
P_SetMobjState(mobj, mobj->info->seestate);
if (mobj->movedir == 2)
mobj->threshold = 16; // bounce 16 times
else
mobj->threshold = 32; // bounce 32 times
mobj->watertop = mobj->target->floorz + 16*FRACUNIT;
P_LinedefExecute(LE_PINCHPHASE, mobj, NULL);
}
else
{
// Attack 2: Energy shot!
mobj->movedir = 1;
if (mobj->health >= 8)
mobj->extravalue1 = 0;
else if (mobj->health >= 5)
mobj->extravalue1 = 2;
else if (mobj->health >= 4)
mobj->extravalue1 = 1;
else
mobj->extravalue1 = 3;
switch (mobj->extravalue1)
{
case 0: // shoot once
case 2: // spread-shot
default:
mobj->threshold = 2;
break;
case 1: // shoot 3 times
mobj->threshold = 3*2;
break;
case 3: // shoot like a goddamn machinegun
mobj->threshold = 8*2;
break;
}
}
break;
case 3:
// Return to idle.
mobj->watertop = mobj->target->floorz + 32*FRACUNIT;
P_SetMobjState(mobj, mobj->info->spawnstate);
mobj->flags &= ~MF_PAIN;
mobj->fuse = 10*TICRATE;
break;
}
mobj->movecount++;
mobj->movecount %= 4;
@@ -5410,6 +5413,7 @@ static void P_Boss9Thinker(mobj_t *mobj)
// Face your target
angle = R_PointToAngle2(mobj->x, mobj->y, mobj->target->x, mobj->target->y); // absolute angle
angle = (angle-mobj->angle); // relative angle
if (angle < ANGLE_180)
mobj->angle += angle/8;
else
@@ -5433,6 +5437,7 @@ static void P_Boss9Thinker(mobj_t *mobj)
danger = false;
if (mobj->target->z+mobj->target->momz*2 > mobj->z+mobj->height)
danger = false;
if (danger)
{
// An incoming attack is detected! What should we do?!
@@ -5440,21 +5445,27 @@ static void P_Boss9Thinker(mobj_t *mobj)
mobj->movedir = ANGLE_11hh - FixedAngle(FixedMul(AngleFixed(ANGLE_11hh), FixedDiv((mobj->info->spawnhealth - mobj->health)<<FRACBITS, (mobj->info->spawnhealth-1)<<FRACBITS)));
if (P_RandomChance(FRACUNIT/2))
mobj->movedir = InvAngle(mobj->movedir);
mobj->threshold = 6 + (FixedMul(24<<FRACBITS, FixedDiv((mobj->info->spawnhealth - mobj->health)<<FRACBITS, (mobj->info->spawnhealth-1)<<FRACBITS))>>FRACBITS);
if (mobj->info->activesound)
S_StartSound(mobj, mobj->info->activesound);
if (mobj->info->painchance)
P_SetMobjState(mobj, mobj->info->painchance);
return;
}
// Move normally: Approach the player using normal thrust and simulated friction.
dist = P_AproxDistance(mobj->x-mobj->target->x, mobj->y-mobj->target->y);
P_Thrust(mobj, R_PointToAngle2(0, 0, mobj->momx, mobj->momy), -3*FRACUNIT/8);
if (dist < 64*FRACUNIT)
P_Thrust(mobj, mobj->angle, -4*FRACUNIT);
else if (dist > 180*FRACUNIT)
P_Thrust(mobj, mobj->angle, FRACUNIT);
mobj->momz += P_AproxDistance(mobj->momx, mobj->momy)/12; // Move up higher the faster you're going.
}
}
@@ -8803,14 +8814,15 @@ static boolean P_MobjRegularThink(mobj_t *mobj)
{
const angle_t fa = (i*FINEANGLES/16) & FINEMASK;
ns = FixedMul(64 * FRACUNIT, mobj->scale);
x = mobj->x + FixedMul(FINESINE(fa),ns);
y = mobj->y + FixedMul(FINECOSINE(fa),ns);
x = mobj->x + FixedMul(FINESINE(fa), ns);
y = mobj->y + FixedMul(FINECOSINE(fa), ns);
mo2 = P_SpawnMobj(x, y, z, MT_EXPLODE);
ns = FixedMul(16 * FRACUNIT, mobj->scale);
mo2->momx = FixedMul(FINESINE(fa),ns);
mo2->momy = FixedMul(FINECOSINE(fa),ns);
mo2->momx = FixedMul(FINESINE(fa), ns);
mo2->momy = FixedMul(FINECOSINE(fa), ns);
}
z -= FixedMul(32*FRACUNIT, mobj->scale);
}
P_SetMobjState(mobj, mobj->info->deathstate);
@@ -9004,9 +9016,9 @@ static void P_IceBlockFuseThink(mobj_t *mobj)
for (i = 0; i < 5; i++)
{
mobj_t *debris = P_SpawnMobj(mobj->x, mobj->y, mobj->z, MT_SMK_ICEBLOCK_DEBRIS);
debris->angle = FixedAngle(P_RandomRange(0,360)<<FRACBITS);
P_InstaThrust(debris, debris->angle, P_RandomRange(3,18)*(FRACUNIT/4));
debris->momz = P_RandomRange(4,8)<<FRACBITS;
debris->angle = FixedAngle(P_RandomRange(0, 360)<<FRACBITS);
P_InstaThrust(debris, debris->angle, P_RandomRange(3, 18)*(FRACUNIT/4));
debris->momz = P_RandomRange(4, 8)<<FRACBITS;
if (!i) // kinda hacky :V
S_StartSound(debris, sfx_s3k82);
}