From ebd2bdd1c82eaef65526de767dc9a40401f63393 Mon Sep 17 00:00:00 2001 From: wolfy852 Date: Fri, 1 Jan 2016 14:53:29 -0600 Subject: [PATCH 01/10] Add CA_DASHMODE to the game This works fine in single player on vanilla builds, multiplayer is untested. This might not be the best way to handle the ability, so modifications for efficiency/sanity might be necessary. --- src/d_player.h | 3 ++- src/dehacked.c | 1 + src/p_user.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 1 deletion(-) diff --git a/src/d_player.h b/src/d_player.h index e2a1081b0..08c98b7a3 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -57,7 +57,8 @@ typedef enum CA_FALLSWITCH, CA_JUMPBOOST, CA_AIRDRILL, - CA_JUMPTHOK + CA_JUMPTHOK, + CA_DASHMODE } charability_t; //Secondary skin abilities diff --git a/src/dehacked.c b/src/dehacked.c index 0ba054f07..3fd05ffe6 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -7623,6 +7623,7 @@ struct { {"CA_JUMPBOOST",CA_JUMPBOOST}, {"CA_AIRDRILL",CA_AIRDRILL}, {"CA_JUMPTHOK",CA_JUMPTHOK}, + {"CA_DASHMODE",CA_DASHMODE}, // Secondary {"CA2_NONE",CA2_NONE}, // now slot 0! {"CA2_SPINDASH",CA2_SPINDASH}, diff --git a/src/p_user.c b/src/p_user.c index 8854d8d64..4b307feca 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4072,6 +4072,7 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) case CA_THOK: case CA_HOMINGTHOK: case CA_JUMPTHOK: // Credit goes to CZ64 and Sryder13 for the original + case CA_DASHMODE: // Credit goes to Iceman404 // Now it's Sonic's abilities turn! // THOK! if (!(player->pflags & PF_THOKKED) || (player->charability2 == CA2_MULTIABILITY)) @@ -8664,6 +8665,8 @@ void P_DoPityCheck(player_t *player) // boolean playerdeadview; // show match/chaos/tag/capture the flag rankings while in death view +INT32 dashmode = 0; // initial variable set for CA_DASHMODE +boolean dashmodeflag = false; void P_PlayerThink(player_t *player) { @@ -9148,6 +9151,63 @@ void P_PlayerThink(player_t *player) player->pflags &= ~PF_SLIDING; + // Dash mode ability for Metal Sonic + if ((player->charability == CA_DASHMODE) && !(maptol & TOL_NIGHTS)) // woo, dashmode! no nights tho. + { + fixed_t defspeed = skins[player->skin].normalspeed; // Default normalspeed. + fixed_t maxtop = skins[player->skin].normalspeed * 55/36; + + if (!(player->speed > player->normalspeed)) //are we currently exceeding our normalspeed? + player->actionspd = player->normalspeed; //if not, force thok to normalspeed + else + player->actionspd = player->speed; //otherwise, thok at your current speed (this fixes super and speedshoes thok slowing you down) + + if (player->speed >= (defspeed - 5*FRACUNIT) || (player->pflags & PF_STARTDASH)) + { + dashmode++; // Counter. Adds 1 to dash mode per tic in top speed. + if (dashmode == 3*TICRATE) // This isn't in the ">=" equation because it'd cause the sound to play infinitely. + S_StartSound(player->mo, sfx_s3ka2); // If the player enters dashmode, play this sound on the the tic it starts. + } + else if (!(player->pflags & PF_SPINNING)) + { + if (dashmode > 0) + dashmode = dashmode - 3; // Rather than lose it all, it gently counts back down! + else if (dashmode < 0) + dashmode = 0; + } + + if (dashmode >= 3*TICRATE && P_IsObjectOnGround(player->mo)) // Dash Mode can continue counting in the air, but will only activate on floor touch. + dashmodeflag = true; + + if (dashmode < 3*TICRATE) // Exits Dash Mode if you drop below speed/dash counter tics. Not in the above block so it doesn't keep disabling in midair. + { + player->normalspeed = defspeed; // Reset to default if not capable of entering dash mode. + player->jumpfactor = 1*FRACUNIT; + dashmodeflag = false; + } + + //WHEN PARAMETERS ARE MET, REWARD THE DASH MODE EFFECTS + if (dashmodeflag) + { + if (player->normalspeed < maxtop) // If the player is not currently at 50 normalspeed in dash mode, add speed each tic + { + player->normalspeed = player->normalspeed + 1*FRACUNIT/5; // Enter Dash Mode smoothly. + if (player->jumpfactor < 5*FRACUNIT/4) + player->jumpfactor = player->jumpfactor + 1*FRACUNIT/300; // Boosts his jumpheight. Remember fractions instead of decimals. "1.5*FRACUNIT = 3*FRACUNIT/2" + } + } + + //COSMETIC STUPIDITY! + if (dashmode > 108) //Dash Mode will go down a tic a bit above activation, this makes dust spawn every other tic. + dashmode = 107; + + if (player->normalspeed >= maxtop) + { + mobj_t *ghost = P_SpawnGhostMobj(player->mo); // Spawns afterimages + ghost->fuse = 2; // Makes the images fade quickly + } + } + /* // Colormap verification { From a15a4ace7e8bac122a90ddc6645f76f76de1ff87 Mon Sep 17 00:00:00 2001 From: RedEnchilada Date: Sat, 2 Jan 2016 22:34:55 -0600 Subject: [PATCH 02/10] Do dashmode thok speed adjustments at thok instead of modifying actionspd --- src/p_user.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/p_user.c b/src/p_user.c index 4b307feca..034bab498 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4079,13 +4079,19 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) { // Catapult the player fixed_t actionspd = player->actionspd; + + if (player->charability == CA_DASHMODE) + actionspd = max(player->normalspeed, FixedDiv(player->speed, player->mo->scale)); + if (player->mo->eflags & MFE_UNDERWATER) actionspd >>= 1; + if ((player->charability == CA_JUMPTHOK) && !(player->pflags & PF_THOKKED)) { player->pflags &= ~PF_JUMPED; P_DoJump(player, false); } + P_InstaThrust(player->mo, player->mo->angle, FixedMul(actionspd, player->mo->scale)); if (maptol & TOL_2D) From ba8c0dfc6e55e1116aa93b3ce4b030711340d114 Mon Sep 17 00:00:00 2001 From: RedEnchilada Date: Sat, 2 Jan 2016 22:58:35 -0600 Subject: [PATCH 03/10] Clean up dash mode and make multiplayer-compatible Actionspd is now the running speed in dashmode. --- src/p_user.c | 45 ++++++++++++++------------------------------- 1 file changed, 14 insertions(+), 31 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 034bab498..802e7f9c3 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -8671,8 +8671,6 @@ void P_DoPityCheck(player_t *player) // boolean playerdeadview; // show match/chaos/tag/capture the flag rankings while in death view -INT32 dashmode = 0; // initial variable set for CA_DASHMODE -boolean dashmodeflag = false; void P_PlayerThink(player_t *player) { @@ -9160,15 +9158,10 @@ void P_PlayerThink(player_t *player) // Dash mode ability for Metal Sonic if ((player->charability == CA_DASHMODE) && !(maptol & TOL_NIGHTS)) // woo, dashmode! no nights tho. { - fixed_t defspeed = skins[player->skin].normalspeed; // Default normalspeed. +#define dashmode player->glidetime fixed_t maxtop = skins[player->skin].normalspeed * 55/36; - if (!(player->speed > player->normalspeed)) //are we currently exceeding our normalspeed? - player->actionspd = player->normalspeed; //if not, force thok to normalspeed - else - player->actionspd = player->speed; //otherwise, thok at your current speed (this fixes super and speedshoes thok slowing you down) - - if (player->speed >= (defspeed - 5*FRACUNIT) || (player->pflags & PF_STARTDASH)) + if (player->speed >= FixedMul(skins[player->skin].normalspeed - 5*FRACUNIT, player->mo->scale) || (player->pflags & PF_STARTDASH)) { dashmode++; // Counter. Adds 1 to dash mode per tic in top speed. if (dashmode == 3*TICRATE) // This isn't in the ">=" equation because it'd cause the sound to play infinitely. @@ -9176,42 +9169,32 @@ void P_PlayerThink(player_t *player) } else if (!(player->pflags & PF_SPINNING)) { - if (dashmode > 0) + if (dashmode > 3) dashmode = dashmode - 3; // Rather than lose it all, it gently counts back down! - else if (dashmode < 0) + else dashmode = 0; } - - if (dashmode >= 3*TICRATE && P_IsObjectOnGround(player->mo)) // Dash Mode can continue counting in the air, but will only activate on floor touch. - dashmodeflag = true; if (dashmode < 3*TICRATE) // Exits Dash Mode if you drop below speed/dash counter tics. Not in the above block so it doesn't keep disabling in midair. { - player->normalspeed = defspeed; // Reset to default if not capable of entering dash mode. - player->jumpfactor = 1*FRACUNIT; - dashmodeflag = false; + player->normalspeed = skins[player->skin].normalspeed; // Reset to default if not capable of entering dash mode. + player->jumpfactor = skins[player->skin].jumpfactor; } - - //WHEN PARAMETERS ARE MET, REWARD THE DASH MODE EFFECTS - if (dashmodeflag) + else if (P_IsObjectOnGround(player->mo)) // Activate dash mode if we're on the ground. { - if (player->normalspeed < maxtop) // If the player is not currently at 50 normalspeed in dash mode, add speed each tic - { + if (player->normalspeed < skins[player->skin].actionspd) // If the player normalspeed is not currently at actionspd in dash mode, add speed each tic player->normalspeed = player->normalspeed + 1*FRACUNIT/5; // Enter Dash Mode smoothly. - if (player->jumpfactor < 5*FRACUNIT/4) - player->jumpfactor = player->jumpfactor + 1*FRACUNIT/300; // Boosts his jumpheight. Remember fractions instead of decimals. "1.5*FRACUNIT = 3*FRACUNIT/2" - } + + if (player->jumpfactor < FixedMul(skins[player->skin].jumpfactor, 5*FRACUNIT/4)) // Boost jump height. + player->jumpfactor = player->jumpfactor + 1*FRACUNIT/300; } - - //COSMETIC STUPIDITY! - if (dashmode > 108) //Dash Mode will go down a tic a bit above activation, this makes dust spawn every other tic. - dashmode = 107; - - if (player->normalspeed >= maxtop) + + if (player->normalspeed >= skins[player->skin].actionspd) { mobj_t *ghost = P_SpawnGhostMobj(player->mo); // Spawns afterimages ghost->fuse = 2; // Makes the images fade quickly } +#undef dashmode } /* From c38af2c6a2751336da1512d9e3a15ec1e75c565e Mon Sep 17 00:00:00 2001 From: RedEnchilada Date: Sat, 2 Jan 2016 23:26:22 -0600 Subject: [PATCH 04/10] Remove unused maxtop variable --- src/p_user.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 802e7f9c3..3b0d48628 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -9159,8 +9159,6 @@ void P_PlayerThink(player_t *player) if ((player->charability == CA_DASHMODE) && !(maptol & TOL_NIGHTS)) // woo, dashmode! no nights tho. { #define dashmode player->glidetime - fixed_t maxtop = skins[player->skin].normalspeed * 55/36; - if (player->speed >= FixedMul(skins[player->skin].normalspeed - 5*FRACUNIT, player->mo->scale) || (player->pflags & PF_STARTDASH)) { dashmode++; // Counter. Adds 1 to dash mode per tic in top speed. From 95d6cba18405b5ce7f9224e1849b3f0751bc6f02 Mon Sep 17 00:00:00 2001 From: wolfy852 Date: Mon, 25 Jan 2016 01:49:37 -0600 Subject: [PATCH 05/10] [HACK] Make dashmode work again Fixed one of Red's mistakes, and used a different struct variable for dashmode. This needs to be changed though, because everything will break if someone loads a circuit map. --- src/p_user.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 3b0d48628..91bbfc6f2 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -9158,7 +9158,7 @@ void P_PlayerThink(player_t *player) // Dash mode ability for Metal Sonic if ((player->charability == CA_DASHMODE) && !(maptol & TOL_NIGHTS)) // woo, dashmode! no nights tho. { -#define dashmode player->glidetime +#define dashmode player->laps if (player->speed >= FixedMul(skins[player->skin].normalspeed - 5*FRACUNIT, player->mo->scale) || (player->pflags & PF_STARTDASH)) { dashmode++; // Counter. Adds 1 to dash mode per tic in top speed. @@ -9168,10 +9168,13 @@ void P_PlayerThink(player_t *player) else if (!(player->pflags & PF_SPINNING)) { if (dashmode > 3) - dashmode = dashmode - 3; // Rather than lose it all, it gently counts back down! + dashmode -= 3; // Rather than lose it all, it gently counts back down! else dashmode = 0; } + + if (dashmode > 254) + dashmode = 3*TICRATE+1; if (dashmode < 3*TICRATE) // Exits Dash Mode if you drop below speed/dash counter tics. Not in the above block so it doesn't keep disabling in midair. { From 67b92d727344ab66bb5e070a9d45e8e647942c87 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 25 Jan 2016 11:47:33 +0000 Subject: [PATCH 06/10] Went and fixed the dashmode variable hack nonsense once and for all myself would have gone for "dashtime", but then I was reminded that was already a name for something to do with spindash. Oh well --- src/d_clisrv.c | 2 ++ src/d_clisrv.h | 1 + src/d_player.h | 1 + src/lua_playerlib.c | 4 ++++ src/p_saveg.c | 2 ++ src/p_user.c | 11 ++++++----- 6 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 31738e9b2..ee2d18961 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -531,6 +531,7 @@ static inline void resynch_write_player(resynch_pak *rsp, const size_t i) rsp->deadtimer = players[i].deadtimer; rsp->exiting = (tic_t)LONG(players[i].exiting); rsp->homing = players[i].homing; + rsp->dashmode = (tic_t)LONG(players[i].dashmode); rsp->cmomx = (fixed_t)LONG(players[i].cmomx); rsp->cmomy = (fixed_t)LONG(players[i].cmomy); rsp->rmomx = (fixed_t)LONG(players[i].rmomx); @@ -656,6 +657,7 @@ static void resynch_read_player(resynch_pak *rsp) players[i].deadtimer = rsp->deadtimer; players[i].exiting = (tic_t)LONG(rsp->exiting); players[i].homing = rsp->homing; + players[i].dashmode = (tic_t)LONG(rsp->dashmode); players[i].cmomx = (fixed_t)LONG(rsp->cmomx); players[i].cmomy = (fixed_t)LONG(rsp->cmomy); players[i].rmomx = (fixed_t)LONG(rsp->rmomx); diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 6bc06f13a..2bcfad176 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -191,6 +191,7 @@ typedef struct INT32 deadtimer; tic_t exiting; UINT8 homing; + tic_t dashmode; fixed_t cmomx; fixed_t cmomy; fixed_t rmomx; diff --git a/src/d_player.h b/src/d_player.h index 08c98b7a3..a3acb8728 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -352,6 +352,7 @@ typedef struct player_s tic_t exiting; // Exitlevel timer UINT8 homing; // Are you homing? + tic_t dashmode; // counter for dashmode ability tic_t skidtime; // Skid timer diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index 64513ab97..b03833354 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -202,6 +202,8 @@ static int player_get(lua_State *L) lua_pushinteger(L, plr->exiting); else if (fastcmp(field,"homing")) lua_pushinteger(L, plr->homing); + else if (fastcmp(field,"dashmode")) + lua_pushinteger(L, plr->dashmode); else if (fastcmp(field,"skidtime")) lua_pushinteger(L, plr->skidtime); else if (fastcmp(field,"cmomx")) @@ -452,6 +454,8 @@ static int player_set(lua_State *L) plr->exiting = (tic_t)luaL_checkinteger(L, 3); else if (fastcmp(field,"homing")) plr->homing = (UINT8)luaL_checkinteger(L, 3); + else if (fastcmp(field,"dashmode")) + plr->dashmode = (tic_t)luaL_checkinteger(L, 3); else if (fastcmp(field,"skidtime")) plr->skidtime = (tic_t)luaL_checkinteger(L, 3); else if (fastcmp(field,"cmomx")) diff --git a/src/p_saveg.c b/src/p_saveg.c index 07e7b3564..a574afb55 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -162,6 +162,7 @@ static inline void P_NetArchivePlayers(void) WRITEINT32(save_p, players[i].deadtimer); WRITEUINT32(save_p, players[i].exiting); WRITEUINT8(save_p, players[i].homing); + WRITEUINT32(save_p, players[i].dashmode); WRITEUINT32(save_p, players[i].skidtime); //////////////////////////// @@ -337,6 +338,7 @@ static inline void P_NetUnArchivePlayers(void) players[i].deadtimer = READINT32(save_p); // End game if game over lasts too long players[i].exiting = READUINT32(save_p); // Exitlevel timer players[i].homing = READUINT8(save_p); // Are you homing? + players[i].dashmode = READUINT32(save_p); // counter for dashmode ability players[i].skidtime = READUINT32(save_p); // Skid timer //////////////////////////// diff --git a/src/p_user.c b/src/p_user.c index 91bbfc6f2..8a6d8b871 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -9155,10 +9155,10 @@ void P_PlayerThink(player_t *player) player->pflags &= ~PF_SLIDING; +#define dashmode player->dashmode // Dash mode ability for Metal Sonic if ((player->charability == CA_DASHMODE) && !(maptol & TOL_NIGHTS)) // woo, dashmode! no nights tho. { -#define dashmode player->laps if (player->speed >= FixedMul(skins[player->skin].normalspeed - 5*FRACUNIT, player->mo->scale) || (player->pflags & PF_STARTDASH)) { dashmode++; // Counter. Adds 1 to dash mode per tic in top speed. @@ -9172,10 +9172,10 @@ void P_PlayerThink(player_t *player) else dashmode = 0; } - + if (dashmode > 254) dashmode = 3*TICRATE+1; - + if (dashmode < 3*TICRATE) // Exits Dash Mode if you drop below speed/dash counter tics. Not in the above block so it doesn't keep disabling in midair. { player->normalspeed = skins[player->skin].normalspeed; // Reset to default if not capable of entering dash mode. @@ -9195,9 +9195,10 @@ void P_PlayerThink(player_t *player) mobj_t *ghost = P_SpawnGhostMobj(player->mo); // Spawns afterimages ghost->fuse = 2; // Makes the images fade quickly } -#undef dashmode } - + else + dashmode = 0; +#undef dashmode /* // Colormap verification { From e314b442b2762d79df4f07d5a6da0ae0d6c6c57c Mon Sep 17 00:00:00 2001 From: wolfy852 Date: Mon, 25 Jan 2016 20:26:31 -0600 Subject: [PATCH 07/10] Remove dashmode limit since tic_t is UINT32 This might be overpowered as hell. Needs testing for sure. --- src/p_user.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 8a6d8b871..3c86c3621 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -9173,9 +9173,6 @@ void P_PlayerThink(player_t *player) dashmode = 0; } - if (dashmode > 254) - dashmode = 3*TICRATE+1; - if (dashmode < 3*TICRATE) // Exits Dash Mode if you drop below speed/dash counter tics. Not in the above block so it doesn't keep disabling in midair. { player->normalspeed = skins[player->skin].normalspeed; // Reset to default if not capable of entering dash mode. From c5ca1a8f24e21c6cc13e5d145f55a2cd6f717bd8 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Thu, 7 Jul 2016 01:40:28 +0100 Subject: [PATCH 08/10] The dashmode struct variable now has a cap, per a Wolfs request. --- src/p_user.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 48f678601..6b57bb7a9 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -9171,40 +9171,42 @@ void P_PlayerThink(player_t *player) #define dashmode player->dashmode // Dash mode ability for Metal Sonic - if ((player->charability == CA_DASHMODE) && !(maptol & TOL_NIGHTS)) // woo, dashmode! no nights tho. + if ((player->charability == CA_DASHMODE) && !(maptol & TOL_NIGHTS)) // woo, dashmode! no nights tho. { if (player->speed >= FixedMul(skins[player->skin].normalspeed - 5*FRACUNIT, player->mo->scale) || (player->pflags & PF_STARTDASH)) { - dashmode++; // Counter. Adds 1 to dash mode per tic in top speed. - if (dashmode == 3*TICRATE) // This isn't in the ">=" equation because it'd cause the sound to play infinitely. - S_StartSound(player->mo, sfx_s3ka2); // If the player enters dashmode, play this sound on the the tic it starts. + dashmode++; // Counter. Adds 1 to dash mode per tic in top speed. + if (dashmode == 3*TICRATE) // This isn't in the ">=" equation because it'd cause the sound to play infinitely. + S_StartSound(player->mo, sfx_s3ka2); // If the player enters dashmode, play this sound on the the tic it starts. } else if (!(player->pflags & PF_SPINNING)) { if (dashmode > 3) - dashmode -= 3; // Rather than lose it all, it gently counts back down! + dashmode -= 3; // Rather than lose it all, it gently counts back down! else dashmode = 0; } - if (dashmode < 3*TICRATE) // Exits Dash Mode if you drop below speed/dash counter tics. Not in the above block so it doesn't keep disabling in midair. + if (dashmode < 3*TICRATE) // Exits Dash Mode if you drop below speed/dash counter tics. Not in the above block so it doesn't keep disabling in midair. { - player->normalspeed = skins[player->skin].normalspeed; // Reset to default if not capable of entering dash mode. + player->normalspeed = skins[player->skin].normalspeed; // Reset to default if not capable of entering dash mode. player->jumpfactor = skins[player->skin].jumpfactor; } - else if (P_IsObjectOnGround(player->mo)) // Activate dash mode if we're on the ground. + else if (P_IsObjectOnGround(player->mo)) // Activate dash mode if we're on the ground. { - if (player->normalspeed < skins[player->skin].actionspd) // If the player normalspeed is not currently at actionspd in dash mode, add speed each tic - player->normalspeed = player->normalspeed + 1*FRACUNIT/5; // Enter Dash Mode smoothly. + if (player->normalspeed < skins[player->skin].actionspd) // If the player normalspeed is not currently at actionspd in dash mode, add speed each tic + player->normalspeed = player->normalspeed + 1*FRACUNIT/5; // Enter Dash Mode smoothly. if (player->jumpfactor < FixedMul(skins[player->skin].jumpfactor, 5*FRACUNIT/4)) // Boost jump height. player->jumpfactor = player->jumpfactor + 1*FRACUNIT/300; } + dashmode = min(dashmode, 3*TICRATE + 3); + if (player->normalspeed >= skins[player->skin].actionspd) { - mobj_t *ghost = P_SpawnGhostMobj(player->mo); // Spawns afterimages - ghost->fuse = 2; // Makes the images fade quickly + mobj_t *ghost = P_SpawnGhostMobj(player->mo); // Spawns afterimages + ghost->fuse = 2; // Makes the images fade quickly } } else From cee37819cde19ea88a41ae2b4ca419bd67dc6622 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Sat, 9 Jul 2016 14:52:49 +0100 Subject: [PATCH 09/10] Dashmode now has its own animation, SPR2_PEEL. Requires a new PLAYER.DTA. I made a lot of references to the peelout here because I'm not sure what else to call a Sonic character's faster-than-usual-running animation and SPR2_DASH was taken. * SPR2_PEEL, SPR2_SPEE. * S_PLAY_PEEL, S_PLAY_SUPER_PEEL. * PA_PEEL. * Dashmode actually starts charging from runspeed instead of the arbitrarily calculated (normalspeed - 5*FRACUNIT). This just made things easier, honestly, and it's 1 FU of difference compared to the current test case. --- src/d_player.h | 1 + src/dehacked.c | 3 +++ src/info.c | 4 ++++ src/info.h | 4 ++++ src/p_mobj.c | 20 ++++++++++++++++++-- src/p_user.c | 17 ++++++++++++++--- 6 files changed, 44 insertions(+), 5 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index 0e4c5ec51..4a5d0e702 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -165,6 +165,7 @@ typedef enum PA_EDGE, PA_WALK, PA_RUN, + PA_PEEL, PA_PAIN, PA_ROLL, PA_SPRING, diff --git a/src/dehacked.c b/src/dehacked.c index 37584c6e1..57496d20c 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -3794,6 +3794,7 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit "S_PLAY_WAIT", "S_PLAY_WALK", "S_PLAY_RUN", + "S_PLAY_PEEL", "S_PLAY_PAIN", "S_PLAY_DEAD", "S_PLAY_DRWN", @@ -3819,6 +3820,7 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit "S_PLAY_SUPER_STND", "S_PLAY_SUPER_WALK", "S_PLAY_SUPER_RUN", + "S_PLAY_SUPER_PEEL", "S_PLAY_SUPER_PAIN", "S_PLAY_SUPER_STUN", "S_PLAY_SUPER_DEAD", @@ -7188,6 +7190,7 @@ struct { {"PA_EDGE",PA_EDGE}, {"PA_WALK",PA_WALK}, {"PA_RUN",PA_RUN}, + {"PA_PEEL",PA_PEEL}, {"PA_PAIN",PA_PAIN}, {"PA_ROLL",PA_ROLL}, {"PA_SPRING",PA_SPRING}, diff --git a/src/info.c b/src/info.c index dc71ad163..8eec24818 100644 --- a/src/info.c +++ b/src/info.c @@ -62,6 +62,7 @@ char spr2names[NUMPLAYERSPRITES][5] = "WAIT", "WALK", "RUN_", + "PEEL", "PAIN", "DEAD", "DRWN", @@ -88,6 +89,7 @@ char spr2names[NUMPLAYERSPRITES][5] = "SSTD", "SWLK", "SRUN", + "SPEE", "SPAN", "SMSL", "SDTH", @@ -132,6 +134,7 @@ state_t states[NUMSTATES] = {SPR_PLAY, SPR2_WAIT, 16, {NULL}, 0, 0, S_PLAY_WAIT}, // S_PLAY_WAIT {SPR_PLAY, SPR2_WALK, 4, {NULL}, 0, 0, S_PLAY_WALK}, // S_PLAY_WALK {SPR_PLAY, SPR2_RUN , 2, {NULL}, 0, 0, S_PLAY_RUN}, // S_PLAY_RUN + {SPR_PLAY, SPR2_PEEL, 2, {NULL}, 0, 0, S_PLAY_PEEL}, // S_PLAY_PEEL {SPR_PLAY, SPR2_PAIN, 350, {NULL}, 0, 0, S_PLAY_FALL}, // S_PLAY_PAIN {SPR_PLAY, SPR2_DEAD, 4, {NULL}, 0, 0, S_PLAY_DEAD}, // S_PLAY_DEAD {SPR_PLAY, SPR2_DRWN, 4, {NULL}, 0, 0, S_PLAY_DRWN}, // S_PLAY_DRWN @@ -157,6 +160,7 @@ state_t states[NUMSTATES] = {SPR_PLAY, SPR2_SSTD, 7, {NULL}, 0, 0, S_PLAY_SUPER_STND}, // S_PLAY_SUPER_STND {SPR_PLAY, SPR2_SWLK, 7, {NULL}, 0, 0, S_PLAY_SUPER_WALK}, // S_PLAY_SUPER_WALK {SPR_PLAY, SPR2_SRUN, 7, {NULL}, 0, 0, S_PLAY_SUPER_RUN}, // S_PLAY_SUPER_RUN + {SPR_PLAY, SPR2_SPEE, 7, {NULL}, 0, 0, S_PLAY_SUPER_PEEL}, // S_PLAY_SUPER_PEEL {SPR_PLAY, SPR2_SPAN, -1, {NULL}, 0, 0, S_PLAY_SUPER_STND}, // S_PLAY_SUPER_PAIN {SPR_PLAY, SPR2_SMSL, -1, {NULL}, 0, 0, S_PLAY_SUPER_STND}, // S_PLAY_SUPER_STUN {SPR_PLAY, SPR2_SDTH, 4, {NULL}, 0, 0, S_PLAY_SUPER_DEAD}, // S_PLAY_SUPER_DEAD diff --git a/src/info.h b/src/info.h index 46fdde46b..46b76096b 100644 --- a/src/info.h +++ b/src/info.h @@ -581,6 +581,7 @@ enum playersprite SPR2_WAIT, SPR2_WALK, SPR2_RUN , + SPR2_PEEL, SPR2_PAIN, SPR2_DEAD, SPR2_DRWN, @@ -607,6 +608,7 @@ enum playersprite SPR2_SSTD, SPR2_SWLK, SPR2_SRUN, + SPR2_SPEE, SPR2_SPAN, SPR2_SMSL, SPR2_SDTH, @@ -645,6 +647,7 @@ typedef enum state S_PLAY_WAIT, S_PLAY_WALK, S_PLAY_RUN, + S_PLAY_PEEL, S_PLAY_PAIN, S_PLAY_DEAD, S_PLAY_DRWN, @@ -670,6 +673,7 @@ typedef enum state S_PLAY_SUPER_STND, S_PLAY_SUPER_WALK, S_PLAY_SUPER_RUN, + S_PLAY_SUPER_PEEL, S_PLAY_SUPER_PAIN, S_PLAY_SUPER_STUN, S_PLAY_SUPER_DEAD, diff --git a/src/p_mobj.c b/src/p_mobj.c index 5fb3c81d7..bffa796dd 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -175,6 +175,8 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state) return P_SetPlayerMobjState(mobj, S_PLAY_SUPER_WALK); case S_PLAY_RUN: return P_SetPlayerMobjState(mobj, S_PLAY_SUPER_RUN); + case S_PLAY_PEEL: + return P_SetPlayerMobjState(mobj, S_PLAY_SUPER_PEEL); case S_PLAY_PAIN: return P_SetPlayerMobjState(mobj, S_PLAY_SUPER_PAIN); case S_PLAY_DEAD: @@ -231,6 +233,10 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state) case S_PLAY_SUPER_RUN: player->panim = PA_RUN; break; + case S_PLAY_PEEL: + case S_PLAY_SUPER_PEEL: + player->panim = PA_PEEL; + break; case S_PLAY_PAIN: case S_PLAY_SUPER_PAIN: case S_PLAY_SUPER_STUN: @@ -316,7 +322,7 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state) else mobj->tics = 4; } - else if (player->panim == PA_RUN) + else if ((player->panim == PA_RUN) || (player->panim == PA_PEEL)) { if (speed > 52<tics = 1; @@ -339,6 +345,9 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state) { switch(spr2) { + case SPR2_PEEL: + spr2 = SPR2_RUN; + break; case SPR2_RUN: spr2 = SPR2_WALK; break; @@ -393,6 +402,9 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state) case SPR2_SRUN: spr2 = SPR2_RUN; break; + case SPR2_SPEE: + spr2 = SPR2_PEEL; + break; case SPR2_SPAN: spr2 = SPR2_PAIN; break; @@ -2955,7 +2967,9 @@ static void P_PlayerZMovement(mobj_t *mo) { if (mo->player->cmomx || mo->player->cmomy) { - if (mo->player->speed >= FixedMul(mo->player->runspeed, mo->scale) && mo->player->panim != PA_RUN) + if (mo->player->dashmode >= 3*TICRATE && mo->player->panim != PA_PEEL) + P_SetPlayerMobjState(mo, S_PLAY_PEEL); + else if (mo->player->speed >= FixedMul(mo->player->runspeed, mo->scale) && mo->player->panim != PA_RUN) P_SetPlayerMobjState(mo, S_PLAY_RUN); else if ((mo->player->rmomx || mo->player->rmomy) && (mo->player->panim != PA_WALK || mo->state-states == S_PLAY_SUPER_FLOAT)) P_SetPlayerMobjState(mo, S_PLAY_WALK); @@ -2964,6 +2978,8 @@ static void P_PlayerZMovement(mobj_t *mo) } else { + if (mo->player->dashmode >= 3*TICRATE && mo->player->panim != PA_PEEL) + P_SetPlayerMobjState(mo, S_PLAY_PEEL); if (mo->player->speed >= FixedMul(mo->player->runspeed, mo->scale) && mo->player->panim != PA_RUN) P_SetPlayerMobjState(mo, S_PLAY_RUN); else if ((mo->momx || mo->momy) && (mo->player->panim != PA_WALK || mo->state-states == S_PLAY_SUPER_FLOAT)) diff --git a/src/p_user.c b/src/p_user.c index 6b57bb7a9..0eef60b13 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3501,6 +3501,9 @@ static void P_DoSuperStuff(player_t *player) case S_PLAY_SUPER_RUN: P_SetPlayerMobjState(player->mo, S_PLAY_RUN); break; + case S_PLAY_SUPER_PEEL: + P_SetPlayerMobjState(player->mo, S_PLAY_PEEL); + break; case S_PLAY_SUPER_PAIN: P_SetPlayerMobjState(player->mo, S_PLAY_PAIN); break; @@ -6507,9 +6510,12 @@ static void P_MovePlayer(player_t *player) if ((cmd->forwardmove != 0 || cmd->sidemove != 0) || (player->powers[pw_super] && !onground)) { + // If the player is in dashmode, here's their peelout. + if (player->charability == CA_DASHMODE && player->dashmode >= 3*TICRATE && player->panim == PA_RUN && !player->skidtime && (onground || player->powers[pw_super])) + P_SetPlayerMobjState (player->mo, S_PLAY_PEEL); // If the player is moving fast enough, // break into a run! - if (player->speed >= runspd && player->panim == PA_WALK && !player->skidtime && (onground || player->powers[pw_super])) + else if (player->speed >= runspd && player->panim == PA_WALK && !player->skidtime && (onground || player->powers[pw_super])) P_SetPlayerMobjState (player->mo, S_PLAY_RUN); // Super floating at slow speeds has its own special animation. @@ -6521,6 +6527,11 @@ static void P_MovePlayer(player_t *player) P_SetPlayerMobjState (player->mo, S_PLAY_WALK); } + // If your peelout animation is playing, and you're + // going too slow, switch back to the run. + if (player->panim == PA_PEEL && player->dashmode < 3*TICRATE) + P_SetPlayerMobjState(player->mo, S_PLAY_RUN); + // If your running animation is playing, and you're // going too slow, switch back to the walking frames. if (player->panim == PA_RUN && player->speed < runspd) @@ -6851,7 +6862,7 @@ static void P_MovePlayer(player_t *player) #endif } // Otherwise, face the direction you're travelling. - else if (player->panim == PA_WALK || player->panim == PA_RUN || player->panim == PA_ROLL + else if (player->panim == PA_WALK || player->panim == PA_RUN || player->panim == PA_PEEL || player->panim == PA_ROLL || (player->mo->state-states == S_PLAY_FLY || player->mo->state-states == S_PLAY_FLY_TIRED)) player->mo->angle = R_PointToAngle2(0, 0, player->rmomx, player->rmomy); @@ -9173,7 +9184,7 @@ void P_PlayerThink(player_t *player) // Dash mode ability for Metal Sonic if ((player->charability == CA_DASHMODE) && !(maptol & TOL_NIGHTS)) // woo, dashmode! no nights tho. { - if (player->speed >= FixedMul(skins[player->skin].normalspeed - 5*FRACUNIT, player->mo->scale) || (player->pflags & PF_STARTDASH)) + if (player->speed >= FixedMul(player->runspeed, player->mo->scale) || (player->pflags & PF_STARTDASH)) { dashmode++; // Counter. Adds 1 to dash mode per tic in top speed. if (dashmode == 3*TICRATE) // This isn't in the ">=" equation because it'd cause the sound to play infinitely. From 625cb39af74057329478fb635be870e99e16b120 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Sat, 9 Jul 2016 16:53:41 +0100 Subject: [PATCH 10/10] Dashmode now destroys spikes and monitors on contact. Enemies? Probably not for now. --- src/p_map.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/p_map.c b/src/p_map.c index 668ba19c2..6ad475099 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -448,6 +448,35 @@ static boolean PIT_CheckThing(mobj_t *thing) return true; } + // Dashmode users destroy spikes and monitors. + if ((tmthing->player) && (tmthing->player->charability == CA_DASHMODE) && (tmthing->player->dashmode >= 3*TICRATE) + && (thing->flags & (MF_MONITOR) || thing->type == MT_SPIKE)) + { + if ((thing->flags & (MF_MONITOR)) && (thing->health <= 0 || !(thing->flags & MF_SHOOTABLE))) + return true; + blockdist = thing->radius + tmthing->radius; + if (abs(thing->x - tmx) >= blockdist || abs(thing->y - tmy) >= blockdist) + return true; // didn't hit it + // see if it went over / under + if (tmthing->z > thing->z + thing->height) + return true; // overhead + if (tmthing->z + tmthing->height < thing->z) + return true; // underneath + if (thing->type == MT_SPIKE) + { + S_StartSound(tmthing, thing->info->deathsound); + for (thing = thing->subsector->sector->thinglist; thing; thing = thing->snext) + if (thing->type == MT_SPIKE && thing->health > 0 && thing->flags & MF_SOLID && P_AproxDistance(thing->x - tmthing->x, thing->y - tmthing->y) < FixedMul(56*FRACUNIT, thing->scale)) + P_KillMobj(thing, tmthing, tmthing, 0); + } + else + { + thing->health = 0; + P_KillMobj(thing, tmthing, tmthing, 0); + } + return true; + } + if (!(thing->flags & (MF_SOLID|MF_SPECIAL|MF_PAIN|MF_SHOOTABLE))) return true;