mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Fix followers in anti gravity
This commit is contained in:
parent
4c1459cd4e
commit
4c8d373962
5 changed files with 33 additions and 10 deletions
|
|
@ -721,6 +721,7 @@ static void readfollower(MYFILE *f)
|
|||
followers[numfollowers].scale = FRACUNIT;
|
||||
followers[numfollowers].atangle = 230;
|
||||
followers[numfollowers].dist = 16;
|
||||
followers[numfollowers].height = 16;
|
||||
followers[numfollowers].zoffs = 32;
|
||||
followers[numfollowers].horzlag = 2;
|
||||
followers[numfollowers].vertlag = 6;
|
||||
|
|
@ -801,6 +802,11 @@ static void readfollower(MYFILE *f)
|
|||
DEH_WriteUndoline(word, va("%d", followers[numfollowers].dist), UNDO_NONE);
|
||||
followers[numfollowers].dist = (INT32)atoi(word2);
|
||||
}
|
||||
else if (fastcmp(word, "HEIGHT"))
|
||||
{
|
||||
DEH_WriteUndoline(word, va("%d", followers[numfollowers].height), UNDO_NONE);
|
||||
followers[numfollowers].height = (INT32)atoi(word2);
|
||||
}
|
||||
else if (fastcmp(word, "IDLESTATE"))
|
||||
{
|
||||
if (word2)
|
||||
|
|
@ -897,6 +903,7 @@ if (followers[numfollowers].field < threshold) \
|
|||
} \
|
||||
|
||||
FALLBACK(dist, "DIST", 0, 0);
|
||||
FALLBACK(height, "HEIGHT", 1, 1);
|
||||
FALLBACK(zoffs, "ZOFFS", 0, 0);
|
||||
FALLBACK(horzlag, "HORZLAG", 1, 1);
|
||||
FALLBACK(vertlag, "VERTLAG", 1, 1);
|
||||
|
|
|
|||
15
src/k_kart.c
15
src/k_kart.c
|
|
@ -1930,6 +1930,21 @@ void K_MatchGenericExtraFlags(mobj_t *mo, mobj_t *master)
|
|||
mo->eflags = (mo->eflags & ~MFE_DRAWONLYFORP4)|(master->eflags & MFE_DRAWONLYFORP4);
|
||||
}
|
||||
|
||||
// same as above, but does not adjust Z height when flipping
|
||||
void K_GenericExtraFlagsNoZAdjust(mobj_t *mo, mobj_t *master)
|
||||
{
|
||||
// flipping
|
||||
mo->eflags = (mo->eflags & ~MFE_VERTICALFLIP)|(master->eflags & MFE_VERTICALFLIP);
|
||||
mo->flags2 = (mo->flags2 & ~MF2_OBJECTFLIP)|(master->flags2 & MF2_OBJECTFLIP);
|
||||
|
||||
// visibility (usually for hyudoro)
|
||||
mo->flags2 = (mo->flags2 & ~MF2_DONTDRAW)|(master->flags2 & MF2_DONTDRAW);
|
||||
mo->eflags = (mo->eflags & ~MFE_DRAWONLYFORP1)|(master->eflags & MFE_DRAWONLYFORP1);
|
||||
mo->eflags = (mo->eflags & ~MFE_DRAWONLYFORP2)|(master->eflags & MFE_DRAWONLYFORP2);
|
||||
mo->eflags = (mo->eflags & ~MFE_DRAWONLYFORP3)|(master->eflags & MFE_DRAWONLYFORP3);
|
||||
mo->eflags = (mo->eflags & ~MFE_DRAWONLYFORP4)|(master->eflags & MFE_DRAWONLYFORP4);
|
||||
}
|
||||
|
||||
static void K_SpawnDashDustRelease(player_t *player)
|
||||
{
|
||||
fixed_t newx;
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ void K_KartBouncing(mobj_t *mobj1, mobj_t *mobj2, boolean bounce, boolean solid)
|
|||
void K_KartPainEnergyFling(player_t *player);
|
||||
void K_FlipFromObject(mobj_t *mo, mobj_t *master);
|
||||
void K_MatchGenericExtraFlags(mobj_t *mo, mobj_t *master);
|
||||
void K_GenericExtraFlagsNoZAdjust(mobj_t *mo, mobj_t *master);
|
||||
void K_DoIngameRespawn(player_t *player);
|
||||
void K_RespawnChecker(player_t *player);
|
||||
void K_KartMoveAnimation(player_t *player);
|
||||
|
|
|
|||
19
src/p_user.c
19
src/p_user.c
|
|
@ -8072,17 +8072,15 @@ static void P_HandleFollower(player_t *player)
|
|||
sy = player->mo->y + FixedMul((player->mo->scale*fl.dist), FINESINE((an)>>ANGLETOFINESHIFT));
|
||||
|
||||
// for the z coordinate, don't be a doof like Steel and forget that MFE_VERTICALFLIP exists :P
|
||||
sz = player->mo->z + FixedMul(player->mo->scale, zoffs);
|
||||
/*if (player->mo->eflags & MFE_VERTICALFLIP) // it's safe to assume that VERTICALFLIP accounts for MF2_OBJECTFLIP too
|
||||
sz -= (player->mo->height + FixedMul(player->mo->scale, zoffs*2));*/
|
||||
// ^ handled by K_matchgenericextraflags oops
|
||||
|
||||
sz = player->mo->z + FixedMul(player->mo->scale, zoffs)*P_MobjFlip(player->mo);
|
||||
if (player->mo->eflags & MFE_VERTICALFLIP)
|
||||
sz += fl.height*player->mo->scale;
|
||||
|
||||
// finally, add a cool floating effect to the z height.
|
||||
// not stolen from k_kart I swear!!
|
||||
const fixed_t pi = (22<<FRACBITS) / 7; // loose approximation, this doesn't need to be incredibly precise
|
||||
fixed_t sine = fl.bobamp * FINESINE((((8*pi*(fl.bobspeed)) * leveltime)>>ANGLETOFINESHIFT) & FINEMASK);
|
||||
sz += sine;
|
||||
sz += FixedMul(player->mo->scale, sine)*P_MobjFlip(player->mo);
|
||||
|
||||
if (!player->follower) // follower doesn't exist / isn't valid
|
||||
{
|
||||
|
|
@ -8111,13 +8109,13 @@ static void P_HandleFollower(player_t *player)
|
|||
// move the follower next to us (yes, this is really basic maths but it looks pretty damn clean in practice)!
|
||||
player->follower->momx = (sx - player->follower->x)/fl.horzlag;
|
||||
player->follower->momy = (sy - player->follower->y)/fl.horzlag;
|
||||
player->follower->momz = (sz - player->follower->z)/fl.vertlag; // make z momentum a bit floatier, it'll look cute I promise!
|
||||
player->follower->momz = (sz - player->follower->z)/fl.vertlag;
|
||||
player->follower->angle = player->mo->angle;
|
||||
player->follower->color = player->mo->color;
|
||||
player->follower->colorized = player->mo->colorized;
|
||||
|
||||
P_SetScale(player->follower, FixedMul(fl.scale, player->mo->scale));
|
||||
K_MatchGenericExtraFlags(player->follower, player->mo);
|
||||
K_GenericExtraFlagsNoZAdjust(player->follower, player->mo); // Not K_MatchGenericExtraFlag because the Z adjust it has only works properly if master & mo have the same Z height.
|
||||
|
||||
// For comeback in battle.
|
||||
player->follower->flags2 = (player->follower->flags2 & ~MF2_SHADOW)|(player->mo->flags2 & MF2_SHADOW);
|
||||
|
|
@ -8127,11 +8125,12 @@ static void P_HandleFollower(player_t *player)
|
|||
if (player->pflags & PF_TIMEOVER || (!cv_showfollowers.value && (!P_IsDisplayPlayer(player) || displayplayers[0] != consoleplayer) ))
|
||||
player->follower->flags2 |= MF2_DONTDRAW;
|
||||
|
||||
if (player->speed)
|
||||
if (player->speed && (player->follower->momx || player->follower->momy))
|
||||
player->follower->angle = R_PointToAngle2(0, 0, player->follower->momx, player->follower->momy);
|
||||
// if we're moving let's make the angle the direction we're moving towards. This is to avoid drifting / reverse looking awkward.
|
||||
// Make sure the follower itself is also moving however, otherwise we'll be facing angle 0
|
||||
|
||||
// handle follower animations. Yes, it looks like very bad kiddie script so what, do you have any better idea genius? Go get a life instead of criticizing my unpaid work!!!!!!
|
||||
// handle follower animations. Could probably be better...
|
||||
// hurt or dead
|
||||
if (player->kartstuff[k_spinouttimer] || player->mo->state == &states[S_KART_SPIN] || player->mo->health <= 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -115,6 +115,7 @@ typedef struct follower_s
|
|||
// some position shenanigans:
|
||||
INT32 atangle; // angle the object will be at around the player. The object itself will always face the same direction as the player.
|
||||
INT32 dist; // distance relative to the player. (In a circle)
|
||||
INT32 height; // height of the follower, this is mostly important for Z flipping.
|
||||
INT32 zoffs; // Z offset relative to the player's height. Cannot be negative.
|
||||
|
||||
// movement options
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue