First commit, CA_BOUNCE almost completed.

This commit is contained in:
toasterbabe 2016-12-23 17:31:07 +00:00
parent 37c8ef6369
commit 10a137620a
8 changed files with 115 additions and 14 deletions

View file

@ -66,6 +66,7 @@ typedef enum
CA_AIRDRILL, CA_AIRDRILL,
CA_JUMPTHOK, CA_JUMPTHOK,
CA_DASHMODE, CA_DASHMODE,
CA_BOUNCE,
CA_TWINSPIN CA_TWINSPIN
} charability_t; } charability_t;
@ -158,9 +159,12 @@ typedef enum
PF_SHIELDABILITY = 1<<28, PF_SHIELDABILITY = 1<<28,
// Force jump damage? // Force jump damage?
PF_FORCEJUMPDAMAGE = 1<<29 PF_FORCEJUMPDAMAGE = 1<<29,
// free up to and including 1<<31 // Bouncing
PF_BOUNCING = 1<<30
// 1<<31 is free
} pflags_t; } pflags_t;
typedef enum typedef enum

View file

@ -3816,6 +3816,10 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit
"S_PLAY_CLING", "S_PLAY_CLING",
"S_PLAY_CLIMB", "S_PLAY_CLIMB",
// CA_BOUNCE
"S_PLAY_BOUNCE",
"S_PLAY_BOUNCE_LANDING",
// CA_TWINSPIN // CA_TWINSPIN
"S_PLAY_TWINSPIN", "S_PLAY_TWINSPIN",
@ -6790,6 +6794,7 @@ static const char *const PLAYERFLAG_LIST[] = {
"CANCARRY", // Can carry? "CANCARRY", // Can carry?
"SHIELDABILITY", // Thokked with shield ability "SHIELDABILITY", // Thokked with shield ability
"FORCEJUMPDAMAGE", // Force jump damage "FORCEJUMPDAMAGE", // Force jump damage
"BOUNCING",
NULL // stop loop here. NULL // stop loop here.
}; };
@ -7207,6 +7212,7 @@ struct {
{"CA_AIRDRILL",CA_AIRDRILL}, {"CA_AIRDRILL",CA_AIRDRILL},
{"CA_JUMPTHOK",CA_JUMPTHOK}, {"CA_JUMPTHOK",CA_JUMPTHOK},
{"CA_DASHMODE",CA_DASHMODE}, {"CA_DASHMODE",CA_DASHMODE},
{"CA_BOUNCE",CA_BOUNCE},
{"CA_TWINSPIN",CA_TWINSPIN}, {"CA_TWINSPIN",CA_TWINSPIN},
// Secondary // Secondary
{"CA2_NONE",CA2_NONE}, // now slot 0! {"CA2_NONE",CA2_NONE}, // now slot 0!

View file

@ -402,6 +402,9 @@ char spr2names[NUMPLAYERSPRITES][5] =
"CLNG", "CLNG",
"CLMB", "CLMB",
"BNCE",
"BLND",
"TWIN", "TWIN",
"MLEE", "MLEE",
@ -514,6 +517,10 @@ state_t states[NUMSTATES] =
{SPR_PLAY, SPR2_CLNG|FF_ANIMATE, -1, {NULL}, 0, 4, S_NULL}, // S_PLAY_CLING {SPR_PLAY, SPR2_CLNG|FF_ANIMATE, -1, {NULL}, 0, 4, S_NULL}, // S_PLAY_CLING
{SPR_PLAY, SPR2_CLMB, 5, {NULL}, 0, 0, S_PLAY_CLIMB}, // S_PLAY_CLIMB {SPR_PLAY, SPR2_CLMB, 5, {NULL}, 0, 0, S_PLAY_CLIMB}, // S_PLAY_CLIMB
// CA_BOUNCE
{SPR_PLAY, SPR2_BNCE|FF_ANIMATE, -1, {NULL}, 0, 0, S_NULL}, // S_PLAY_BOUNCE
{SPR_PLAY, SPR2_BLND|FF_SPR2ENDSTATE, 2, {NULL}, S_PLAY_BOUNCE, 4, S_PLAY_BOUNCE_LANDING}, // S_PLAY_BOUNCE_LANDING
// CA_TWINSPIN // CA_TWINSPIN
{SPR_PLAY, SPR2_TWIN|FF_SPR2ENDSTATE, 1, {NULL}, S_PLAY_JUMP, 0, S_PLAY_TWINSPIN}, // S_PLAY_TWINSPIN {SPR_PLAY, SPR2_TWIN|FF_SPR2ENDSTATE, 1, {NULL}, S_PLAY_JUMP, 0, S_PLAY_TWINSPIN}, // S_PLAY_TWINSPIN

View file

@ -604,6 +604,9 @@ enum playersprite
SPR2_CLNG, // cling SPR2_CLNG, // cling
SPR2_CLMB, // climb SPR2_CLMB, // climb
SPR2_BNCE, // bounce
SPR2_BLND, // bounce landing
SPR2_TWIN, // twinspin SPR2_TWIN, // twinspin
SPR2_MLEE, // melee SPR2_MLEE, // melee
@ -713,6 +716,10 @@ typedef enum state
S_PLAY_CLING, S_PLAY_CLING,
S_PLAY_CLIMB, S_PLAY_CLIMB,
// CA_BOUNCE
S_PLAY_BOUNCE,
S_PLAY_BOUNCE_LANDING,
// CA_TWINSPIN // CA_TWINSPIN
S_PLAY_TWINSPIN, S_PLAY_TWINSPIN,

View file

@ -371,7 +371,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
|| ((player->pflags & PF_JUMPED) && (player->pflags & PF_FORCEJUMPDAMAGE || !(player->charflags & SF_NOJUMPSPIN) || (player->charability == CA_TWINSPIN && player->panim == PA_ABILITY))) || ((player->pflags & PF_JUMPED) && (player->pflags & PF_FORCEJUMPDAMAGE || !(player->charflags & SF_NOJUMPSPIN) || (player->charability == CA_TWINSPIN && player->panim == PA_ABILITY)))
|| (player->pflags & (PF_SPINNING|PF_GLIDING)) || (player->pflags & (PF_SPINNING|PF_GLIDING))
|| (player->charability2 == CA2_MELEE && player->panim == PA_ABILITY2) || (player->charability2 == CA2_MELEE && player->panim == PA_ABILITY2)
|| ((player->charflags & SF_STOMPDAMAGE) && (P_MobjFlip(toucher)*(toucher->z - (special->z + special->height/2)) > 0) && (P_MobjFlip(toucher)*toucher->momz < 0)) || ((player->charflags & SF_STOMPDAMAGE || player->pflags & PF_BOUNCING) && (P_MobjFlip(toucher)*(toucher->z - (special->z + special->height/2)) > 0) && (P_MobjFlip(toucher)*toucher->momz < 0))
|| player->powers[pw_invulnerability] || player->powers[pw_super] || player->powers[pw_invulnerability] || player->powers[pw_super]
|| elementalpierce) // Do you possess the ability to subdue the object? || elementalpierce) // Do you possess the ability to subdue the object?
{ {
@ -423,7 +423,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
|| ((player->pflags & PF_JUMPED) && (player->pflags & PF_FORCEJUMPDAMAGE || !(player->charflags & SF_NOJUMPSPIN) || (player->charability == CA_TWINSPIN && player->panim == PA_ABILITY))) || ((player->pflags & PF_JUMPED) && (player->pflags & PF_FORCEJUMPDAMAGE || !(player->charflags & SF_NOJUMPSPIN) || (player->charability == CA_TWINSPIN && player->panim == PA_ABILITY)))
|| (player->pflags & (PF_SPINNING|PF_GLIDING)) || (player->pflags & (PF_SPINNING|PF_GLIDING))
|| (player->charability2 == CA2_MELEE && player->panim == PA_ABILITY2) || (player->charability2 == CA2_MELEE && player->panim == PA_ABILITY2)
|| ((player->charflags & SF_STOMPDAMAGE) && (P_MobjFlip(toucher)*(toucher->z - (special->z + special->height/2)) > 0) && (P_MobjFlip(toucher)*toucher->momz < 0)) || ((player->charflags & SF_STOMPDAMAGE || player->pflags & PF_BOUNCING) && (P_MobjFlip(toucher)*(toucher->z - (special->z + special->height/2)) > 0) && (P_MobjFlip(toucher)*toucher->momz < 0))
|| player->powers[pw_invulnerability] || player->powers[pw_super]) // Do you possess the ability to subdue the object? || player->powers[pw_invulnerability] || player->powers[pw_super]) // Do you possess the ability to subdue the object?
{ {
if ((P_MobjFlip(toucher)*toucher->momz < 0) && (elementalpierce != 1)) if ((P_MobjFlip(toucher)*toucher->momz < 0) && (elementalpierce != 1))
@ -1395,7 +1395,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
} }
else if (((player->pflags & PF_NIGHTSMODE) && (player->pflags & PF_DRILLING)) else if (((player->pflags & PF_NIGHTSMODE) && (player->pflags & PF_DRILLING))
|| ((player->pflags & PF_JUMPED) && (player->pflags & PF_FORCEJUMPDAMAGE || !(player->charflags & SF_NOJUMPSPIN) || (player->charability == CA_TWINSPIN && player->panim == PA_ABILITY))) || ((player->pflags & PF_JUMPED) && (player->pflags & PF_FORCEJUMPDAMAGE || !(player->charflags & SF_NOJUMPSPIN) || (player->charability == CA_TWINSPIN && player->panim == PA_ABILITY)))
|| ((player->charflags & SF_STOMPDAMAGE) && (P_MobjFlip(toucher)*(toucher->z - (special->z + special->height/2)) > 0) && (P_MobjFlip(toucher)*toucher->momz < 0)) || ((player->charflags & SF_STOMPDAMAGE || player->pflags & PF_BOUNCING) && (P_MobjFlip(toucher)*(toucher->z - (special->z + special->height/2)) > 0) && (P_MobjFlip(toucher)*toucher->momz < 0))
|| (player->pflags & (PF_SPINNING|PF_GLIDING)) || (player->pflags & (PF_SPINNING|PF_GLIDING))
|| player->powers[pw_invulnerability] || player->powers[pw_super]) // Do you possess the ability to subdue the object? || player->powers[pw_invulnerability] || player->powers[pw_super]) // Do you possess the ability to subdue the object?
{ {

View file

@ -1063,7 +1063,7 @@ static boolean PIT_CheckThing(mobj_t *thing)
|| !(tmthing->player->charflags & SF_NOJUMPSPIN) || !(tmthing->player->charflags & SF_NOJUMPSPIN)
|| (tmthing->player->charability == CA_TWINSPIN && tmthing->player->panim == PA_ABILITY))) || (tmthing->player->charability == CA_TWINSPIN && tmthing->player->panim == PA_ABILITY)))
|| (tmthing->player->charability2 == CA2_MELEE && tmthing->player->panim == PA_ABILITY2) || (tmthing->player->charability2 == CA2_MELEE && tmthing->player->panim == PA_ABILITY2)
|| ((tmthing->player->charflags & SF_STOMPDAMAGE) || ((tmthing->player->charflags & SF_STOMPDAMAGE || tmthing->player->pflags & PF_BOUNCING)
&& (P_MobjFlip(tmthing)*(tmthing->z - (thing->z + thing->height/2)) > 0) && (P_MobjFlip(tmthing)*tmthing->momz < 0)) && (P_MobjFlip(tmthing)*(tmthing->z - (thing->z + thing->height/2)) > 0) && (P_MobjFlip(tmthing)*tmthing->momz < 0))
|| elementalpierce)) || elementalpierce))
{ {
@ -1105,7 +1105,7 @@ static boolean PIT_CheckThing(mobj_t *thing)
|| !(tmthing->player->charflags & SF_NOJUMPSPIN) || !(tmthing->player->charflags & SF_NOJUMPSPIN)
|| (tmthing->player->charability == CA_TWINSPIN && tmthing->player->panim == PA_ABILITY))) || (tmthing->player->charability == CA_TWINSPIN && tmthing->player->panim == PA_ABILITY)))
|| (tmthing->player->charability2 == CA2_MELEE && tmthing->player->panim == PA_ABILITY2) || (tmthing->player->charability2 == CA2_MELEE && tmthing->player->panim == PA_ABILITY2)
|| ((tmthing->player->charflags & SF_STOMPDAMAGE) || ((tmthing->player->charflags & SF_STOMPDAMAGE || tmthing->player->pflags & PF_BOUNCING)
&& (P_MobjFlip(tmthing)*(tmthing->z - (thing->z + thing->height/2)) > 0) && (P_MobjFlip(tmthing)*tmthing->momz < 0))) && (P_MobjFlip(tmthing)*(tmthing->z - (thing->z + thing->height/2)) > 0) && (P_MobjFlip(tmthing)*tmthing->momz < 0)))
&& !((thing->type == MT_RING_REDBOX && tmthing->player->ctfteam != 1) || (thing->type == MT_RING_BLUEBOX && tmthing->player->ctfteam != 2))) && !((thing->type == MT_RING_REDBOX && tmthing->player->ctfteam != 1) || (thing->type == MT_RING_BLUEBOX && tmthing->player->ctfteam != 2)))
; ;

