From 29e11a03782edd17634fdaf8a09b209c0a13d85d Mon Sep 17 00:00:00 2001 From: Latapostrophe Date: Thu, 22 Apr 2021 15:11:15 +0200 Subject: [PATCH 01/11] changes to the delay, boost when doing upwards trick --- src/d_player.h | 6 ++++++ src/k_kart.c | 39 +++++++++++++++++++++++++++++++++++---- src/p_mobj.c | 2 +- src/p_saveg.c | 8 ++++++++ src/p_user.c | 2 +- 5 files changed, 51 insertions(+), 6 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index afa232991..8f1481499 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -241,6 +241,7 @@ typedef enum // CONSTANTS FOR TRICK PANELS #define TRICKMOMZRAMP (30) #define TRICKLAG (9) +#define TRICKDELAY (TICRATE/2) #define TUMBLEBOUNCES 3 @@ -450,9 +451,14 @@ typedef struct player_s UINT8 jawztargetdelay; // (0 to 5) - Delay for Jawz target switching, to make it less twitchy UINT8 trickpanel; // Trick panel state + tic_t tricktime; // Increases while you're tricking. You can't input any trick until it's reached a certain threshold fixed_t trickmomx; fixed_t trickmomy; fixed_t trickmomz; + fixed_t trickboostpower; // Save the rough speed multiplier. Used for upwards tricks. + tic_t trickboostdecay; // used to know how long you've waited + tic_t trickboost; // Trick boost. This one is weird and has variable speed. Dear god. + UINT32 roundscore; // battle score this round UINT8 emeralds; diff --git a/src/k_kart.c b/src/k_kart.c index dedf9dddc..9a5bd8b05 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -2546,6 +2546,11 @@ static void K_GetKartBoostPower(player_t *player) } } + if (player->trickboost) // Trick pannel up-boost + { + ADDBOOST(player->trickboostpower, 5*FRACUNIT, 0); // % speed, 500% accel, 0% handling + } + if (player->ringboost) // Ring Boost { ADDBOOST(FRACUNIT/5, 4*FRACUNIT, 0); // + 20% top speed, + 400% acceleration, +0% handling @@ -4868,7 +4873,10 @@ void K_DoPogoSpring(mobj_t *mo, fixed_t vertispeed, UINT8 sound) thrust = FixedMul(thrust, 9*FRACUNIT/8); } - mo->player->trickmomx = mo->player->trickmomy = mo->player->trickmomz = 0; // Reset post-hitlag momentums. + mo->player->trickmomx = mo->player->trickmomy = mo->player->trickmomz = mo->player->tricktime = 0; // Reset post-hitlag momentums and timer + // Setup the boost for potential upwards trick, at worse, make it your regular max speed. + mo->player->trickboostpower = max(FixedDiv(mo->player->speed, K_GetKartSpeed(mo->player, false)) - FRACUNIT, 0); + //CONS_Printf("Got boost: %d%\n", mo->player->trickboostpower*100 / FRACUNIT); } mo->momz = FixedMul(thrust, vscale); @@ -6284,7 +6292,7 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) // Speed lines if (player->sneakertimer || player->ringboost || player->driftboost || player->startboost - || player->eggmanexplode) + || player->eggmanexplode || player->trickboost) { if (player->invincibilitytimer) K_SpawnInvincibilitySpeedLines(player->mo); @@ -6525,6 +6533,9 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) } } + if (player->trickboost) + player->trickboost--; + if (player->flamedash) player->flamedash--; @@ -8787,6 +8798,9 @@ void K_MoveKartPlayer(player_t *player, boolean onground) fixed_t basespeed = P_AproxDistance(player->mo->momx, player->mo->momy); // at WORSE, keep your normal speed when tricking. fixed_t speed = FixedMul(speedmult, P_AproxDistance(player->mo->momx, player->mo->momy)); + if (!cmd->turning && !player->throwdir) // increment this counter while your inputs are neutral + player->tricktime++; + // debug shit //CONS_Printf("%d\n", player->mo->momz / mapobjectscale); if (momz < -10*FRACUNIT) // :youfuckedup: @@ -8858,6 +8872,12 @@ void K_MoveKartPlayer(player_t *player, boolean onground) relative = false; } + // Calculate speed boost decay: + // Base speed boost duration is 35 tics. + // At most, lose 3/4th of your boost. + player->trickboostdecay = min(TICRATE*3/4, abs(momz/FRACUNIT)); + //CONS_Printf("decay: %d\n", player->trickboostdecay); + P_SetObjectMomZ(player->mo, 48*FRACUNIT, relative); player->trickmomx = player->mo->momx; @@ -8866,7 +8886,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) P_InstaThrust(player->mo, 0, 0); // Sike, you have no speed :) player->mo->momz = 0; - player->trickpanel = 3; + player->trickpanel = 4; player->mo->hitlag = TRICKLAG; } } @@ -8882,8 +8902,19 @@ void K_MoveKartPlayer(player_t *player, boolean onground) } + else if (player->trickpanel == 4 && P_IsObjectOnGround(player->mo)) // Upwards trick landed! + { + //CONS_Printf("apply boost\n"); + S_StartSound(player->mo, sfx_s23c); + K_SpawnDashDustRelease(player); + player->trickboost = TICRATE - player->trickboostdecay; + + player->trickpanel = player->trickboostdecay = 0; + } + // Wait until we let go off the control stick to remove the delay - if ((player->pflags & PF_TRICKDELAY) && !player->throwdir && !cmd->turning) + // buttons must be neutral after the initial trick delay. This prevents weirdness where slight nudges after blast off would send you flying. + if ((player->pflags & PF_TRICKDELAY) && !player->throwdir && !cmd->turning && (player->tricktime >= TRICKDELAY)) { player->pflags &= ~PF_TRICKDELAY; } diff --git a/src/p_mobj.c b/src/p_mobj.c index f3711f819..8cccc7963 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1109,7 +1109,7 @@ fixed_t P_GetMobjGravity(mobj_t *mo) gravityadd = (4*gravityadd)/3; } - if (mo->player->trickpanel == 2 || mo->player->trickpanel == 3) + if (mo->player->trickpanel >= 2) { gravityadd = (5*gravityadd)/2; } diff --git a/src/p_saveg.c b/src/p_saveg.c index 35f68be29..9f2d182fb 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -305,9 +305,13 @@ static void P_NetArchivePlayers(void) WRITEUINT8(save_p, players[i].jawztargetdelay); WRITEUINT8(save_p, players[i].trickpanel); + WRITEUINT32(save_p, players[i].tricktime); WRITEUINT32(save_p, players[i].trickmomx); WRITEUINT32(save_p, players[i].trickmomy); WRITEUINT32(save_p, players[i].trickmomz); + WRITEUINT32(save_p, players[i].trickboostpower); + WRITEUINT32(save_p, players[i].trickboostdecay); + WRITEUINT32(save_p, players[i].trickboost); WRITEUINT32(save_p, players[i].roundscore); WRITEUINT8(save_p, players[i].emeralds); @@ -557,9 +561,13 @@ static void P_NetUnArchivePlayers(void) players[i].jawztargetdelay = READUINT8(save_p); players[i].trickpanel = READUINT8(save_p); + players[i].tricktime = (tic_t)READUINT32(save_p); players[i].trickmomx = READUINT32(save_p); players[i].trickmomy = READUINT32(save_p); players[i].trickmomz = READUINT32(save_p); + players[i].trickboostpower = READUINT32(save_p); + players[i].trickboostdecay = (tic_t)READUINT32(save_p); + players[i].trickboost = (tic_t)READUINT32(save_p); players[i].roundscore = READUINT32(save_p); players[i].emeralds = READUINT8(save_p); diff --git a/src/p_user.c b/src/p_user.c index 3cd0bba5c..18afb0337 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2030,7 +2030,7 @@ void P_MovePlayer(player_t *player) { player->drawangle += ANGLE_22h; } - else if (player->trickpanel == 3) + else if (player->trickpanel >= 3) { player->drawangle -= ANGLE_22h; } From a25b79885d805721946e9ec29f371c08638c4b08 Mon Sep 17 00:00:00 2001 From: Latapostrophe Date: Thu, 22 Apr 2021 19:33:01 +0200 Subject: [PATCH 02/11] 1/4s delay w/o input checks instead of 1/2 w/ input checks --- src/d_player.h | 2 +- src/k_kart.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index 8f1481499..84165192b 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -241,7 +241,7 @@ typedef enum // CONSTANTS FOR TRICK PANELS #define TRICKMOMZRAMP (30) #define TRICKLAG (9) -#define TRICKDELAY (TICRATE/2) +#define TRICKDELAY (TICRATE/4) #define TUMBLEBOUNCES 3 diff --git a/src/k_kart.c b/src/k_kart.c index 9a5bd8b05..5848f5b09 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8798,8 +8798,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) fixed_t basespeed = P_AproxDistance(player->mo->momx, player->mo->momy); // at WORSE, keep your normal speed when tricking. fixed_t speed = FixedMul(speedmult, P_AproxDistance(player->mo->momx, player->mo->momy)); - if (!cmd->turning && !player->throwdir) // increment this counter while your inputs are neutral - player->tricktime++; + player->tricktime++; // debug shit //CONS_Printf("%d\n", player->mo->momz / mapobjectscale); From 8b50b0ddd76b0500bae355a778177d24e634806f Mon Sep 17 00:00:00 2001 From: Latapostrophe Date: Thu, 22 Apr 2021 21:26:00 +0200 Subject: [PATCH 03/11] boost is now 125%, allow turning after upwards trick --- src/k_kart.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 5848f5b09..c714a68c2 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -4874,8 +4874,8 @@ void K_DoPogoSpring(mobj_t *mo, fixed_t vertispeed, UINT8 sound) } mo->player->trickmomx = mo->player->trickmomy = mo->player->trickmomz = mo->player->tricktime = 0; // Reset post-hitlag momentums and timer - // Setup the boost for potential upwards trick, at worse, make it your regular max speed. - mo->player->trickboostpower = max(FixedDiv(mo->player->speed, K_GetKartSpeed(mo->player, false)) - FRACUNIT, 0); + // Setup the boost for potential upwards trick, at worse, make it your regular max speed. (boost = curr speed*1.25) + mo->player->trickboostpower = max(FixedDiv(mo->player->speed, K_GetKartSpeed(mo->player, false)) - FRACUNIT, 0)*125/100; //CONS_Printf("Got boost: %d%\n", mo->player->trickboostpower*100 / FRACUNIT); } @@ -7279,9 +7279,9 @@ INT16 K_GetKartTurnValue(player_t *player, INT16 turnvalue) return 0; } - if (player->trickpanel != 0) + if (player->trickpanel != 0 && player->trickpanel < 4) { - // No turning during trick panel + // No turning during trick panel unless you did the upwards trick (4) return 0; } From d10f4ea1281059ca4b549386babfe9316c979ae2 Mon Sep 17 00:00:00 2001 From: Latapostrophe Date: Fri, 23 Apr 2021 00:14:36 +0200 Subject: [PATCH 04/11] More suitable data types + lua push --- src/d_player.h | 6 +++--- src/k_kart.c | 6 ++++-- src/lua_playerlib.c | 16 ++++++++++++++++ src/p_saveg.c | 12 ++++++------ 4 files changed, 29 insertions(+), 11 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index 84165192b..445c1148d 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -451,13 +451,13 @@ typedef struct player_s UINT8 jawztargetdelay; // (0 to 5) - Delay for Jawz target switching, to make it less twitchy UINT8 trickpanel; // Trick panel state - tic_t tricktime; // Increases while you're tricking. You can't input any trick until it's reached a certain threshold + UINT8 tricktime; // Increases while you're tricking. You can't input any trick until it's reached a certain threshold fixed_t trickmomx; fixed_t trickmomy; fixed_t trickmomz; fixed_t trickboostpower; // Save the rough speed multiplier. Used for upwards tricks. - tic_t trickboostdecay; // used to know how long you've waited - tic_t trickboost; // Trick boost. This one is weird and has variable speed. Dear god. + UINT8 trickboostdecay; // used to know how long you've waited + UINT8 trickboost; // Trick boost. This one is weird and has variable speed. Dear god. UINT32 roundscore; // battle score this round diff --git a/src/k_kart.c b/src/k_kart.c index c714a68c2..915d3cd32 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8797,8 +8797,10 @@ void K_MoveKartPlayer(player_t *player, boolean onground) fixed_t speedmult = max(0, FRACUNIT - abs(momz)/TRICKMOMZRAMP); // TRICKMOMZRAMP momz is minimum speed (Should be 20) fixed_t basespeed = P_AproxDistance(player->mo->momx, player->mo->momy); // at WORSE, keep your normal speed when tricking. fixed_t speed = FixedMul(speedmult, P_AproxDistance(player->mo->momx, player->mo->momy)); - - player->tricktime++; + + // We'll never need to go above that. + if (player->tricktime <= TRICKDELAY) + player->tricktime++; // debug shit //CONS_Printf("%d\n", player->mo->momz / mapobjectscale); diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index a76eb1990..a9e193543 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -354,12 +354,20 @@ static int player_get(lua_State *L) lua_pushinteger(L, plr->glanceDir); else if (fastcmp(field,"trickpanel")) lua_pushinteger(L, plr->trickpanel); + else if (fastcmp(field,"tricktime")) + lua_pushinteger(L, plr->tricktime); else if (fastcmp(field,"trickmomx")) lua_pushfixed(L, plr->trickmomx); else if (fastcmp(field,"trickmomy")) lua_pushfixed(L, plr->trickmomy); else if (fastcmp(field,"trickmomz")) lua_pushfixed(L, plr->trickmomz); + else if (fastcmp(field,"trickboostpower")) + lua_pushfixed(L, plr->trickboostpower); + else if (fastcmp(field,"trickboostdecay")) + lua_pushinteger(L, plr->trickboostdecay); + else if (fastcmp(field,"trickboost")) + lua_pushinteger(L, plr->trickboost); else if (fastcmp(field,"roundscore")) plr->roundscore = luaL_checkinteger(L, 3); else if (fastcmp(field,"emeralds")) @@ -697,12 +705,20 @@ static int player_set(lua_State *L) plr->glanceDir = luaL_checkinteger(L, 3); else if (fastcmp(field,"trickpanel")) plr->trickpanel = luaL_checkinteger(L, 3); + else if (fastcmp(field,"tricktime")) + plr->tricktime = luaL_checkinteger(L, 3); else if (fastcmp(field,"trickmomx")) plr->trickmomx = luaL_checkfixed(L, 3); else if (fastcmp(field,"trickmomy")) plr->trickmomy = luaL_checkfixed(L, 3); else if (fastcmp(field,"trickmomz")) plr->trickmomz = luaL_checkfixed(L, 3); + else if (fastcmp(field,"trickboostpower")) + plr->trickboostpower = luaL_checkfixed(L, 3); + else if (fastcmp(field,"trickboostdecay")) + plr->trickboostdecay = luaL_checkinteger(L, 3); + else if (fastcmp(field,"trickboost")) + plr->trickboost = luaL_checkinteger(L, 3); else if (fastcmp(field,"roundscore")) lua_pushinteger(L, plr->roundscore); else if (fastcmp(field,"emeralds")) diff --git a/src/p_saveg.c b/src/p_saveg.c index 9f2d182fb..e8e992fcc 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -305,13 +305,13 @@ static void P_NetArchivePlayers(void) WRITEUINT8(save_p, players[i].jawztargetdelay); WRITEUINT8(save_p, players[i].trickpanel); - WRITEUINT32(save_p, players[i].tricktime); + WRITEUINT8(save_p, players[i].tricktime); WRITEUINT32(save_p, players[i].trickmomx); WRITEUINT32(save_p, players[i].trickmomy); WRITEUINT32(save_p, players[i].trickmomz); WRITEUINT32(save_p, players[i].trickboostpower); - WRITEUINT32(save_p, players[i].trickboostdecay); - WRITEUINT32(save_p, players[i].trickboost); + WRITEUINT8(save_p, players[i].trickboostdecay); + WRITEUINT8(save_p, players[i].trickboost); WRITEUINT32(save_p, players[i].roundscore); WRITEUINT8(save_p, players[i].emeralds); @@ -561,13 +561,13 @@ static void P_NetUnArchivePlayers(void) players[i].jawztargetdelay = READUINT8(save_p); players[i].trickpanel = READUINT8(save_p); - players[i].tricktime = (tic_t)READUINT32(save_p); + players[i].tricktime = READUINT8(save_p); players[i].trickmomx = READUINT32(save_p); players[i].trickmomy = READUINT32(save_p); players[i].trickmomz = READUINT32(save_p); players[i].trickboostpower = READUINT32(save_p); - players[i].trickboostdecay = (tic_t)READUINT32(save_p); - players[i].trickboost = (tic_t)READUINT32(save_p); + players[i].trickboostdecay = READUINT8(save_p); + players[i].trickboost = READUINT8(save_p); players[i].roundscore = READUINT32(save_p); players[i].emeralds = READUINT8(save_p); From f935b3b6f496f480253a4cb18940ebcbaa1c0093 Mon Sep 17 00:00:00 2001 From: Latapostrophe Date: Fri, 23 Apr 2021 02:10:20 +0200 Subject: [PATCH 05/11] wip: starting on visuals --- src/k_kart.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 79 insertions(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index 915d3cd32..593d46409 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8135,6 +8135,53 @@ void K_AdjustPlayerFriction(player_t *player) } } +// +// K_trickPanelTimingVisual +// Spawns the timing visual for trick panels depending on the given player's momz. +// + +#define RADIUSSCALING 6 +#define MINRADIUS 24 + +static void K_trickPanelTimingVisual(player_t *player, fixed_t momz) +{ + + fixed_t pos, tx, ty, tz; + mobj_t *flame; + + angle_t hang = R_PointToAngle(player->mo->x, player->mo->y) + ANG1*90; // horizontal angle + angle_t vang = -leveltime*ANG1*12; // vertical angle... arbitrary rotation speed for now. + fixed_t dist = FixedMul(max(MINRADIUS<mo->scale); // distance. + + UINT8 i; + + //CONS_Printf("a\n"); + + // Do you like trig? cool, me neither. + for (i=0; i < 2; i++) + { + //CONS_Printf("%d\n", i); + pos = FixedMul(dist, FINESINE(vang>>ANGLETOFINESHIFT)); + tx = player->mo->x + FixedMul(pos, FINECOSINE(hang>>ANGLETOFINESHIFT)); + ty = player->mo->y + FixedMul(pos, FINESINE(hang>>ANGLETOFINESHIFT)); + tz = player->mo->z + FixedMul(dist, FINECOSINE(vang>>ANGLETOFINESHIFT)); + + // All coordinates set, spawn our fire, now. + flame = P_SpawnMobj(tx, ty, tz, MT_THOK); // @TODO: Make this into its own object. Duh. + flame->frame = 0; + flame->tics = 2; + + // make sure this is only drawn for our local player + // @TODO + + vang += FixedAngle(180<mo->momx, player->mo->momy); // at WORSE, keep your normal speed when tricking. fixed_t speed = FixedMul(speedmult, P_AproxDistance(player->mo->momx, player->mo->momy)); - + + K_trickPanelTimingVisual(player, abs(momz)); + + // streaks: + if (momz*P_MobjFlip(player->mo) > 0) // only spawn those while you're going upwards relative to your current gravity + { + // these are all admittedly arbitrary numbers... + INT32 n; + INT32 maxlines = max(1, (momz/FRACUNIT)/8); + INT32 frequency = max(1, 5-(momz/FRACUNIT)/4); + fixed_t sx, sy, sz; + mobj_t *spdl; + + if (!(leveltime % frequency)) + { + for (n=0; n < maxlines; n++) + { + sx = player->mo->x + P_RandomRange(-24, 24)*player->mo->scale; + sy = player->mo->y + P_RandomRange(-24, 24)*player->mo->scale; + sz = player->mo->z + P_RandomRange(0, 48)*player->mo->scale; + + spdl = P_SpawnMobj(sx, sy, sz, MT_FASTLINE); + P_SetTarget(&spdl->target, player->mo); + spdl->angle = R_PointToAngle2(spdl->x, spdl->y, player->mo->x, player->mo->y); + spdl->rollangle = -ANG1*90*P_MobjFlip(player->mo); // angle them downwards relative to the player's gravity... + spdl->spriteyscale = player->trickboostpower+FRACUNIT; + } + + } + + } + // We'll never need to go above that. if (player->tricktime <= TRICKDELAY) player->tricktime++; From a27b825d3c078260d3f7826dcab53cc761519083 Mon Sep 17 00:00:00 2001 From: Latapostrophe Date: Fri, 23 Apr 2021 12:56:46 +0200 Subject: [PATCH 06/11] horiz. lines keep momentum, slightly better visuals --- src/k_kart.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 593d46409..3f1cdebb9 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8168,11 +8168,27 @@ static void K_trickPanelTimingVisual(player_t *player, fixed_t momz) // All coordinates set, spawn our fire, now. flame = P_SpawnMobj(tx, ty, tz, MT_THOK); // @TODO: Make this into its own object. Duh. - flame->frame = 0; + + // PLACEHOLDER VISUALS + // @TODO: SPRITES + flame->sprite = SPR_FLAM; + flame->frame = ((leveltime%16) /2)|FF_FULLBRIGHT; flame->tics = 2; + flame->rollangle = vang + ANG1*90; // make sure this is only drawn for our local player - // @TODO + flame->renderflags &= ~K_GetPlayerDontDrawFlag(player); + + // second flame for visuals... + flame = P_SpawnMobj(tx, ty, tz, MT_THOK); // @TODO: Make this into its own object. Duh. + + flame->sprite = SPR_FLAM; + flame->frame = ((leveltime%16) /2)|FF_FULLBRIGHT|FF_TRANS60; + flame->tics = 10; + flame->rollangle = vang + ANG1*90; + + // make sure this is only drawn for our local player + flame->renderflags &= ~K_GetPlayerDontDrawFlag(player); vang += FixedAngle(180<angle = R_PointToAngle2(spdl->x, spdl->y, player->mo->x, player->mo->y); spdl->rollangle = -ANG1*90*P_MobjFlip(player->mo); // angle them downwards relative to the player's gravity... spdl->spriteyscale = player->trickboostpower+FRACUNIT; + spdl->momx = player->mo->momx; + spdl->momy = player->mo->momy; } } From e632e1d70ee4491c2e3085026249c6a2522e0d84 Mon Sep 17 00:00:00 2001 From: Latapostrophe Date: Sat, 24 Apr 2021 01:26:39 +0200 Subject: [PATCH 07/11] Final (?) visuals for trick panel timing --- src/d_player.h | 3 ++ src/info.c | 2 ++ src/info.h | 2 ++ src/k_hud.c | 34 ++++++++++++++++++++ src/k_kart.c | 85 ++++++++++++++++++++++++++++++++++++-------------- 5 files changed, 102 insertions(+), 24 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index 445c1148d..8bd2f3fa8 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -232,6 +232,9 @@ typedef enum khud_cardanimation, // Used to determine the position of some full-screen Battle Mode graphics khud_yougotem, // "You Got Em" gfx when hitting someone as a karma player via a method that gets you back in the game instantly + // Tricks + khud_trickcool, + NUMKARTHUD } karthudtype_t; diff --git a/src/info.c b/src/info.c index eaa800ebc..ff982d6de 100644 --- a/src/info.c +++ b/src/info.c @@ -747,6 +747,8 @@ char sprnames[NUMSPRITES + 1][5] = "SDDS", // Spindash dust "SDWN", // Spindash wind + "TRCK", + "FLBM", // First person view sprites; this is a sprite so that it can be replaced by a specialized MD2 draw later diff --git a/src/info.h b/src/info.h index 697d206c6..f012df8a0 100644 --- a/src/info.h +++ b/src/info.h @@ -1289,6 +1289,8 @@ typedef enum sprite SPR_SDDS, // Spindash dust SPR_SDWN, // Spindash wind + SPR_TRCK, + SPR_FLBM, // Finish line beam // First person view sprites; this is a sprite so that it can be replaced by a specialized MD2 draw later diff --git a/src/k_hud.c b/src/k_hud.c index c2b29fe3d..e03172ae4 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -162,6 +162,8 @@ static patch_t *kp_cpu; static patch_t *kp_nametagstem; +static patch_t *kp_trickcool[2]; + void K_LoadKartHUDGraphics(void) { INT32 i, j; @@ -601,6 +603,9 @@ void K_LoadKartHUDGraphics(void) kp_cpu = (patch_t *) W_CachePatchName("K_CPU", PU_HUDGFX); kp_nametagstem = (patch_t *) W_CachePatchName("K_NAMEST", PU_HUDGFX); + + kp_trickcool[0] = W_CachePatchName("K_COOL1", PU_HUDGFX); + kp_trickcool[1] = W_CachePatchName("K_COOL2", PU_HUDGFX); } // For the item toggle menu @@ -3951,6 +3956,31 @@ static void K_drawLapStartAnim(void) } } +// stretch for "COOOOOL" popup. +// I can't be fucked to find out any math behind this so have a table lmao +static fixed_t stretch[6][2] = { + {FRACUNIT/4, FRACUNIT*4}, + {FRACUNIT/2, FRACUNIT*2}, + {FRACUNIT, FRACUNIT}, + {FRACUNIT*2, FRACUNIT/2}, + {FRACUNIT*4, FRACUNIT/4}, + {FRACUNIT*2, FRACUNIT/2}, +}; + +static void K_drawTrickCool(void) +{ + + tic_t timer = TICRATE - stplyr->karthud[khud_trickcool]; + if (timer <= 6) + { + V_DrawStretchyFixedPatch(160<karthud[khud_trickcool]) + K_drawTrickCool(); + if (modeattacking || freecam) // everything after here is MP and debug only return; diff --git a/src/k_kart.c b/src/k_kart.c index 3f1cdebb9..938f4a5d0 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -6099,6 +6099,9 @@ void K_KartPlayerHUDUpdate(player_t *player) if (player->karthud[khud_tauntvoices]) player->karthud[khud_tauntvoices]--; + if (player->karthud[khud_trickcool]) + player->karthud[khud_trickcool]--; + if (!(player->pflags & PF_FAULT)) player->karthud[khud_fault] = 0; else if (player->karthud[khud_fault] > 0 && player->karthud[khud_fault] < 2*TICRATE) @@ -8138,10 +8141,12 @@ void K_AdjustPlayerFriction(player_t *player) // // K_trickPanelTimingVisual // Spawns the timing visual for trick panels depending on the given player's momz. +// If the player has tricked and is not in hitlag, this will send the half circles flying out. +// if you tumble, they'll fall off instead. // #define RADIUSSCALING 6 -#define MINRADIUS 24 +#define MINRADIUS 12 static void K_trickPanelTimingVisual(player_t *player, fixed_t momz) { @@ -8150,8 +8155,8 @@ static void K_trickPanelTimingVisual(player_t *player, fixed_t momz) mobj_t *flame; angle_t hang = R_PointToAngle(player->mo->x, player->mo->y) + ANG1*90; // horizontal angle - angle_t vang = -leveltime*ANG1*12; // vertical angle... arbitrary rotation speed for now. - fixed_t dist = FixedMul(max(MINRADIUS<mo->scale); // distance. + angle_t vang = -FixedAngle(momz)*12 + (ANG1*45); // vertical angle... arbitrary rotation speed for now. + fixed_t dist = FixedMul(max(MINRADIUS<mo->scale); // distance. UINT8 i; @@ -8164,31 +8169,48 @@ static void K_trickPanelTimingVisual(player_t *player, fixed_t momz) pos = FixedMul(dist, FINESINE(vang>>ANGLETOFINESHIFT)); tx = player->mo->x + FixedMul(pos, FINECOSINE(hang>>ANGLETOFINESHIFT)); ty = player->mo->y + FixedMul(pos, FINESINE(hang>>ANGLETOFINESHIFT)); - tz = player->mo->z + FixedMul(dist, FINECOSINE(vang>>ANGLETOFINESHIFT)); + tz = player->mo->z + player->mo->height/2 + FixedMul(dist, FINECOSINE(vang>>ANGLETOFINESHIFT)); // All coordinates set, spawn our fire, now. - flame = P_SpawnMobj(tx, ty, tz, MT_THOK); // @TODO: Make this into its own object. Duh. + flame = P_SpawnMobj(tx, ty, tz, MT_THOK); - // PLACEHOLDER VISUALS - // @TODO: SPRITES - flame->sprite = SPR_FLAM; - flame->frame = ((leveltime%16) /2)|FF_FULLBRIGHT; - flame->tics = 2; - flame->rollangle = vang + ANG1*90; + P_SetScale(flame, player->mo->scale); + + // Visuals + flame->sprite = SPR_TRCK; + flame->frame = i|FF_FULLBRIGHT; + + if (player->trickpanel <= 1 && !player->tumbleBounces) + flame->tics = 2; + else + { + flame->tics = TICRATE; + + if (player->trickpanel > 1) // we tricked + { + // Send the thing outwards via ghetto maths + pos = FixedMul(48*player->mo->scale, FINESINE((vang +ANG1*90)>>ANGLETOFINESHIFT)); + tx = player->mo->x + FixedMul(pos, FINECOSINE(hang>>ANGLETOFINESHIFT)); + ty = player->mo->y + FixedMul(pos, FINESINE(hang>>ANGLETOFINESHIFT)); + tz = player->mo->z + player->mo->height/2 + FixedMul(48*player->mo->scale, FINECOSINE((vang +ANG1*90)>>ANGLETOFINESHIFT)); + + flame->momx = tx -player->mo->x; + flame->momy = ty -player->mo->y; + flame->momz = tz -(player->mo->z+player->mo->height/2); + } + else // we failed the trick. + { + flame->flags &= ~MF_NOGRAVITY; + P_SetObjectMomZ(flame, 4<mo->x, player->mo->y, flame->x, flame->y), 8*mapobjectscale); + flame->momx += player->mo->momx; + flame->momy += player->mo->momy; + flame->momz += player->mo->momz; + } + } // make sure this is only drawn for our local player - flame->renderflags &= ~K_GetPlayerDontDrawFlag(player); - - // second flame for visuals... - flame = P_SpawnMobj(tx, ty, tz, MT_THOK); // @TODO: Make this into its own object. Duh. - - flame->sprite = SPR_FLAM; - flame->frame = ((leveltime%16) /2)|FF_FULLBRIGHT|FF_TRANS60; - flame->tics = 10; - flame->rollangle = vang + ANG1*90; - - // make sure this is only drawn for our local player - flame->renderflags &= ~K_GetPlayerDontDrawFlag(player); + flame->renderflags |= (RF_DONTDRAW & ~K_GetPlayerDontDrawFlag(player)); vang += FixedAngle(180<mo->momx, player->mo->momy); // at WORSE, keep your normal speed when tricking. fixed_t speed = FixedMul(speedmult, P_AproxDistance(player->mo->momx, player->mo->momy)); - K_trickPanelTimingVisual(player, abs(momz)); + K_trickPanelTimingVisual(player, momz); // streaks: if (momz*P_MobjFlip(player->mo) > 0) // only spawn those while you're going upwards relative to your current gravity @@ -8907,11 +8929,22 @@ void K_MoveKartPlayer(player_t *player, boolean onground) player->pflags &= ~PF_TUMBLESOUND; player->tumbleHeight = 30; // Base tumble bounce height player->trickpanel = 0; + K_trickPanelTimingVisual(player, momz); // fail trick visual P_SetPlayerMobjState(player->mo, S_KART_SPINOUT); } else if (!(player->pflags & PF_TRICKDELAY)) // don't allow tricking at the same frame you tumble obv { + + // "COOL" timing n shit. + if (cmd->turning || player->throwdir) + { + if (abs(momz) < FRACUNIT*99) // Let's use that as baseline for PERFECT trick. + { + player->karthud[khud_trickcool] = TICRATE; + } + } + // Uses cmd->turning over steering intentionally. if (cmd->turning > 0) { @@ -8925,6 +8958,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) player->trickpanel = 2; player->mo->hitlag = TRICKLAG; + K_trickPanelTimingVisual(player, momz); } else if (cmd->turning < 0) { @@ -8938,6 +8972,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) player->trickpanel = 3; player->mo->hitlag = TRICKLAG; + K_trickPanelTimingVisual(player, momz); } else if (player->throwdir == 1) { @@ -8956,6 +8991,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) player->trickpanel = 2; player->mo->hitlag = TRICKLAG; + K_trickPanelTimingVisual(player, momz); } else if (player->throwdir == -1) { @@ -8985,6 +9021,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) player->trickpanel = 4; player->mo->hitlag = TRICKLAG; + K_trickPanelTimingVisual(player, momz); } } } From e980be69ef40d6c42b0e9947ce0556bbf08f4b75 Mon Sep 17 00:00:00 2001 From: Latapostrophe Date: Sat, 24 Apr 2021 01:56:34 +0200 Subject: [PATCH 08/11] wip splitscreen garbage. DOES NOT WORK. --- src/k_hud.c | 22 ++++++++++++++++++++-- src/k_kart.c | 2 ++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/k_hud.c b/src/k_hud.c index e03172ae4..18809ae6f 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -3971,13 +3971,31 @@ static void K_drawTrickCool(void) { tic_t timer = TICRATE - stplyr->karthud[khud_trickcool]; + INT32 x = (BASEVIDWIDTH/2); + INT32 y = ((BASEVIDHEIGHT)/2)-10; + + // @TODO: fix this shit + /*if (r_splitscreen > 2) // 4p split + { + if (stplyr == &players[displayplayers[0]] || stplyr == &players[displayplayers[2]]) + { + x /= 2; + y /= 2; + } + else + { + x /= 2 + BASEVIDWIDTH/2; + y /= 2 + BASEVIDHEIGHT/2; + } + }*/ + if (timer <= 6) { - V_DrawStretchyFixedPatch(160< Date: Sat, 24 Apr 2021 14:46:39 +0200 Subject: [PATCH 09/11] Fix effects in splitscreen --- src/k_hud.c | 36 ++++++++++++++---------------------- src/k_kart.c | 16 ++++++---------- src/r_main.c | 35 +++++++++++++++++++++++++++++++++++ src/r_main.h | 1 + 4 files changed, 56 insertions(+), 32 deletions(-) diff --git a/src/k_hud.c b/src/k_hud.c index 18809ae6f..d023653a2 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -684,6 +684,9 @@ INT32 ITEM2_X, ITEM2_Y; INT32 LAPS2_X, LAPS2_Y; INT32 POSI2_X, POSI2_Y; +// trick "cool" +INT32 TCOOL_X, TCOOL_Y; + void K_AdjustXYWithSnap(INT32 *x, INT32 *y, UINT32 options, INT32 dupx, INT32 dupy) { @@ -987,6 +990,10 @@ static void K_initKartHUD(void) WANT_X = BASEVIDWIDTH - 55; // 270 WANT_Y = BASEVIDHEIGHT- 71; // 176 + // trick COOL + TCOOL_X = (BASEVIDWIDTH)/2; + TCOOL_Y = (BASEVIDHEIGHT)/2 -10; + if (r_splitscreen) // Splitscreen { ITEM_X = 5; @@ -1029,6 +1036,8 @@ static void K_initKartHUD(void) MINI_X = (3*BASEVIDWIDTH/4); MINI_Y = (3*BASEVIDHEIGHT/4); + TCOOL_X = (BASEVIDWIDTH)/4; + if (r_splitscreen > 2) // 4P-only { MINI_X = (BASEVIDWIDTH/2); @@ -3962,40 +3971,23 @@ static fixed_t stretch[6][2] = { {FRACUNIT/4, FRACUNIT*4}, {FRACUNIT/2, FRACUNIT*2}, {FRACUNIT, FRACUNIT}, - {FRACUNIT*2, FRACUNIT/2}, - {FRACUNIT*4, FRACUNIT/4}, - {FRACUNIT*2, FRACUNIT/2}, + {FRACUNIT*4, FRACUNIT/2}, + {FRACUNIT*8, FRACUNIT/4}, + {FRACUNIT*4, FRACUNIT/2}, }; static void K_drawTrickCool(void) { tic_t timer = TICRATE - stplyr->karthud[khud_trickcool]; - INT32 x = (BASEVIDWIDTH/2); - INT32 y = ((BASEVIDHEIGHT)/2)-10; - - // @TODO: fix this shit - /*if (r_splitscreen > 2) // 4p split - { - if (stplyr == &players[displayplayers[0]] || stplyr == &players[displayplayers[2]]) - { - x /= 2; - y /= 2; - } - else - { - x /= 2 + BASEVIDWIDTH/2; - y /= 2 + BASEVIDHEIGHT/2; - } - }*/ if (timer <= 6) { - V_DrawStretchyFixedPatch(x<mo->x, player->mo->y) + ANG1*90; // horizontal angle - angle_t vang = -FixedAngle(momz)*12 + (ANG1*45); // vertical angle... arbitrary rotation speed for now. - fixed_t dist = FixedMul(max(MINRADIUS<mo->scale); // distance. + angle_t hang = R_PointToAnglePlayer(player, player->mo->x, player->mo->y) + ANG1*90; // horizontal angle + angle_t vang = -FixedAngle(momz)*12 + (ANG1*45); // vertical angle dependant on momz, we want it to line up at 45 degrees at the perfect frame to trick at + fixed_t dist = FixedMul(max(MINRADIUS<mo->scale); // distance. UINT8 i; - //CONS_Printf("a\n"); - // Do you like trig? cool, me neither. for (i=0; i < 2; i++) { - //CONS_Printf("%d\n", i); pos = FixedMul(dist, FINESINE(vang>>ANGLETOFINESHIFT)); tx = player->mo->x + FixedMul(pos, FINECOSINE(hang>>ANGLETOFINESHIFT)); ty = player->mo->y + FixedMul(pos, FINESINE(hang>>ANGLETOFINESHIFT)); @@ -8190,7 +8185,8 @@ static void K_trickPanelTimingVisual(player_t *player, fixed_t momz) if (player->trickpanel > 1) // we tricked { - // Send the thing outwards via ghetto maths + // Send the thing outwards via ghetto maths which involves redoing the whole 3d sphere again, witht the "vertical" angle shifted by 90 degrees. + // There's probably a simplier way to do this the way I want to but this works. pos = FixedMul(48*player->mo->scale, FINESINE((vang +ANG1*90)>>ANGLETOFINESHIFT)); tx = player->mo->x + FixedMul(pos, FINECOSINE(hang>>ANGLETOFINESHIFT)); ty = player->mo->y + FixedMul(pos, FINESINE(hang>>ANGLETOFINESHIFT)); @@ -8200,7 +8196,7 @@ static void K_trickPanelTimingVisual(player_t *player, fixed_t momz) flame->momy = ty -player->mo->y; flame->momz = tz -(player->mo->z+player->mo->height/2); } - else // we failed the trick. + else // we failed the trick, drop the half circles, it'll be funny I promise. { flame->flags &= ~MF_NOGRAVITY; P_SetObjectMomZ(flame, 4<x; + refy = cam->y; + + // Now do whatever tehe fuck is this hellish maths from R_PointToAngle while swapping viewx/viewy for our refx/refy + return (y -= refy, (x -= refx) || y) ? + x >= 0 ? + y >= 0 ? + (x > y) ? tantoangle[SlopeDiv(y,x)] : // octant 0 + ANGLE_90-tantoangle[SlopeDiv(x,y)] : // octant 1 + x > (y = -y) ? 0-tantoangle[SlopeDiv(y,x)] : // octant 8 + ANGLE_270+tantoangle[SlopeDiv(x,y)] : // octant 7 + y >= 0 ? (x = -x) > y ? ANGLE_180-tantoangle[SlopeDiv(y,x)] : // octant 3 + ANGLE_90 + tantoangle[SlopeDiv(x,y)] : // octant 2 + (x = -x) > (y = -y) ? ANGLE_180+tantoangle[SlopeDiv(y,x)] : // octant 4 + ANGLE_270-tantoangle[SlopeDiv(x,y)] : // octant 5 + 0; +} + // This version uses 64-bit variables to avoid overflows with large values. // Currently used only by OpenGL rendering. angle_t R_PointToAngle64(INT64 x, INT64 y) diff --git a/src/r_main.h b/src/r_main.h index 49e028149..5208b52a3 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -63,6 +63,7 @@ extern lighttable_t *zlight[LIGHTLEVELS][MAXLIGHTZ]; INT32 R_PointOnSide(fixed_t x, fixed_t y, node_t *node); INT32 R_PointOnSegSide(fixed_t x, fixed_t y, seg_t *line); angle_t R_PointToAngle(fixed_t x, fixed_t y); +angle_t R_PointToAnglePlayer(player_t *player, fixed_t x, fixed_t y); angle_t R_PointToAngle64(INT64 x, INT64 y); angle_t R_PointToAngle2(fixed_t px2, fixed_t py2, fixed_t px1, fixed_t py1); angle_t R_PointToAngleEx(INT32 x2, INT32 y2, INT32 x1, INT32 y1); From 47a95efa6b6d1ea0e65abc7a07875b08f6e1324e Mon Sep 17 00:00:00 2001 From: Latapostrophe Date: Sat, 24 Apr 2021 14:49:41 +0200 Subject: [PATCH 10/11] push R_PointToAnlePlayer to Lua, might be super useful for it. --- src/lua_baselib.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index abf0224d2..9e1c909f5 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -2098,6 +2098,16 @@ static int lib_rPointToAngle(lua_State *L) return 1; } +static int lib_rPointToAnglePlayer(lua_State *L) +{ + player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + fixed_t x = luaL_checkfixed(L, 2); + fixed_t y = luaL_checkfixed(L, 3); + //HUDSAFE + lua_pushangle(L, R_PointToAnglePlayer(player, x, y)); + return 1; +} + static int lib_rPointToAngle2(lua_State *L) { fixed_t px2 = luaL_checkfixed(L, 1); @@ -3876,6 +3886,7 @@ static luaL_Reg lib[] = { // r_defs {"R_PointToAngle",lib_rPointToAngle}, + {"R_PointToAnglePlayer", lib_rPointToAnglePlayer}, {"R_PointToAngle2",lib_rPointToAngle2}, {"R_PointToDist",lib_rPointToDist}, {"R_PointToDist2",lib_rPointToDist2}, From 82fa8755027ff3a6485740909b207ecb5c2fe5c7 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sat, 12 Jun 2021 00:56:55 -0400 Subject: [PATCH 11/11] Refactor R_PointToAnglePlayer --- src/r_main.c | 58 ++++++++++++++++++---------------------------------- 1 file changed, 20 insertions(+), 38 deletions(-) diff --git a/src/r_main.c b/src/r_main.c index 97d946876..dfc11ab4a 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -318,18 +318,7 @@ INT32 R_PointOnSegSide(fixed_t x, fixed_t y, seg_t *line) angle_t R_PointToAngle(fixed_t x, fixed_t y) { - return (y -= viewy, (x -= viewx) || y) ? - x >= 0 ? - y >= 0 ? - (x > y) ? tantoangle[SlopeDiv(y,x)] : // octant 0 - ANGLE_90-tantoangle[SlopeDiv(x,y)] : // octant 1 - x > (y = -y) ? 0-tantoangle[SlopeDiv(y,x)] : // octant 8 - ANGLE_270+tantoangle[SlopeDiv(x,y)] : // octant 7 - y >= 0 ? (x = -x) > y ? ANGLE_180-tantoangle[SlopeDiv(y,x)] : // octant 3 - ANGLE_90 + tantoangle[SlopeDiv(x,y)] : // octant 2 - (x = -x) > (y = -y) ? ANGLE_180+tantoangle[SlopeDiv(y,x)] : // octant 4 - ANGLE_270-tantoangle[SlopeDiv(x,y)] : // octant 5 - 0; + return R_PointToAngle2(viewx, viewy, x, y); } // Similar to R_PointToAngle, but requires an additional player_t argument. @@ -338,33 +327,26 @@ angle_t R_PointToAngle(fixed_t x, fixed_t y) angle_t R_PointToAnglePlayer(player_t *player, fixed_t x, fixed_t y) { fixed_t refx = viewx, refy = viewy; - camera_t *cam = &camera[0]; - - // Check for splitscreen players and get their cam if possible. - if (player == &players[displayplayers[1]]) - cam = &camera[1]; - else if (player == &players[displayplayers[2]]) - cam = &camera[2]; - else if (player == &players[displayplayers[3]]) - cam = &camera[3]; - + camera_t *cam = NULL; + UINT8 i; + + for (i = 0; i < r_splitscreen; i++) + { + if (player == &players[displayplayers[i]]) + { + cam = &camera[i]; + break; + } + } + // use whatever cam we found's coordinates. - refx = cam->x; - refy = cam->y; - - // Now do whatever tehe fuck is this hellish maths from R_PointToAngle while swapping viewx/viewy for our refx/refy - return (y -= refy, (x -= refx) || y) ? - x >= 0 ? - y >= 0 ? - (x > y) ? tantoangle[SlopeDiv(y,x)] : // octant 0 - ANGLE_90-tantoangle[SlopeDiv(x,y)] : // octant 1 - x > (y = -y) ? 0-tantoangle[SlopeDiv(y,x)] : // octant 8 - ANGLE_270+tantoangle[SlopeDiv(x,y)] : // octant 7 - y >= 0 ? (x = -x) > y ? ANGLE_180-tantoangle[SlopeDiv(y,x)] : // octant 3 - ANGLE_90 + tantoangle[SlopeDiv(x,y)] : // octant 2 - (x = -x) > (y = -y) ? ANGLE_180+tantoangle[SlopeDiv(y,x)] : // octant 4 - ANGLE_270-tantoangle[SlopeDiv(x,y)] : // octant 5 - 0; + if (cam != NULL) + { + refx = cam->x; + refy = cam->y; + } + + return R_PointToAngle2(refx, refy, x, y); } // This version uses 64-bit variables to avoid overflows with large values.