mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Instead of hacking ticcmd generation, add/modify helper functions acting as intermediaries that add the necessary changes.
* Introducing K_GetKartButtons(player_t), for adding false presses to. * K_GetForwardMove(player_t) takes kickstarting into account, and is now applied to engine sound generation too. * BT_REALACCELERATE has been deleted.
This commit is contained in:
parent
cce4165f35
commit
a43a762b46
10 changed files with 57 additions and 40 deletions
|
|
@ -33,7 +33,6 @@ typedef enum
|
|||
BT_FORWARD = 1<<5, // Aim Item Forward
|
||||
BT_BACKWARD = 1<<6, // Aim Item Backward
|
||||
BT_LOOKBACK = 1<<7, // Look Backward
|
||||
BT_REALACCELERATE = 1<<8, // Accelerate but not influenced by boosting or kickstart
|
||||
|
||||
BT_EBRAKEMASK = (BT_ACCELERATE|BT_BRAKE),
|
||||
|
||||
|
|
|
|||
|
|
@ -11649,7 +11649,6 @@ struct {
|
|||
{"BT_ATTACK",BT_ATTACK},
|
||||
{"BT_FORWARD",BT_FORWARD},
|
||||
{"BT_BACKWARD",BT_BACKWARD},
|
||||
{"BT_REALACCELERATE",BT_REALACCELERATE},
|
||||
{"BT_CUSTOM1",BT_CUSTOM1}, // Lua customizable
|
||||
{"BT_CUSTOM2",BT_CUSTOM2}, // Lua customizable
|
||||
{"BT_CUSTOM3",BT_CUSTOM3}, // Lua customizable
|
||||
|
|
|
|||
|
|
@ -1012,14 +1012,9 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
|
|||
// forward with key or button // SRB2kart - we use an accel/brake instead of forward/backward.
|
||||
axis = PlayerJoyAxis(ssplayer, AXISMOVE);
|
||||
if (PlayerInputDown(ssplayer, gc_accelerate) || (gamepadjoystickmove && axis > 0))
|
||||
{
|
||||
cmd->buttons |= (BT_ACCELERATE|BT_REALACCELERATE);
|
||||
forward = MAXPLMOVE; // 50
|
||||
}
|
||||
else if ((gamestate == GS_LEVEL) && (player->kartstuff[k_sneakertimer] || (player->kickstartaccel >= ACCEL_KICKSTART)))
|
||||
{
|
||||
cmd->buttons |= BT_ACCELERATE;
|
||||
forward = MAXPLMOVE;
|
||||
forward = MAXPLMOVE; // 50
|
||||
}
|
||||
else if (analogjoystickmove && axis > 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -990,7 +990,7 @@ void K_BuildBotTiccmd(player_t *player, ticcmd_t *cmd)
|
|||
rad = playerwidth;
|
||||
}
|
||||
|
||||
cmd->buttons |= (BT_ACCELERATE|BT_REALACCELERATE);
|
||||
cmd->buttons |= BT_ACCELERATE;
|
||||
|
||||
// Full speed ahead!
|
||||
cmd->forwardmove = MAXPLMOVE;
|
||||
|
|
@ -1067,7 +1067,7 @@ void K_BuildBotTiccmd(player_t *player, ticcmd_t *cmd)
|
|||
// where we figure out what the shape of the track looks like.
|
||||
UINT16 oldButtons = cmd->buttons;
|
||||
|
||||
cmd->buttons &= ~(BT_ACCELERATE|BT_REALACCELERATE|BT_BRAKE);
|
||||
cmd->buttons &= ~(BT_ACCELERATE|BT_BRAKE);
|
||||
|
||||
if (oldButtons & BT_ACCELERATE)
|
||||
{
|
||||
|
|
@ -1076,7 +1076,7 @@ void K_BuildBotTiccmd(player_t *player, ticcmd_t *cmd)
|
|||
|
||||
if (oldButtons & BT_BRAKE)
|
||||
{
|
||||
cmd->buttons |= (BT_ACCELERATE|BT_REALACCELERATE);
|
||||
cmd->buttons |= BT_ACCELERATE;
|
||||
}
|
||||
|
||||
cmd->forwardmove = -cmd->forwardmove;
|
||||
|
|
|
|||
|
|
@ -3829,7 +3829,7 @@ static void K_drawInput(void)
|
|||
V_DrawFill(x+(xoffs), y+offs, BUTTW-1, BUTTH, col);\
|
||||
V_DrawFixedPatch((x+1+(xoffs))<<FRACBITS, (y+offs+1)<<FRACBITS, FRACUNIT, splitflags, fontv[TINY_FONT].font[symb-HU_FONTSTART], NULL)
|
||||
|
||||
drawbutt(-2*BUTTW, BT_REALACCELERATE, 'A');
|
||||
drawbutt(-2*BUTTW, BT_ACCELERATE, 'A');
|
||||
drawbutt( -BUTTW, BT_BRAKE, 'B');
|
||||
drawbutt( 0, BT_DRIFT, 'D');
|
||||
drawbutt( BUTTW, BT_ATTACK, 'I');
|
||||
|
|
|
|||
60
src/k_kart.c
60
src/k_kart.c
|
|
@ -1902,19 +1902,19 @@ void K_KartMoveAnimation(player_t *player)
|
|||
|
||||
const boolean onground = P_IsObjectOnGround(player->mo);
|
||||
|
||||
ticcmd_t *cmd = &player->cmd;
|
||||
const boolean spinningwheels = (((cmd->buttons & BT_ACCELERATE) == BT_ACCELERATE) || (onground && player->speed > 0));
|
||||
const boolean lookback = ((cmd->buttons & BT_LOOKBACK) == BT_LOOKBACK);
|
||||
UINT16 buttons = K_GetKartButtons(player);
|
||||
const boolean spinningwheels = (((buttons & BT_ACCELERATE) == BT_ACCELERATE) || (onground && player->speed > 0));
|
||||
const boolean lookback = ((buttons & BT_LOOKBACK) == BT_LOOKBACK);
|
||||
|
||||
SINT8 turndir = 0;
|
||||
SINT8 destGlanceDir = 0;
|
||||
SINT8 drift = player->kartstuff[k_drift];
|
||||
|
||||
if (cmd->turning < -minturn)
|
||||
if (player->cmd.turning < -minturn)
|
||||
{
|
||||
turndir = -1;
|
||||
}
|
||||
else if (cmd->turning > minturn)
|
||||
else if (player->cmd.turning > minturn)
|
||||
{
|
||||
turndir = 1;
|
||||
}
|
||||
|
|
@ -2583,6 +2583,19 @@ UINT16 K_GetKartFlashing(player_t *player)
|
|||
return tics;
|
||||
}
|
||||
|
||||
boolean K_KartKickstart(player_t *player)
|
||||
{
|
||||
return ((player->pflags & PF_KICKSTARTACCEL)
|
||||
&& (!K_PlayerUsesBotMovement(player))
|
||||
&& (player->kickstartaccel >= ACCEL_KICKSTART));
|
||||
}
|
||||
|
||||
UINT16 K_GetKartButtons(player_t *player)
|
||||
{
|
||||
return (player->cmd.buttons |
|
||||
(K_KartKickstart(player) ? BT_ACCELERATE : 0));
|
||||
}
|
||||
|
||||
SINT8 K_GetForwardMove(player_t *player)
|
||||
{
|
||||
SINT8 forwardmove = player->cmd.forwardmove;
|
||||
|
|
@ -2602,6 +2615,13 @@ SINT8 K_GetForwardMove(player_t *player)
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (K_KartKickstart(player)) // unlike the brute forward of sneakers, allow for backwards easing here
|
||||
{
|
||||
forwardmove += MAXPLMOVE;
|
||||
if (forwardmove > MAXPLMOVE)
|
||||
forwardmove = MAXPLMOVE;
|
||||
}
|
||||
|
||||
return forwardmove;
|
||||
}
|
||||
|
||||
|
|
@ -5632,7 +5652,7 @@ player_t *K_FindJawzTarget(mobj_t *actor, player_t *source)
|
|||
}
|
||||
|
||||
// Engine Sounds.
|
||||
static void K_UpdateEngineSounds(player_t *player, ticcmd_t *cmd)
|
||||
static void K_UpdateEngineSounds(player_t *player)
|
||||
{
|
||||
const INT32 numsnds = 13;
|
||||
|
||||
|
|
@ -5641,6 +5661,8 @@ static void K_UpdateEngineSounds(player_t *player, ticcmd_t *cmd)
|
|||
|
||||
const UINT8 dampenval = 48; // 255 * 48 = close enough to FRACUNIT/6
|
||||
|
||||
const UINT16 buttons = K_GetKartButtons(player);
|
||||
|
||||
INT32 class, s, w; // engine class number
|
||||
|
||||
UINT8 volume = 255;
|
||||
|
|
@ -5681,17 +5703,17 @@ static void K_UpdateEngineSounds(player_t *player, ticcmd_t *cmd)
|
|||
if (player->respawn.state == RESPAWNST_DROP) // Dropdashing
|
||||
{
|
||||
// Dropdashing
|
||||
targetsnd = ((cmd->buttons & BT_ACCELERATE) ? 12 : 0);
|
||||
targetsnd = ((buttons & BT_ACCELERATE) ? 12 : 0);
|
||||
}
|
||||
else if (K_PlayerEBrake(player) == true)
|
||||
{
|
||||
// Spindashing
|
||||
targetsnd = ((cmd->buttons & BT_DRIFT) ? 12 : 0);
|
||||
targetsnd = ((buttons & BT_DRIFT) ? 12 : 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Average out the value of forwardmove and the speed that you're moving at.
|
||||
targetsnd = (((6 * cmd->forwardmove) / 25) + ((player->speed / mapobjectscale) / 5)) / 2;
|
||||
targetsnd = (((6 * K_GetForwardMove(player)) / 25) + ((player->speed / mapobjectscale) / 5)) / 2;
|
||||
}
|
||||
|
||||
if (targetsnd < 0) { targetsnd = 0; }
|
||||
|
|
@ -5989,7 +6011,7 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd)
|
|||
{
|
||||
K_UpdateOffroad(player);
|
||||
K_UpdateDraft(player);
|
||||
K_UpdateEngineSounds(player, cmd); // Thanks, VAda!
|
||||
K_UpdateEngineSounds(player); // Thanks, VAda!
|
||||
|
||||
// update boost angle if not spun out
|
||||
if (!player->kartstuff[k_spinouttimer] && !player->kartstuff[k_wipeoutslow])
|
||||
|
|
@ -6471,7 +6493,7 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd)
|
|||
if (cmd->buttons & BT_DRIFT)
|
||||
{
|
||||
// Only allow drifting while NOT trying to do an spindash input.
|
||||
if ((cmd->buttons & BT_EBRAKEMASK) != BT_EBRAKEMASK)
|
||||
if ((K_GetKartButtons(player) & BT_EBRAKEMASK) != BT_EBRAKEMASK)
|
||||
{
|
||||
player->driftInput = true;
|
||||
}
|
||||
|
|
@ -7019,7 +7041,7 @@ INT16 K_GetKartTurnValue(player_t *player, INT16 turnvalue)
|
|||
currentSpeed = R_PointToDist2(0, 0, player->mo->momx, player->mo->momy);
|
||||
|
||||
if ((currentSpeed <= 0) // Not moving
|
||||
&& ((player->cmd.buttons & BT_EBRAKEMASK) != BT_EBRAKEMASK) // not e-braking
|
||||
&& ((K_GetKartButtons(player) & BT_EBRAKEMASK) != BT_EBRAKEMASK) // not e-braking
|
||||
&& (player->respawn.state == RESPAWNST_NONE)) // Not respawning
|
||||
{
|
||||
return 0;
|
||||
|
|
@ -7123,6 +7145,8 @@ static void K_KartDrift(player_t *player, boolean onground)
|
|||
const INT32 dstwo = dsone*2;
|
||||
const INT32 dsthree = dstwo*2;
|
||||
|
||||
const UINT16 buttons = K_GetKartButtons(player);
|
||||
|
||||
// Drifting is actually straffing + automatic turning.
|
||||
// Holding the Jump button will enable drifting.
|
||||
// (This comment is extremely funny)
|
||||
|
|
@ -7329,8 +7353,8 @@ static void K_KartDrift(player_t *player, boolean onground)
|
|||
K_SpawnAIZDust(player);
|
||||
|
||||
if (player->kartstuff[k_drift]
|
||||
&& ((player->cmd.buttons & BT_BRAKE)
|
||||
|| !(player->cmd.buttons & BT_ACCELERATE))
|
||||
&& ((buttons & BT_BRAKE)
|
||||
|| !(buttons & BT_ACCELERATE))
|
||||
&& P_IsObjectOnGround(player->mo))
|
||||
{
|
||||
if (!player->kartstuff[k_brakedrift])
|
||||
|
|
@ -7504,7 +7528,7 @@ static INT32 K_FlameShieldMax(player_t *player)
|
|||
|
||||
boolean K_PlayerEBrake(player_t *player)
|
||||
{
|
||||
return (player->cmd.buttons & BT_EBRAKEMASK) == BT_EBRAKEMASK
|
||||
return (K_GetKartButtons(player) & BT_EBRAKEMASK) == BT_EBRAKEMASK
|
||||
&& P_IsObjectOnGround(player->mo) == true
|
||||
&& player->kartstuff[k_drift] == 0
|
||||
&& player->kartstuff[k_spinouttimer] == 0
|
||||
|
|
@ -7687,8 +7711,6 @@ static void K_AirFailsafe(player_t *player)
|
|||
const fixed_t maxSpeed = 6*player->mo->scale;
|
||||
const fixed_t thrustSpeed = 6*player->mo->scale; // 10*player->mo->scale
|
||||
|
||||
ticcmd_t *cmd = &player->cmd;
|
||||
|
||||
if (player->speed > maxSpeed // Above the max speed that you're allowed to use this technique.
|
||||
|| player->respawn.state != RESPAWNST_NONE) // Respawning, you don't need this AND drop dash :V
|
||||
{
|
||||
|
|
@ -7696,7 +7718,7 @@ static void K_AirFailsafe(player_t *player)
|
|||
return;
|
||||
}
|
||||
|
||||
if ((cmd->buttons & BT_ACCELERATE) || K_GetForwardMove(player) != 0)
|
||||
if ((K_GetKartButtons(player) & BT_ACCELERATE) || K_GetForwardMove(player) != 0)
|
||||
{
|
||||
// Queue up later
|
||||
player->airFailsafe = true;
|
||||
|
|
@ -7738,7 +7760,7 @@ void K_AdjustPlayerFriction(player_t *player)
|
|||
{
|
||||
player->mo->friction -= 1024;
|
||||
}
|
||||
else if (player->speed > 0 && cmd->forwardmove < 0)
|
||||
else if (player->speed > 0 && K_GetForwardMove(player) < 0)
|
||||
{
|
||||
player->mo->friction -= 512;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,6 +91,8 @@ fixed_t K_GetKartSpeedFromStat(UINT8 kartspeed);
|
|||
fixed_t K_GetKartSpeed(player_t *player, boolean doboostpower);
|
||||
fixed_t K_GetKartAccel(player_t *player);
|
||||
UINT16 K_GetKartFlashing(player_t *player);
|
||||
boolean K_KartKickstart(player_t *player);
|
||||
UINT16 K_GetKartButtons(player_t *player);
|
||||
SINT8 K_GetForwardMove(player_t *player);
|
||||
fixed_t K_3dKartMovement(player_t *player);
|
||||
boolean K_PlayerEBrake(player_t *player);
|
||||
|
|
|
|||
|
|
@ -648,7 +648,7 @@ static void K_DropDashWait(player_t *player)
|
|||
--------------------------------------------------*/
|
||||
static void K_HandleDropDash(player_t *player)
|
||||
{
|
||||
ticcmd_t *cmd = &player->cmd;
|
||||
const UINT16 buttons = K_GetKartButtons(player);
|
||||
|
||||
if (player->kartstuff[k_growshrinktimer] < 0)
|
||||
{
|
||||
|
|
@ -673,7 +673,7 @@ static void K_HandleDropDash(player_t *player)
|
|||
// The old behavior was stupid and prone to accidental usage.
|
||||
// Let's rip off Mania instead, and turn this into a Drop Dash!
|
||||
|
||||
if ((cmd->buttons & BT_ACCELERATE) && !player->kartstuff[k_spinouttimer]) // Since we're letting players spin out on respawn, don't let them charge a dropdash in this state. (It wouldn't work anyway)
|
||||
if ((buttons & BT_ACCELERATE) && !player->kartstuff[k_spinouttimer]) // Since we're letting players spin out on respawn, don't let them charge a dropdash in this state. (It wouldn't work anyway)
|
||||
{
|
||||
player->respawn.dropdash++;
|
||||
}
|
||||
|
|
@ -698,7 +698,7 @@ static void K_HandleDropDash(player_t *player)
|
|||
}
|
||||
else
|
||||
{
|
||||
if ((cmd->buttons & BT_ACCELERATE) && (player->respawn.dropdash >= TICRATE/4))
|
||||
if ((buttons & BT_ACCELERATE) && (player->respawn.dropdash >= TICRATE/4))
|
||||
{
|
||||
S_StartSound(player->mo, sfx_s23c);
|
||||
player->kartstuff[k_startboost] = 50;
|
||||
|
|
|
|||
|
|
@ -6839,7 +6839,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj)
|
|||
if ((!mobj->target || !mobj->target->health || !mobj->target->player || !P_IsObjectOnGround(mobj->target))
|
||||
|| !mobj->target->player->kartstuff[k_drift] || !mobj->target->player->kartstuff[k_brakedrift]
|
||||
|| !((mobj->target->player->cmd.buttons & BT_BRAKE)
|
||||
|| (mobj->target->player->cmd.buttons & BT_ACCELERATE))) // Letting go of accel functions about the same as brake-drifting
|
||||
|| (K_GetKartButtons(mobj->target->player) & BT_ACCELERATE))) // Letting go of accel functions about the same as brake-drifting
|
||||
{
|
||||
P_RemoveMobj(mobj);
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -4327,7 +4327,7 @@ void P_PlayerThink(player_t *player)
|
|||
// Accessibility - kickstart your acceleration
|
||||
if (!(player->pflags & PF_KICKSTARTACCEL))
|
||||
player->kickstartaccel = 0;
|
||||
else if (cmd->buttons & BT_REALACCELERATE)
|
||||
else if (cmd->buttons & BT_ACCELERATE)
|
||||
{
|
||||
if (!player->exiting && !(player->pflags & PF_ACCELDOWN))
|
||||
player->kickstartaccel = 0;
|
||||
|
|
@ -4569,7 +4569,7 @@ void P_PlayerThink(player_t *player)
|
|||
#endif
|
||||
|
||||
// check for buttons
|
||||
if (cmd->buttons & BT_REALACCELERATE)
|
||||
if (cmd->buttons & BT_ACCELERATE)
|
||||
player->pflags |= PF_ACCELDOWN;
|
||||
else
|
||||
player->pflags &= ~PF_ACCELDOWN;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue