Merge remote-tracking branch 'refs/remotes/origin/gameplay-tweaks' into battle
# Conflicts: # src/k_kart.h
This commit is contained in:
commit
57b4d73ec2
48
src/k_kart.c
48
src/k_kart.c
|
@ -1061,12 +1061,12 @@ static void K_KartItemRouletteByDistance(player_t *player, ticcmd_t *cmd)
|
||||||
|
|
||||||
//{ SRB2kart p_user.c Stuff
|
//{ SRB2kart p_user.c Stuff
|
||||||
|
|
||||||
void K_KartBilliards(mobj_t *mobj1, mobj_t *mobj2, boolean bounce)
|
void K_KartBouncing(mobj_t *mobj1, mobj_t *mobj2, boolean bounce)
|
||||||
{
|
{
|
||||||
mobj_t *fx;
|
mobj_t *fx;
|
||||||
fixed_t ndistx, ndisty, ndistlength;
|
fixed_t momdifx, momdify;
|
||||||
fixed_t a1, a2;
|
fixed_t distx, disty;
|
||||||
fixed_t optimizedP;
|
fixed_t dot, p;
|
||||||
fixed_t mass1, mass2;
|
fixed_t mass1, mass2;
|
||||||
|
|
||||||
if (!mobj1 || !mobj2)
|
if (!mobj1 || !mobj2)
|
||||||
|
@ -1086,38 +1086,22 @@ void K_KartBilliards(mobj_t *mobj1, mobj_t *mobj2, boolean bounce)
|
||||||
|
|
||||||
mass1 = mass2 = 1*FRACUNIT;
|
mass1 = mass2 = 1*FRACUNIT;
|
||||||
if (mobj1->player)
|
if (mobj1->player)
|
||||||
mass1 = (1+mobj1->player->kartweight*20)*FRACUNIT;
|
mass1 = (mobj1->player->kartweight)*FRACUNIT;
|
||||||
if (mobj2->player)
|
if (mobj2->player)
|
||||||
mass2 = (1+mobj2->player->kartweight*20)*FRACUNIT;
|
mass2 = (mobj2->player->kartweight)*FRACUNIT;
|
||||||
|
|
||||||
// find normalised vector from centre of each mobj
|
momdifx = mobj1->momx - mobj2->momx;
|
||||||
ndistx = mobj1->x - mobj2->x;
|
momdify = mobj1->momy - mobj2->momy;
|
||||||
ndisty = mobj1->y - mobj2->y;
|
distx = mobj1->x - mobj2->x;
|
||||||
ndistlength = P_AproxDistance(ndistx, ndisty);
|
disty = mobj1->y - mobj2->y;
|
||||||
ndistx = FixedDiv(ndistx, ndistlength);
|
dot = FixedMul(momdifx, distx) + FixedMul(momdify, disty);
|
||||||
ndisty = FixedDiv(ndisty, ndistlength);
|
p = FixedDiv(dot, FixedMul(distx, distx)+FixedMul(disty, disty));
|
||||||
|
|
||||||
// find length of the component from the movement along n
|
mobj1->momx = mobj1->momx - FixedMul(FixedMul(FixedDiv(2*mass2, mass1 + mass2), p), distx);
|
||||||
a1 = FixedMul(mobj1->momx, ndistx) + FixedMul(mobj1->momy, ndisty);
|
mobj1->momy = mobj1->momy - FixedMul(FixedMul(FixedDiv(2*mass2, mass1 + mass2), p), disty);
|
||||||
a2 = FixedMul(mobj2->momx, ndistx) + FixedMul(mobj2->momy, ndisty);
|
|
||||||
|
|
||||||
optimizedP = FixedDiv(FixedMul(2*FRACUNIT, a1 - a2), mass1 + mass2);
|
mobj2->momx = mobj2->momx - FixedMul(FixedMul(FixedDiv(2*mass1, mass1 + mass2), p), -distx);
|
||||||
|
mobj2->momy = mobj2->momy - FixedMul(FixedMul(FixedDiv(2*mass1, mass1 + mass2), p), -disty);
|
||||||
// calculate new movement of mobj1
|
|
||||||
mobj1->momx = mobj1->momx - FixedMul(FixedMul(optimizedP, mass2), ndistx);
|
|
||||||
mobj1->momy = mobj1->momy - FixedMul(FixedMul(optimizedP, mass2), ndisty);
|
|
||||||
|
|
||||||
// calculate new movement of mobj2
|
|
||||||
mobj2->momx = mobj2->momx + FixedMul(FixedMul(optimizedP, mass1), ndistx);
|
|
||||||
mobj2->momy = mobj2->momy + FixedMul(FixedMul(optimizedP, mass1), ndisty);
|
|
||||||
|
|
||||||
// In addition to knocking players based on their momentum into each other
|
|
||||||
// I will bounce them away from each other based on weight
|
|
||||||
optimizedP = FixedDiv(cv_collideminimum.value*FRACUNIT, mass1 + mass2); // reuse these variables for helping decide bounce speed
|
|
||||||
a1 = FixedMul(optimizedP, mass2);
|
|
||||||
a2 = FixedMul(optimizedP, mass1);
|
|
||||||
P_Thrust(mobj1, R_PointToAngle2(mobj1->x, mobj1->y, mobj2->x, mobj2->y)+ANGLE_180, a1);
|
|
||||||
P_Thrust(mobj2, R_PointToAngle2(mobj1->x, mobj1->y, mobj2->x, mobj2->y), a2);
|
|
||||||
|
|
||||||
if (bounce == true) // Perform a Goomba Bounce.
|
if (bounce == true) // Perform a Goomba Bounce.
|
||||||
mobj1->momz = -mobj1->momz;
|
mobj1->momz = -mobj1->momz;
|
||||||
|
|
|
@ -16,8 +16,8 @@ UINT8 K_GetKartColorByName(const char *name);
|
||||||
void K_RegisterKartStuff(void);
|
void K_RegisterKartStuff(void);
|
||||||
|
|
||||||
UINT8 K_GetKartCC(void);
|
UINT8 K_GetKartCC(void);
|
||||||
void K_KartBouncer(void);
|
|
||||||
void K_KartMoveAnimation(player_t *player);
|
void K_KartMoveAnimation(player_t *player);
|
||||||
|
void K_KartBouncing(mobj_t *mobj1, mobj_t *mobj2, boolean bounce);
|
||||||
void K_KartPlayerThink(player_t *player, ticcmd_t *cmd);
|
void K_KartPlayerThink(player_t *player, ticcmd_t *cmd);
|
||||||
void K_SpinPlayer(player_t *player, mobj_t *source);
|
void K_SpinPlayer(player_t *player, mobj_t *source);
|
||||||
void K_SquishPlayer(player_t *player, mobj_t *source);
|
void K_SquishPlayer(player_t *player, mobj_t *source);
|
||||||
|
|
13
src/p_map.c
13
src/p_map.c
|
@ -1597,6 +1597,12 @@ static boolean PIT_CheckThing(mobj_t *thing)
|
||||||
}
|
}
|
||||||
else if (thing->player) // bounce when players collide
|
else if (thing->player) // bounce when players collide
|
||||||
{
|
{
|
||||||
|
// see if it went over / under
|
||||||
|
if (tmthing->z > thing->z + thing->height)
|
||||||
|
return true; // overhead
|
||||||
|
if (tmthing->z + tmthing->height < thing->z)
|
||||||
|
return true; // underneath
|
||||||
|
|
||||||
if (thing->player->kartstuff[k_growshrinktimer] || thing->player->kartstuff[k_squishedtimer]
|
if (thing->player->kartstuff[k_growshrinktimer] || thing->player->kartstuff[k_squishedtimer]
|
||||||
|| thing->player->kartstuff[k_bootimer] || thing->player->kartstuff[k_spinouttimer]
|
|| thing->player->kartstuff[k_bootimer] || thing->player->kartstuff[k_spinouttimer]
|
||||||
|| thing->player->kartstuff[k_startimer] || thing->player->kartstuff[k_justbumped]
|
|| thing->player->kartstuff[k_startimer] || thing->player->kartstuff[k_justbumped]
|
||||||
|
@ -1648,14 +1654,15 @@ static boolean PIT_CheckThing(mobj_t *thing)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (P_IsObjectOnGround(thing) && tmthing->momz < 0)
|
if (P_IsObjectOnGround(thing) && tmthing->momz < 0)
|
||||||
K_KartBilliards(tmthing, thing, true);
|
K_KartBouncing(tmthing, thing, true);
|
||||||
else if (P_IsObjectOnGround(tmthing) && thing->momz < 0)
|
else if (P_IsObjectOnGround(tmthing) && thing->momz < 0)
|
||||||
K_KartBilliards(thing, tmthing, true);
|
K_KartBouncing(thing, tmthing, true);
|
||||||
else
|
else
|
||||||
K_KartBilliards(tmthing, thing, false);
|
K_KartBouncing(tmthing, thing, false);
|
||||||
|
|
||||||
thing->player->kartstuff[k_justbumped] = 6;
|
thing->player->kartstuff[k_justbumped] = 6;
|
||||||
tmthing->player->kartstuff[k_justbumped] = 6;
|
tmthing->player->kartstuff[k_justbumped] = 6;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
// Are you touching the side of the object you're interacting with?
|
// Are you touching the side of the object you're interacting with?
|
||||||
else if (thing->z - FixedMul(FRACUNIT, thing->scale) <= tmthing->z + tmthing->height
|
else if (thing->z - FixedMul(FRACUNIT, thing->scale) <= tmthing->z + tmthing->height
|
||||||
|
|
Loading…
Reference in New Issue