mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Reset state when bouncing
This commit is contained in:
parent
c3bb2c8539
commit
3164199512
2 changed files with 67 additions and 64 deletions
105
src/k_follower.c
105
src/k_follower.c
|
|
@ -129,7 +129,6 @@ void K_SetFollowerByNum(INT32 playernum, INT32 skinnum)
|
||||||
K_SetFollowerByNum(playernum, -1); // Not found, then set -1 (nothing) as our follower.
|
K_SetFollowerByNum(playernum, -1); // Not found, then set -1 (nothing) as our follower.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*--------------------------------------------------
|
/*--------------------------------------------------
|
||||||
static void K_SetFollowerState(mobj_t *f, statenum_t state)
|
static void K_SetFollowerState(mobj_t *f, statenum_t state)
|
||||||
|
|
||||||
|
|
@ -176,6 +175,35 @@ static void K_SetFollowerState(mobj_t *f, statenum_t state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*--------------------------------------------------
|
||||||
|
static void K_UpdateFollowerState(mobj_t *f, statenum_t state, followerstate_t type)
|
||||||
|
|
||||||
|
Sets a follower object's state & current state type tracker.
|
||||||
|
If the state tracker already matches, then this is ignored.
|
||||||
|
|
||||||
|
Input Arguments:-
|
||||||
|
f - The follower's mobj_t.
|
||||||
|
state - The state to set.
|
||||||
|
type - State type tracker.
|
||||||
|
|
||||||
|
Return:-
|
||||||
|
None
|
||||||
|
--------------------------------------------------*/
|
||||||
|
static void K_UpdateFollowerState(mobj_t *f, statenum_t state, followerstate_t type)
|
||||||
|
{
|
||||||
|
if (f == NULL || P_MobjWasRemoved(f) == true)
|
||||||
|
{
|
||||||
|
// safety net
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (f->extravalue1 != (INT32)type)
|
||||||
|
{
|
||||||
|
K_SetFollowerState(f, state);
|
||||||
|
f->extravalue1 = type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------
|
/*--------------------------------------------------
|
||||||
void K_HandleFollower(player_t *player)
|
void K_HandleFollower(player_t *player)
|
||||||
|
|
||||||
|
|
@ -299,7 +327,8 @@ void K_HandleFollower(player_t *player)
|
||||||
|
|
||||||
// so let's spawn one!
|
// so let's spawn one!
|
||||||
P_SetTarget(&player->follower, P_SpawnMobj(sx, sy, sz, MT_FOLLOWER));
|
P_SetTarget(&player->follower, P_SpawnMobj(sx, sy, sz, MT_FOLLOWER));
|
||||||
K_SetFollowerState(player->follower, fl.idlestate);
|
K_UpdateFollowerState(player->follower, fl.idlestate, FOLLOWERSTATE_IDLE);
|
||||||
|
|
||||||
P_SetTarget(&player->follower->target, player->mo); // we need that to know when we need to disappear
|
P_SetTarget(&player->follower->target, player->mo); // we need that to know when we need to disappear
|
||||||
P_InitAngle(player->follower, player->mo->angle);
|
P_InitAngle(player->follower, player->mo->angle);
|
||||||
|
|
||||||
|
|
@ -314,16 +343,6 @@ void K_HandleFollower(player_t *player)
|
||||||
P_SetTarget(&player->follower->hnext->hnext, bmobj); // this seems absolutely stupid, I know, but this will make updating the momentums/flags of these a bit easier.
|
P_SetTarget(&player->follower->hnext->hnext, bmobj); // this seems absolutely stupid, I know, but this will make updating the momentums/flags of these a bit easier.
|
||||||
P_SetTarget(&bmobj->target, player->follower); // Ditto
|
P_SetTarget(&bmobj->target, player->follower); // Ditto
|
||||||
}
|
}
|
||||||
|
|
||||||
player->follower->extravalue1 = 0; // extravalue1 is used to know what "state set" to use.
|
|
||||||
/*
|
|
||||||
0 = idle
|
|
||||||
1 = forwards
|
|
||||||
2 = hurt
|
|
||||||
3 = win
|
|
||||||
4 = lose
|
|
||||||
5 = hitconfirm (< this one uses ->movecount as timer to know when to end, and goes back to normal states afterwards, unless hurt)
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
else // follower exists, woo!
|
else // follower exists, woo!
|
||||||
{
|
{
|
||||||
|
|
@ -431,10 +450,11 @@ void K_HandleFollower(player_t *player)
|
||||||
{
|
{
|
||||||
player->follower->z = fh;
|
player->follower->z = fh;
|
||||||
|
|
||||||
if (!(player->mo->eflags & MFE_VERTICALFLIP) && player->follower->momz <= 0)
|
if (!(player->mo->eflags & MFE_VERTICALFLIP) && player->follower->momz <= 0 && fl.bobamp != 0)
|
||||||
{
|
{
|
||||||
// Ground bounce
|
// Ground bounce
|
||||||
player->follower->momz = P_GetMobjZMovement(player->mo) + FixedMul(fl.bobamp, player->follower->scale);
|
player->follower->momz = P_GetMobjZMovement(player->mo) + FixedMul(fl.bobamp, player->follower->scale);
|
||||||
|
player->follower->extravalue1 = FOLLOWERSTATE_RESET;
|
||||||
}
|
}
|
||||||
else if (player->follower->momz < 0)
|
else if (player->follower->momz < 0)
|
||||||
{
|
{
|
||||||
|
|
@ -446,10 +466,11 @@ void K_HandleFollower(player_t *player)
|
||||||
{
|
{
|
||||||
player->follower->z = ch;
|
player->follower->z = ch;
|
||||||
|
|
||||||
if ((player->mo->eflags & MFE_VERTICALFLIP) && player->follower->momz >= 0)
|
if ((player->mo->eflags & MFE_VERTICALFLIP) && player->follower->momz >= 0 && fl.bobamp != 0)
|
||||||
{
|
{
|
||||||
// Ground bounce
|
// Ground bounce
|
||||||
player->follower->momz = P_GetMobjZMovement(player->mo) - FixedMul(fl.bobamp, player->follower->scale);
|
player->follower->momz = P_GetMobjZMovement(player->mo) - FixedMul(fl.bobamp, player->follower->scale);
|
||||||
|
player->follower->extravalue1 = FOLLOWERSTATE_RESET;
|
||||||
}
|
}
|
||||||
else if (player->follower->momz > 0)
|
else if (player->follower->momz > 0)
|
||||||
{
|
{
|
||||||
|
|
@ -512,11 +533,7 @@ void K_HandleFollower(player_t *player)
|
||||||
// spin out
|
// spin out
|
||||||
player->follower->angle = player->drawangle;
|
player->follower->angle = player->drawangle;
|
||||||
|
|
||||||
if (player->follower->extravalue1 != 2)
|
K_UpdateFollowerState(player->follower, fl.hurtstate, FOLLOWERSTATE_HURT);
|
||||||
{
|
|
||||||
player->follower->extravalue1 = 2;
|
|
||||||
K_SetFollowerState(player->follower, fl.hurtstate);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (player->mo->health <= 0)
|
if (player->mo->health <= 0)
|
||||||
{
|
{
|
||||||
|
|
@ -524,58 +541,32 @@ void K_HandleFollower(player_t *player)
|
||||||
player->follower->momz = player->mo->momz;
|
player->follower->momz = player->mo->momz;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (player->follower->movecount)
|
else if (player->exiting)
|
||||||
{
|
|
||||||
if (player->follower->extravalue1 != 5)
|
|
||||||
{
|
|
||||||
player->follower->extravalue1 = 5;
|
|
||||||
K_SetFollowerState(player->follower, fl.hitconfirmstate);
|
|
||||||
}
|
|
||||||
|
|
||||||
player->follower->movecount--;
|
|
||||||
}
|
|
||||||
else if (player->speed > 10*player->mo->scale) // animation for moving fast enough
|
|
||||||
{
|
|
||||||
if (player->follower->extravalue1 != 1)
|
|
||||||
{
|
|
||||||
player->follower->extravalue1 = 1;
|
|
||||||
K_SetFollowerState(player->follower, fl.followstate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// animations when nearly still. This includes winning and losing.
|
|
||||||
if (player->follower->extravalue1 != 0)
|
|
||||||
{
|
|
||||||
if (player->exiting)
|
|
||||||
{
|
{
|
||||||
// win/ loss animations
|
// win/ loss animations
|
||||||
if (K_IsPlayerLosing(player))
|
if (K_IsPlayerLosing(player))
|
||||||
{
|
{
|
||||||
// L
|
// L
|
||||||
if (player->follower->extravalue1 != 4)
|
K_UpdateFollowerState(player->follower, fl.losestate, FOLLOWERSTATE_LOSE);
|
||||||
{
|
|
||||||
player->follower->extravalue1 = 4;
|
|
||||||
K_SetFollowerState(player->follower, fl.losestate);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// W
|
// W
|
||||||
if (player->follower->extravalue1 != 3)
|
K_UpdateFollowerState(player->follower, fl.winstate, FOLLOWERSTATE_WIN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (player->follower->movecount)
|
||||||
{
|
{
|
||||||
player->follower->extravalue1 = 3;
|
K_UpdateFollowerState(player->follower, fl.hitconfirmstate, FOLLOWERSTATE_HITCONFIRM);
|
||||||
K_SetFollowerState(player->follower, fl.winstate);
|
player->follower->movecount--;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else if (player->speed > 10*player->mo->scale) // animation for moving fast enough
|
||||||
|
{
|
||||||
|
K_UpdateFollowerState(player->follower, fl.followstate, FOLLOWERSTATE_FOLLOW);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// normal standstill
|
K_UpdateFollowerState(player->follower, fl.idlestate, FOLLOWERSTATE_IDLE);
|
||||||
player->follower->extravalue1 = 0;
|
|
||||||
K_SetFollowerState(player->follower, fl.idlestate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,18 @@ typedef enum
|
||||||
FOLLOWERMODE__MAX
|
FOLLOWERMODE__MAX
|
||||||
} followermode_t;
|
} followermode_t;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
FOLLOWERSTATE_RESET, // Set to this to reset the state entirely.
|
||||||
|
FOLLOWERSTATE_IDLE,
|
||||||
|
FOLLOWERSTATE_FOLLOW,
|
||||||
|
FOLLOWERSTATE_HURT,
|
||||||
|
FOLLOWERSTATE_WIN,
|
||||||
|
FOLLOWERSTATE_LOSE,
|
||||||
|
FOLLOWERSTATE_HITCONFIRM, // Uses movecount as a timer for how long to play this state.
|
||||||
|
FOLLOWERSTATE__MAX
|
||||||
|
} followerstate_t;
|
||||||
|
|
||||||
//
|
//
|
||||||
// We'll define these here because they're really just a mobj that'll follow some rules behind a player
|
// We'll define these here because they're really just a mobj that'll follow some rules behind a player
|
||||||
//
|
//
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue