Merge branch 'shrinkscaler' into 'master'

Scale Shrink time to laser particle size

See merge request KartKrew/Kart!2057
This commit is contained in:
AJ Martinez 2024-03-09 06:02:50 +00:00
commit 724b3a1a02

View file

@ -341,6 +341,7 @@ static void ShrinkLaserThinker(mobj_t *pohbee, mobj_t *gun, mobj_t *laser)
particle->color = laser->color;
P_SetScale(particle, particle->scale * 2);
particle->cusval = particle->scale; // Store for later.
particle->destscale = 0;
//particle->momz = 2 * particle->scale * P_MobjFlip(particle);
@ -535,6 +536,14 @@ boolean Obj_ShrinkLaserCollide(mobj_t *gun, mobj_t *victim)
owner = pohbee_owner(pohbee);
prevTimer = victim->player->growshrinktimer;
fixed_t scale = FRACUNIT; // Used if you hit the gun/laser.
if (gun->type == MT_SHRINK_PARTICLE && gun->cusval != 0) // Hit the laser trail, scale the punishment down.
{
fixed_t normalizer = FixedDiv(FRACUNIT, gun->cusval); // cusval = original scale of the particle, as it eases down to 0
scale = FixedMul(gun->scale, normalizer);
}
if (owner != NULL && victim == owner)
{
// Belongs to us. Give us Grow!
@ -576,17 +585,21 @@ boolean Obj_ShrinkLaserCollide(mobj_t *gun, mobj_t *victim)
}
else
{
// Bullshit contact. Let 'em off for free.
if (scale < FRACUNIT/4)
return true;
if (prevTimer > 0)
{
// Dock some Grow time.
// (Hack-adjacent: Always make sure there's a tic left so standard timer handling can remove the effect properly.)
victim->player->growshrinktimer -= min(3*TICRATE/2, victim->player->growshrinktimer - 1);
victim->player->growshrinktimer -= min(FixedInt(FixedMul(FRACUNIT*3*TICRATE/2, scale)), victim->player->growshrinktimer - 1);
S_StartSound(victim, sfx_s3k40);
}
else
{
// Start shrinking!
victim->player->growshrinktimer -= 5*TICRATE;
victim->player->growshrinktimer -= FixedInt(FixedMul(FRACUNIT*5*TICRATE, scale));
S_StartSound(victim, sfx_kc59); // I don't think you ever get to hear this while the pohbee laser is in your teeth, but best effort.
if (prevTimer >= 0)