View file

@ -253,6 +253,13 @@ UINT8 P_GetMobjSprite2(mobj_t *mobj, UINT8 spr2)
spr2 = SPR2_CLMB; spr2 = SPR2_CLMB;
break; break;
case SPR2_BNCE:
spr2 = SPR2_FALL;
break;
case SPR2_BLND:
spr2 = SPR2_SPIN;
break;
case SPR2_TWIN: case SPR2_TWIN:
spr2 = SPR2_SPIN; spr2 = SPR2_SPIN;
break; break;
@ -526,6 +533,8 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state)
case S_PLAY_FLY: case S_PLAY_FLY:
case S_PLAY_SWIM: case S_PLAY_SWIM:
case S_PLAY_GLIDE: case S_PLAY_GLIDE:
case S_PLAY_BOUNCE:
case S_PLAY_BOUNCE_LANDING:
case S_PLAY_TWINSPIN: case S_PLAY_TWINSPIN:
player->panim = PA_ABILITY; player->panim = PA_ABILITY;
break; break;
@ -3306,6 +3315,22 @@ static void P_PlayerZMovement(mobj_t *mo)
clipmomz = false; clipmomz = false;
} }
} }
if (mo->player->pflags & PF_BOUNCING)
{
fixed_t prevmomz = P_MobjFlip(mo)*abs(mo->momz);
if (mo->eflags & MFE_UNDERWATER)
{
prevmomz /= 2;
}
S_StartSound(mo, sfx_boingf);
P_DoJump(mo->player, false);
P_SetPlayerMobjState(mo, S_PLAY_BOUNCE_LANDING);
mo->player->pflags |= PF_BOUNCING;
mo->player->jumping = 0;
mo->momz = (FixedMul(mo->momz, 3*FRACUNIT/2) + prevmomz)/2;
clipmomz = false;
}
} }
} }
if (!(mo->player->pflags & PF_SPINNING)) if (!(mo->player->pflags & PF_SPINNING))
@ -4127,6 +4152,9 @@ static void P_PlayerMobjThinker(mobj_t *mobj)
// momentum movement // momentum movement
mobj->eflags &= ~MFE_JUSTSTEPPEDDOWN; mobj->eflags &= ~MFE_JUSTSTEPPEDDOWN;
if (mobj->state-states == S_PLAY_BOUNCE_LANDING)
goto animonly;
// Zoom tube // Zoom tube
if (mobj->tracer) if (mobj->tracer)
{ {

View file

@ -870,7 +870,7 @@ void P_DoPlayerPain(player_t *player, mobj_t *source, mobj_t *inflictor)
// Useful when you want to kill everything the player is doing. // Useful when you want to kill everything the player is doing.
void P_ResetPlayer(player_t *player) void P_ResetPlayer(player_t *player)
{ {
player->pflags &= ~(PF_SPINNING|PF_STARTDASH|PF_JUMPED|PF_FORCEJUMPDAMAGE|PF_GLIDING|PF_THOKKED|PF_CANCARRY|PF_SHIELDABILITY); player->pflags &= ~(PF_SPINNING|PF_STARTDASH|PF_JUMPED|PF_FORCEJUMPDAMAGE|PF_GLIDING|PF_THOKKED|PF_CANCARRY|PF_SHIELDABILITY|PF_BOUNCING);
player->powers[pw_carry] = CR_NONE; player->powers[pw_carry] = CR_NONE;
player->jumping = 0; player->jumping = 0;
player->secondjump = 0; player->secondjump = 0;
@ -3934,7 +3934,7 @@ void P_DoJumpShield(player_t *player)
player->jumping = 0; player->jumping = 0;
player->secondjump = 0; player->secondjump = 0;
player->pflags |= PF_THOKKED|PF_SHIELDABILITY; player->pflags |= PF_THOKKED|PF_SHIELDABILITY;
player->pflags &= ~PF_SPINNING; player->pflags &= ~(PF_SPINNING|PF_BOUNCING);
if (electric) if (electric)
{ {
mobj_t *spark; mobj_t *spark;
@ -4278,6 +4278,16 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd)
S_StartSound(player->mo, sfx_spndsh); S_StartSound(player->mo, sfx_spndsh);
} }
break; break;
case CA_BOUNCE:
if (!(player->pflags & PF_THOKKED) || player->charability2 == CA2_MULTIABILITY)
{
P_SetPlayerMobjState(player->mo, S_PLAY_BOUNCE);
player->pflags &= ~PF_JUMPED;
player->pflags |= PF_BOUNCING;
player->mo->momx >>= 1;
player->mo->momy >>= 1;
}
break;
case CA_TWINSPIN: case CA_TWINSPIN:
if (!(player->pflags & PF_THOKKED) || player->charability2 == CA2_MULTIABILITY) if (!(player->pflags & PF_THOKKED) || player->charability2 == CA2_MULTIABILITY)
{ {
@ -4785,11 +4795,16 @@ static void P_3dMovement(player_t *player)
} }
// Better maneuverability while flying // Better maneuverability while flying
if(player->powers[pw_tailsfly]) if (player->powers[pw_tailsfly])
{ {
thrustfactor = player->thrustfactor*2; thrustfactor = player->thrustfactor*2;
acceleration = player->accelstart + (FixedDiv(player->speed, player->mo->scale)>>FRACBITS) * player->acceleration; acceleration = player->accelstart + (FixedDiv(player->speed, player->mo->scale)>>FRACBITS) * player->acceleration;
} }
else if (player->pflags & PF_BOUNCING)
{
thrustfactor = player->thrustfactor/2;
acceleration = player->accelstart + (FixedDiv(player->speed, player->mo->scale)>>FRACBITS) * player->acceleration;
}
// Forward movement // Forward movement
if (player->climbing) if (player->climbing)
@ -6703,9 +6718,44 @@ static void P_MovePlayer(player_t *player)
player->climbing = 0; player->climbing = 0;
} }
if ((!(player->charability == CA_BOUNCE) || player->gotflag) // If you can't bounce, then why the heck would you be bouncing?
&& (player->pflags & PF_BOUNCING))
{
if (onground)
P_SetPlayerMobjState(player->mo, S_PLAY_WALK);
else
{
player->pflags |= PF_JUMPED;
P_SetPlayerMobjState(player->mo, S_PLAY_JUMP);
}
player->pflags &= ~PF_BOUNCING;
}
// Bouncing...
if (player->pflags & PF_BOUNCING)
{
if (!(player->pflags & PF_JUMPDOWN)) // If not holding the jump button
{
P_ResetPlayer(player); // down, stop bouncing.
if (onground)
P_SetPlayerMobjState(player->mo, S_PLAY_WALK);
else if (player->charability2 == CA2_MULTIABILITY)
{
player->pflags |= PF_JUMPED;
P_SetPlayerMobjState(player->mo, S_PLAY_JUMP);
}
else
{
player->pflags |= PF_THOKKED;
player->mo->momx >>= 1;
player->mo->momy >>= 1;
P_SetPlayerMobjState(player->mo, S_PLAY_FALL);
}
}
}
// Glide MOMZ // Glide MOMZ
// AKA my own gravity. =) // AKA my own gravity. =)
if (player->pflags & PF_GLIDING) else if (player->pflags & PF_GLIDING)
{ {
fixed_t leeway; fixed_t leeway;
fixed_t glidespeed = player->actionspd; fixed_t glidespeed = player->actionspd;
@ -6749,8 +6799,7 @@ static void P_MovePlayer(player_t *player)
P_ResetPlayer(player); // down, stop gliding. P_ResetPlayer(player); // down, stop gliding.
if (onground) if (onground)
P_SetPlayerMobjState(player->mo, S_PLAY_WALK); P_SetPlayerMobjState(player->mo, S_PLAY_WALK);
else if (player->charability2 == CA2_MULTIABILITY else if (player->charability2 == CA2_MULTIABILITY)
&& player->charability == CA_GLIDEANDCLIMB)
{ {
player->pflags |= PF_JUMPED; player->pflags |= PF_JUMPED;
P_SetPlayerMobjState(player->mo, S_PLAY_JUMP); P_SetPlayerMobjState(player->mo, S_PLAY_JUMP);
@ -9330,7 +9379,7 @@ void P_PlayerThink(player_t *player)
player->pflags &= ~PF_SLIDING; player->pflags &= ~PF_SLIDING;
#define dashmode player->dashmode #define dashmode player->dashmode
// Dash mode ability for Metal Sonic // Dash mode ability
if ((player->charability == CA_DASHMODE) && !(player->gotflag) && !(maptol & TOL_NIGHTS)) // woo, dashmode! no nights tho. if ((player->charability == CA_DASHMODE) && !(player->gotflag) && !(maptol & TOL_NIGHTS)) // woo, dashmode! no nights tho.
{ {
if (player->speed >= FixedMul(player->runspeed, player->mo->scale) || (player->pflags & PF_STARTDASH)) if (player->speed >= FixedMul(player->runspeed, player->mo->scale) || (player->pflags & PF_STARTDASH))