From 824458a5ff40e8c9fa5a1983c999503002d727d5 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Wed, 13 Jul 2016 18:18:18 +0100 Subject: [PATCH] Swimming animation! Since I know we want it for Smiles eventually. Also, I guess CA_SWIM isn't forced into running on water anymore. --- src/dehacked.c | 3 ++- src/info.c | 2 ++ src/info.h | 2 ++ src/p_mobj.c | 8 ++++++-- src/p_user.c | 17 +++++++++++++---- src/r_things.c | 2 +- 6 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index f8046c48c..aafdcf289 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -3783,8 +3783,9 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit "S_PLAY_EDGE", "S_PLAY_RIDE", - // CA_FLY + // CA_FLY/SWIM "S_PLAY_FLY", + "S_PLAY_SWIM", "S_PLAY_FLY_TIRED", // CA_GLIDEANDCLIMB diff --git a/src/info.c b/src/info.c index dc71ad163..9fd2aee38 100644 --- a/src/info.c +++ b/src/info.c @@ -78,6 +78,7 @@ char spr2names[NUMPLAYERSPRITES][5] = "LIFE", "FLY_", + "SWIM", "TIRE", "GLID", @@ -146,6 +147,7 @@ state_t states[NUMSTATES] = // Tails abilities {SPR_PLAY, SPR2_FLY , 2, {NULL}, 0, 0, S_PLAY_FLY}, // S_PLAY_FLY + {SPR_PLAY, SPR2_SWIM, 2, {NULL}, 0, 0, S_PLAY_SWIM}, // S_PLAY_SWIM {SPR_PLAY, SPR2_TIRE, 12, {NULL}, 0, 0, S_PLAY_FLY_TIRED}, // S_PLAY_FLY_TIRED // Knuckles abilities diff --git a/src/info.h b/src/info.h index 46fdde46b..610839060 100644 --- a/src/info.h +++ b/src/info.h @@ -597,6 +597,7 @@ enum playersprite SPR2_LIFE, SPR2_FLY , + SPR2_SWIM, SPR2_TIRE, SPR2_GLID, @@ -659,6 +660,7 @@ typedef enum state // CA_FLY S_PLAY_FLY, + S_PLAY_SWIM, S_PLAY_FLY_TIRED, // CA_GLIDEANDCLIMB diff --git a/src/p_mobj.c b/src/p_mobj.c index b60a5075c..373326999 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -254,6 +254,7 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state) player->panim = PA_FALL; break; case S_PLAY_FLY: + case S_PLAY_SWIM: case S_PLAY_GLIDE: player->panim = PA_ABILITY; break; @@ -370,9 +371,12 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state) case SPR2_FLY: spr2 = SPR2_SPNG; break; - case SPR2_TIRE: + case SPR2_SWIM: spr2 = SPR2_FLY; break; + case SPR2_TIRE: + spr2 = (player->charability == CA_FLY) ? SPR2_FLY : SPR2_SWIM; + break; case SPR2_GLID: spr2 = SPR2_FLY; @@ -3248,7 +3252,7 @@ static boolean P_SceneryZMovement(mobj_t *mo) boolean P_CanRunOnWater(player_t *player, ffloor_t *rover) { if (!(player->pflags & PF_NIGHTSMODE) && !player->homing - && (((player->charability == CA_SWIM) || player->powers[pw_super] || player->charflags & SF_RUNONWATER) && player->mo->ceilingz-*rover->topheight >= player->mo->height) + && ((player->powers[pw_super] || player->charflags & SF_RUNONWATER) && player->mo->ceilingz-*rover->topheight >= player->mo->height) && (rover->flags & FF_SWIMMABLE) && !(player->pflags & PF_SPINNING) && player->speed > FixedMul(player->runspeed, player->mo->scale) && !(player->pflags & PF_SLIDING) && abs(player->mo->z - *rover->topheight) < FixedMul(30*FRACUNIT, player->mo->scale)) diff --git a/src/p_user.c b/src/p_user.c index c63b57702..6f7313db7 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4104,14 +4104,17 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) break; case CA_FLY: - case CA_SWIM: // Swim + case CA_SWIM: // If currently in the air from a jump, and you pressed the // button again and have the ability to fly, do so! if (player->charability == CA_SWIM && !(player->mo->eflags & MFE_UNDERWATER)) ; // Can't do anything if you're a fish out of water! else if (!(player->pflags & PF_THOKKED) && !(player->powers[pw_tailsfly])) { - P_SetPlayerMobjState(player->mo, S_PLAY_FLY); // Change to the flying animation + if (player->mo->eflags & MFE_UNDERWATER) + P_SetPlayerMobjState(player->mo, S_PLAY_SWIM); // Change to the swimming animation + else + P_SetPlayerMobjState(player->mo, S_PLAY_FLY); // Change to the flying animation player->powers[pw_tailsfly] = tailsflytics + 1; // Set the fly timer @@ -4121,8 +4124,6 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) break; case CA_GLIDEANDCLIMB: // Now Knuckles-type abilities are checked. - // If you can turn super and aren't already, - // and you don't have a shield, do it! if (!(player->pflags & PF_THOKKED) || player->charability2 == CA2_MULTIABILITY) { INT32 glidespeed = player->actionspd; @@ -6728,6 +6729,14 @@ static void P_MovePlayer(player_t *player) if (player->panim != PA_ABILITY) player->powers[pw_tailsfly] = 0; + if (player->charability == CA_FLY || player->charability == CA_SWIM) // Frustratingly has to remain seperate from the below block. + { + if (player->mo->state-states == S_PLAY_FLY && player->mo->eflags & MFE_UNDERWATER) + P_SetPlayerMobjState(player->mo, S_PLAY_SWIM); // Change to the swimming animation + else if (player->mo->state-states == S_PLAY_SWIM && !(player->mo->eflags & MFE_UNDERWATER)) + P_SetPlayerMobjState(player->mo, S_PLAY_FLY); // Change to the flying animation + } + if (player->charability == CA_FLY || (player->charability == CA_SWIM && player->mo->eflags & MFE_UNDERWATER)) { // Fly counter for Tails. diff --git a/src/r_things.c b/src/r_things.c index 1a0e6dcfe..aae649a8f 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -2339,7 +2339,7 @@ void R_InitSkins(void) } // returns true if available in circumstances, otherwise nope -// warning don't use with an invalid skinnum +// warning don't use with an invalid skinnum other than -1 which always returns true boolean R_SkinUnlock(INT32 skinnum) { return ((skinnum == -1) // Simplifies things elsewhere, since there's already plenty of checks for less-than-0...