mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Make the various carry types' handling code into a switch case
This commit is contained in:
parent
ace2e890c0
commit
bd0bd153a7
1 changed files with 135 additions and 116 deletions
87
src/p_user.c
87
src/p_user.c
|
|
@ -11686,43 +11686,48 @@ void P_PlayerAfterThink(player_t *player)
|
||||||
/* if (player->powers[pw_carry] == CR_NONE && player->mo->tracer && !player->homing)
|
/* if (player->powers[pw_carry] == CR_NONE && player->mo->tracer && !player->homing)
|
||||||
P_SetTarget(&player->mo->tracer, NULL);
|
P_SetTarget(&player->mo->tracer, NULL);
|
||||||
else */
|
else */
|
||||||
if (player->powers[pw_carry] == CR_PLAYER && player->mo->tracer)
|
if (player->mo->tracer)
|
||||||
{
|
{
|
||||||
|
switch (player->powers[pw_carry])
|
||||||
|
{
|
||||||
|
case CR_PLAYER: // being carried by a flying character (such as Tails)
|
||||||
|
{
|
||||||
|
mobj_t *tails = player->mo->tracer;
|
||||||
player->mo->height = FixedDiv(P_GetPlayerHeight(player), FixedDiv(14*FRACUNIT,10*FRACUNIT));
|
player->mo->height = FixedDiv(P_GetPlayerHeight(player), FixedDiv(14*FRACUNIT,10*FRACUNIT));
|
||||||
|
|
||||||
if (player->mo->tracer->player && !(player->mo->tracer->player->pflags & PF_CANCARRY))
|
if (tails->player && !(tails->player->pflags & PF_CANCARRY))
|
||||||
player->powers[pw_carry] = CR_NONE;
|
player->powers[pw_carry] = CR_NONE;
|
||||||
|
|
||||||
if (player->mo->eflags & MFE_VERTICALFLIP)
|
if (player->mo->eflags & MFE_VERTICALFLIP)
|
||||||
{
|
{
|
||||||
if ((player->mo->tracer->z + player->mo->tracer->height + player->mo->height + FixedMul(FRACUNIT, player->mo->scale)) <= player->mo->tracer->ceilingz
|
if ((tails->z + tails->height + player->mo->height + FixedMul(FRACUNIT, player->mo->scale)) <= tails->ceilingz
|
||||||
&& (player->mo->tracer->eflags & MFE_VERTICALFLIP)) // Reverse gravity check for the carrier - Flame
|
&& (tails->eflags & MFE_VERTICALFLIP)) // Reverse gravity check for the carrier - Flame
|
||||||
player->mo->z = player->mo->tracer->z + player->mo->tracer->height + FixedMul(FRACUNIT, player->mo->scale);
|
player->mo->z = tails->z + tails->height + FixedMul(FRACUNIT, player->mo->scale);
|
||||||
else
|
else
|
||||||
player->powers[pw_carry] = CR_NONE;
|
player->powers[pw_carry] = CR_NONE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ((player->mo->tracer->z - player->mo->height - FixedMul(FRACUNIT, player->mo->scale)) >= player->mo->tracer->floorz
|
if ((tails->z - player->mo->height - FixedMul(FRACUNIT, player->mo->scale)) >= tails->floorz
|
||||||
&& !(player->mo->tracer->eflags & MFE_VERTICALFLIP)) // Correct gravity check for the carrier - Flame
|
&& !(tails->eflags & MFE_VERTICALFLIP)) // Correct gravity check for the carrier - Flame
|
||||||
player->mo->z = player->mo->tracer->z - player->mo->height - FixedMul(FRACUNIT, player->mo->scale);
|
player->mo->z = tails->z - player->mo->height - FixedMul(FRACUNIT, player->mo->scale);
|
||||||
else
|
else
|
||||||
player->powers[pw_carry] = CR_NONE;
|
player->powers[pw_carry] = CR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player->mo->tracer->health <= 0)
|
if (tails->health <= 0)
|
||||||
player->powers[pw_carry] = CR_NONE;
|
player->powers[pw_carry] = CR_NONE;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
P_TryMove(player->mo, player->mo->tracer->x, player->mo->tracer->y, true);
|
P_TryMove(player->mo, tails->x, tails->y, true);
|
||||||
player->mo->momx = player->mo->tracer->momx;
|
player->mo->momx = tails->momx;
|
||||||
player->mo->momy = player->mo->tracer->momy;
|
player->mo->momy = tails->momy;
|
||||||
player->mo->momz = player->mo->tracer->momz;
|
player->mo->momz = tails->momz;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gametype == GT_COOP)
|
if (gametype == GT_COOP)
|
||||||
{
|
{
|
||||||
player->mo->angle = player->mo->tracer->angle;
|
player->mo->angle = tails->angle;
|
||||||
|
|
||||||
if (!demoplayback || P_AnalogMove(player))
|
if (!demoplayback || P_AnalogMove(player))
|
||||||
{
|
{
|
||||||
|
|
@ -11733,7 +11738,7 @@ void P_PlayerAfterThink(player_t *player)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (P_AproxDistance(player->mo->x - player->mo->tracer->x, player->mo->y - player->mo->tracer->y) > player->mo->radius)
|
if (P_AproxDistance(player->mo->x - tails->x, player->mo->y - tails->y) > player->mo->radius)
|
||||||
player->powers[pw_carry] = CR_NONE;
|
player->powers[pw_carry] = CR_NONE;
|
||||||
|
|
||||||
if (player->powers[pw_carry] != CR_NONE)
|
if (player->powers[pw_carry] != CR_NONE)
|
||||||
|
|
@ -11746,49 +11751,58 @@ void P_PlayerAfterThink(player_t *player)
|
||||||
|
|
||||||
if (player-players == consoleplayer && botingame)
|
if (player-players == consoleplayer && botingame)
|
||||||
CV_SetValue(&cv_analog2, (player->powers[pw_carry] != CR_PLAYER));
|
CV_SetValue(&cv_analog2, (player->powers[pw_carry] != CR_PLAYER));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else if (player->powers[pw_carry] == CR_GENERIC && player->mo->tracer)
|
case CR_GENERIC: // being carried by some generic item
|
||||||
{
|
{
|
||||||
|
mobj_t *item = player->mo->tracer;
|
||||||
// tracer is what you're hanging onto
|
// tracer is what you're hanging onto
|
||||||
P_UnsetThingPosition(player->mo);
|
P_UnsetThingPosition(player->mo);
|
||||||
player->mo->x = player->mo->tracer->x;
|
player->mo->x = item->x;
|
||||||
player->mo->y = player->mo->tracer->y;
|
player->mo->y = item->y;
|
||||||
if (player->mo->eflags & MFE_VERTICALFLIP)
|
if (player->mo->eflags & MFE_VERTICALFLIP)
|
||||||
player->mo->z = player->mo->tracer->z + player->mo->tracer->height - FixedDiv(player->mo->height, 3*FRACUNIT);
|
player->mo->z = item->z + item->height - FixedDiv(player->mo->height, 3*FRACUNIT);
|
||||||
else
|
else
|
||||||
player->mo->z = player->mo->tracer->z - FixedDiv(player->mo->height, 3*FRACUNIT/2);
|
player->mo->z = item->z - FixedDiv(player->mo->height, 3*FRACUNIT/2);
|
||||||
player->mo->momx = player->mo->momy = player->mo->momz = 0;
|
player->mo->momx = player->mo->momy = player->mo->momz = 0;
|
||||||
P_SetThingPosition(player->mo);
|
P_SetThingPosition(player->mo);
|
||||||
if (player->mo->state-states != S_PLAY_RIDE)
|
if (player->mo->state-states != S_PLAY_RIDE)
|
||||||
P_SetPlayerMobjState(player->mo, S_PLAY_RIDE);
|
P_SetPlayerMobjState(player->mo, S_PLAY_RIDE);
|
||||||
|
|
||||||
// Controllable missile
|
// Controllable missile
|
||||||
if (player->mo->tracer->type == MT_BLACKEGGMAN_MISSILE)
|
if (item->type == MT_BLACKEGGMAN_MISSILE)
|
||||||
{
|
{
|
||||||
if (cmd->forwardmove > 0)
|
if (cmd->forwardmove > 0)
|
||||||
player->mo->tracer->momz += FixedMul(FRACUNIT/4, player->mo->tracer->scale);
|
item->momz += FixedMul(FRACUNIT/4, item->scale);
|
||||||
else if (cmd->forwardmove < 0)
|
else if (cmd->forwardmove < 0)
|
||||||
player->mo->tracer->momz -= FixedMul(FRACUNIT/4, player->mo->tracer->scale);
|
item->momz -= FixedMul(FRACUNIT/4, item->scale);
|
||||||
|
|
||||||
player->mo->tracer->angle = player->mo->angle;
|
item->angle = player->mo->angle;
|
||||||
P_InstaThrust(player->mo->tracer, player->mo->tracer->angle, FixedMul(player->mo->tracer->info->speed, player->mo->tracer->scale));
|
P_InstaThrust(item, item->angle, FixedMul(item->info->speed, item->scale));
|
||||||
|
|
||||||
if (player->mo->z <= player->mo->floorz
|
if (player->mo->z <= player->mo->floorz || item->health <= 0)
|
||||||
|| player->mo->tracer->health <= 0)
|
|
||||||
{
|
{
|
||||||
player->powers[pw_carry] = CR_NONE;
|
player->powers[pw_carry] = CR_NONE;
|
||||||
P_SetTarget(&player->mo->tracer, NULL);
|
P_SetTarget(&player->mo->tracer, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else if (player->powers[pw_carry] == CR_MACESPIN && player->mo->tracer && player->mo->tracer->tracer)
|
case CR_MACESPIN: // being carried by a spinning chain
|
||||||
{
|
{
|
||||||
|
mobj_t *chain;
|
||||||
|
mobj_t *macecenter;
|
||||||
|
if (!player->mo->tracer->tracer) // can't spin around a point if... there is no point in doing so
|
||||||
|
break;
|
||||||
|
chain = player->mo->tracer;
|
||||||
|
macecenter = player->mo->tracer->tracer;
|
||||||
|
|
||||||
player->mo->height = P_GetPlayerSpinHeight(player);
|
player->mo->height = P_GetPlayerSpinHeight(player);
|
||||||
// tracer is what you're hanging onto....
|
// tracer is what you're hanging onto....
|
||||||
player->mo->momx = (player->mo->tracer->x - player->mo->x)*2;
|
player->mo->momx = (chain->x - player->mo->x)*2;
|
||||||
player->mo->momy = (player->mo->tracer->y - player->mo->y)*2;
|
player->mo->momy = (chain->y - player->mo->y)*2;
|
||||||
player->mo->momz = (player->mo->tracer->z - (player->mo->height-player->mo->tracer->height/2) - player->mo->z)*2;
|
player->mo->momz = (chain->z - (player->mo->height-chain->height/2) - player->mo->z)*2;
|
||||||
P_TeleportMove(player->mo, player->mo->tracer->x, player->mo->tracer->y, player->mo->tracer->z - (player->mo->height-player->mo->tracer->height/2));
|
P_TeleportMove(player->mo, chain->x, chain->y, chain->z - (player->mo->height-chain->height/2));
|
||||||
if (!player->powers[pw_flashing]) // handle getting hurt
|
if (!player->powers[pw_flashing]) // handle getting hurt
|
||||||
{
|
{
|
||||||
player->pflags |= PF_JUMPED;
|
player->pflags |= PF_JUMPED;
|
||||||
|
|
@ -11796,10 +11810,10 @@ void P_PlayerAfterThink(player_t *player)
|
||||||
player->secondjump = 0;
|
player->secondjump = 0;
|
||||||
player->pflags &= ~PF_THOKKED;
|
player->pflags &= ~PF_THOKKED;
|
||||||
|
|
||||||
if ((player->mo->tracer->tracer->flags & MF_SLIDEME) // Noclimb on chain parameters gives this
|
if ((macecenter->flags & MF_SLIDEME) // Noclimb on chain parameters gives this
|
||||||
&& !(twodlevel || player->mo->flags2 & MF2_TWOD)) // why on earth would you want to turn them in 2D mode?
|
&& !(twodlevel || player->mo->flags2 & MF2_TWOD)) // why on earth would you want to turn them in 2D mode?
|
||||||
{
|
{
|
||||||
player->mo->tracer->tracer->angle += cmd->sidemove<<ANGLETOFINESHIFT;
|
macecenter->angle += cmd->sidemove<<ANGLETOFINESHIFT;
|
||||||
player->mo->angle += cmd->sidemove<<ANGLETOFINESHIFT; // 2048 --> ANGLE_MAX
|
player->mo->angle += cmd->sidemove<<ANGLETOFINESHIFT; // 2048 --> ANGLE_MAX
|
||||||
|
|
||||||
if (!demoplayback || P_AnalogMove(player))
|
if (!demoplayback || P_AnalogMove(player))
|
||||||
|
|
@ -11811,6 +11825,11 @@ void P_PlayerAfterThink(player_t *player)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (thiscam)
|
if (thiscam)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue