mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-29 12:40:58 +00:00
Merge branch 'slopewall_transfer' into 'master'
Slopewall transfer As @Nev3r wants. Go along a slope, hit a wall? LAUNCH! Well, I mean. He wants it slightly less weak. I have already made it less weak than P_SlopeLaunch. Also also I made the trail that goes behind the player when they're rolling take into account vertical momentum as well as horizontal, so that being launched directly up didn't leave you trailless. Test with <root>/!LatestSRB2Files/srb2win_branch_transfer.exe and <root>/Nev3r/ACZMaster.wad (roll down slope directly in front of you). See merge request !66
This commit is contained in:
commit
921b57e904
4 changed files with 66 additions and 1 deletions
31
src/p_mobj.c
31
src/p_mobj.c
|
@ -2176,8 +2176,39 @@ void P_XYMovement(mobj_t *mo)
|
|||
}
|
||||
else if (player || mo->flags & (MF_SLIDEME|MF_PUSHABLE))
|
||||
{ // try to slide along it
|
||||
#ifdef ESLOPE
|
||||
// Wall transfer part 1.
|
||||
pslope_t *transferslope = NULL;
|
||||
fixed_t transfermomz = 0;
|
||||
if (oldslope && (P_MobjFlip(mo)*(predictedz - mo->z) > 0)) // Only for moving up (relative to gravity), otherwise there's a failed launch when going down slopes and hitting walls
|
||||
{
|
||||
transferslope = ((mo->standingslope) ? mo->standingslope : oldslope);
|
||||
if (((transferslope->zangle < ANGLE_180) ? transferslope->zangle : InvAngle(transferslope->zangle)) >= ANGLE_45) // Prevent some weird stuff going on on shallow slopes.
|
||||
transfermomz = P_GetWallTransferMomZ(mo, transferslope);
|
||||
}
|
||||
#endif
|
||||
|
||||
P_SlideMove(mo);
|
||||
xmove = ymove = 0;
|
||||
|
||||
#ifdef ESLOPE
|
||||
// Wall transfer part 2.
|
||||
if (transfermomz && transferslope) // Are we "transferring onto the wall" (really just a disguised vertical launch)?
|
||||
{
|
||||
angle_t relation; // Scale transfer momentum based on how head-on it is to the slope.
|
||||
if (mo->momx || mo->momy) // "Guess" the angle of the wall you hit using new momentum
|
||||
relation = transferslope->xydirection - R_PointToAngle2(0, 0, mo->momx, mo->momy);
|
||||
else // Give it for free, I guess.
|
||||
relation = ANGLE_90;
|
||||
transfermomz = FixedMul(transfermomz,
|
||||
abs(FINESINE((relation >> ANGLETOFINESHIFT) & FINEMASK)));
|
||||
if (P_MobjFlip(mo)*(transfermomz - mo->momz) > 2*FRACUNIT) // Do the actual launch!
|
||||
{
|
||||
mo->momz = transfermomz;
|
||||
mo->standingslope = NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else if (mo->type == MT_SPINFIRE)
|
||||
{
|
||||
|
|
|
@ -804,6 +804,39 @@ void P_SlopeLaunch(mobj_t *mo)
|
|||
mo->standingslope = NULL;
|
||||
}
|
||||
|
||||
//
|
||||
// P_GetWallTransferMomZ
|
||||
//
|
||||
// It would be nice to have a single function that does everything necessary for slope-to-wall transfer.
|
||||
// However, it needs to be seperated out in P_XYMovement to take into account momentum before and after hitting the wall.
|
||||
// This just performs the necessary calculations for getting the base vertical momentum; the horizontal is already reasonably calculated by P_SlideMove.
|
||||
fixed_t P_GetWallTransferMomZ(mobj_t *mo, pslope_t *slope)
|
||||
{
|
||||
vector3_t slopemom, axis;
|
||||
angle_t ang;
|
||||
|
||||
if (mo->standingslope->flags & SL_NOPHYSICS)
|
||||
return 0;
|
||||
|
||||
// If there's physics, time for launching.
|
||||
// Doesn't kill the vertical momentum as much as P_SlopeLaunch does.
|
||||
ang = slope->zangle + ANG15*((slope->zangle > 0) ? 1 : -1);
|
||||
if (ang > ANGLE_90 && ang < ANGLE_180)
|
||||
ang = ((slope->zangle > 0) ? ANGLE_90 : InvAngle(ANGLE_90)); // hard cap of directly upwards
|
||||
|
||||
slopemom.x = mo->momx;
|
||||
slopemom.y = mo->momy;
|
||||
slopemom.z = 3*(mo->momz/2);
|
||||
|
||||
axis.x = -slope->d.y;
|
||||
axis.y = slope->d.x;
|
||||
axis.z = 0;
|
||||
|
||||
FV3_Rotate(&slopemom, &axis, ang >> ANGLETOFINESHIFT);
|
||||
|
||||
return 2*(slopemom.z/3);
|
||||
}
|
||||
|
||||
// Function to help handle landing on slopes
|
||||
void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope)
|
||||
{
|
||||
|
|
|
@ -37,6 +37,7 @@ fixed_t P_GetZAt(pslope_t *slope, fixed_t x, fixed_t y);
|
|||
void P_QuantizeMomentumToSlope(vector3_t *momentum, pslope_t *slope);
|
||||
void P_ReverseQuantizeMomentumToSlope(vector3_t *momentum, pslope_t *slope);
|
||||
void P_SlopeLaunch(mobj_t *mo);
|
||||
fixed_t P_GetWallTransferMomZ(mobj_t *mo, pslope_t *slope);
|
||||
void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope);
|
||||
void P_ButteredSlope(mobj_t *mo);
|
||||
|
||||
|
|
|
@ -6908,7 +6908,7 @@ static void P_MovePlayer(player_t *player)
|
|||
P_ResetScore(player);
|
||||
|
||||
// Show the "THOK!" graphic when spinning quickly across the ground. (even applies to non-spinners, in the case of zoom tubes)
|
||||
if (player->pflags & PF_SPINNING && player->speed > FixedMul(15<<FRACBITS, player->mo->scale) && !(player->pflags & PF_JUMPED))
|
||||
if (player->pflags & PF_SPINNING && P_AproxDistance(player->speed, player->mo->momz) > FixedMul(15<<FRACBITS, player->mo->scale) && !(player->pflags & PF_JUMPED))
|
||||
{
|
||||
P_SpawnSpinMobj(player, player->spinitem);
|
||||
if (demorecording)
|
||||
|
|
Loading…
Reference in a new issue