Merge branch 'charge-instawhip' into 'master'

More flexible instawhip

See merge request KartKrew/Kart!1551
This commit is contained in:
Oni 2023-10-15 01:40:43 +00:00
commit 97ddaba295
17 changed files with 243 additions and 90 deletions

View file

@ -857,7 +857,9 @@ struct player_t
mobj_t *hand;
mobj_t *flickyAttacker;
UINT8 instaShieldCooldown;
UINT8 instaWhipCharge;
UINT8 instaWhipCooldown;
UINT8 instaWhipChargeLockout;
UINT8 guardCooldown;
UINT8 handtimer;

View file

@ -4087,7 +4087,7 @@ state_t states[NUMSTATES] =
{SPR_NULL, 0, 0, {A_PlaySound}, sfx_s3ka0, 2, S_INSTAWHIP_RECHARGE3}, // S_INSTAWHIP_RECHARGE2
{SPR_WPRE, FF_FULLBRIGHT|FF_FLOORSPRITE|FF_ANIMATE|0, 36, {NULL}, 17, 2, S_INSTAWHIP_RECHARGE4}, // S_INSTAWHIP_RECHARGE3
{SPR_NULL, 0, 0, {A_PlaySound}, sfx_s3k7c, 2, S_NULL}, // S_INSTAWHIP_RECHARGE4
{SPR_WPRJ, FF_ANIMATE, 9, {NULL}, 8, 1, S_NULL}, // S_INSTAWHIP_REJECT
{SPR_WPRJ, FF_FULLBRIGHT|FF_ANIMATE, 9, {NULL}, 8, 1, S_INSTAWHIP_REJECT}, // S_INSTAWHIP_REJECT
{SPR_GRNG, FF_FULLBRIGHT|FF_PAPERSPRITE|0, -1, {NULL}, 0, 0, S_NULL}, // S_BLOCKRING
{SPR_GBDY, FF_FULLBRIGHT|FF_ANIMATE|0, -1, {NULL}, 4, 2, S_NULL}, // S_BLOCKBODY
@ -23025,8 +23025,8 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] =
S_NULL, // xdeathstate
sfx_None, // deathsound
0, // speed
90*FRACUNIT, // radius
90*FRACUNIT, // height
95*FRACUNIT, // radius
95*FRACUNIT, // height
0, // display offset
100, // mass
0, // damage

View file

@ -1415,7 +1415,7 @@ static void K_BotItemInstashield(player_t *player, ticcmd_t *cmd)
return;
}
if (player->instaShieldCooldown || leveltime < starttime || player->spindash)
if (player->instaWhipCharge || leveltime < starttime || player->spindash)
{
// Instashield is on cooldown.
return;

View file

@ -869,7 +869,7 @@ boolean K_InstaWhipCollide(mobj_t *shield, mobj_t *victim)
attacker->renderflags &= ~RF_DONTDRAW;
attackerPlayer->spindashboost = 0;
attackerPlayer->sneakertimer = 0;
attackerPlayer->instaShieldCooldown = GUARDBREAK_COOLDOWN;
attackerPlayer->instaWhipCharge = GUARDBREAK_COOLDOWN;
attackerPlayer->guardCooldown = GUARDBREAK_COOLDOWN;
attackerPlayer->flashing = 0;

View file

@ -1409,8 +1409,8 @@ static void K_UpdateDraft(player_t *player)
leniency *= 4;
}
// Opportunity cost for berserk attacking. Get your slingshot speed first!
if (player->instaShieldCooldown && player->rings <= 0)
// Want to berserk attack? Get your speed FIRST.
if (player->instaWhipCharge >= INSTAWHIP_TETHERBLOCK || player->instaWhipCooldown)
return;
// Not enough speed to draft.
@ -3691,8 +3691,7 @@ void K_DoGuardBreak(mobj_t *t1, mobj_t *t2) {
if (P_PlayerInPain(t2->player))
return;
// short-circuit instashield for vfx visibility
t1->player->instaShieldCooldown = GUARDBREAK_COOLDOWN;
t1->player->instaWhipCharge = 0;
t1->player->guardCooldown = GUARDBREAK_COOLDOWN;
S_StartSound(t1, sfx_gbrk);
@ -8136,32 +8135,8 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd)
if (player->gateBoost)
player->gateBoost--;
if (leveltime < starttime)
{
player->instaShieldCooldown = (gametyperules & GTR_SPHERES) ? INSTAWHIP_STARTOFBATTLE : INSTAWHIP_STARTOFRACE;
}
else if (player->rings > 0)
{
if (player->instaShieldCooldown > INSTAWHIP_COOLDOWN)
player->instaShieldCooldown--;
else
player->instaShieldCooldown = INSTAWHIP_COOLDOWN;
}
else
{
if (player->instaShieldCooldown)
{
player->instaShieldCooldown--;
if (!P_IsObjectOnGround(player->mo))
player->instaShieldCooldown = max(player->instaShieldCooldown, 1);
}
}
if (player->powerup.rhythmBadgeTimer > 0)
{
player->instaShieldCooldown = min(player->instaShieldCooldown, 1);
player->powerup.rhythmBadgeTimer--;
}
if (player->powerup.barrierTimer > 0)
{
@ -8291,6 +8266,44 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd)
if (player->justbumped > 0)
player->justbumped--;
if (player->instaWhipCooldown)
{
player->instaWhipCharge = 0;
player->instaWhipCooldown--;
}
// Don't screw up chain ring pickup/usage with instawhip charge.
// If the button stays held, delay charge a bit.
if (player->instaWhipChargeLockout)
player->instaWhipChargeLockout--;
if (player->rings > 0 || player->itemamount || player->ringdelay)
player->instaWhipChargeLockout = INSTAWHIP_HOLD_DELAY;
if (!(player->cmd.buttons & BT_ATTACK)) // Deliberate Item button release, no need to protect you from lockout
player->instaWhipChargeLockout = 0;
if (player->instaWhipCharge && player->instaWhipCharge < INSTAWHIP_CHARGETIME)
{
if (!S_SoundPlaying(player->mo, sfx_wchrg1))
S_StartSoundAtVolume(player->mo, sfx_wchrg1, 255/2);
}
else
{
S_StopSoundByID(player->mo, sfx_wchrg1);
}
if (player->instaWhipCharge >= INSTAWHIP_CHARGETIME)
{
if (!S_SoundPlaying(player->mo, sfx_wchrg2))
S_StartSoundAtVolume(player->mo, sfx_wchrg2, 255/3);
}
else
{
S_StopSoundByID(player->mo, sfx_wchrg2);
}
if (player->itemamount || player->respawn.state != RESPAWNST_NONE || player->pflags & (PF_ITEMOUT|PF_EGGMANOUT) || player->rocketsneakertimer)
player->instaWhipCharge = 0;
if (player->tiregrease)
{
// Remove grease faster if players are moving slower; players that are recovering
@ -8448,9 +8461,6 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd)
player->pflags &= ~PF_DRIFTINPUT;
}
if (K_PlayerGuard(player) && !K_PowerUpRemaining(player, POWERUP_BARRIER))
player->instaShieldCooldown = max(player->instaShieldCooldown, INSTAWHIP_DROPGUARD);
// Roulette Code
K_KartItemRoulette(player, cmd);
@ -10196,7 +10206,33 @@ boolean K_PlayerGuard(player_t *player)
return true;
}
return (K_PlayerEBrake(player) && player->spheres > 0);
if (player->spheres == 0)
return false;
// Ugh. Duplicating a lot of this because while Guard _superficially_ looks like it's
// restricted similarly to ebrake, it's actually _really_ bad if we can't guard after item bumps.
if (player->respawn.state != RESPAWNST_NONE
&& (player->respawn.init == true || player->respawn.fromRingShooter == true))
{
return false;
}
if (Obj_PlayerRingShooterFreeze(player) == true)
{
return false;
}
if (K_PressingEBrake(player) == true
&& (player->drift == 0 || P_IsObjectOnGround(player->mo) == false)
&& P_PlayerInPain(player) == false
&& player->spindashboost == 0
&& player->nocontrol == 0)
{
return true;
}
return false;
}
SINT8 K_Sliptiding(player_t *player)
@ -10987,6 +11023,90 @@ void K_MoveKartPlayer(player_t *player, boolean onground)
}
}
// This looks a lot like the check that's right under it, but this check is specifically for instawhip charge,
// which is allowed during painstate as a last-ditch defensive option.
if (player && player->mo && player->mo->health > 0 && !player->spectator && !mapreset && leveltime > introtime)
{
boolean chargingwhip = (cmd->buttons & BT_ATTACK) && (player->rings <= 0) && (!player->instaWhipChargeLockout);
boolean releasedwhip = (!(cmd->buttons & BT_ATTACK)) && (player->rings <= 0 && player->instaWhipCharge) && !(P_PlayerInPain(player));
if (K_PowerUpRemaining(player, POWERUP_BADGE))
{
chargingwhip = false;
releasedwhip = (ATTACK_IS_DOWN && player->rings <= 0);
player->instaWhipCharge = INSTAWHIP_CHARGETIME;
player->instaWhipCooldown = 0;
}
if (leveltime < starttime || player->spindash || player->pflags & (PF_ITEMOUT|PF_EGGMANOUT) || player->rocketsneakertimer || player->instaWhipCooldown)
{
chargingwhip = false;
player->instaWhipCharge = 0;
}
if (chargingwhip)
{
player->instaWhipCharge = min(player->instaWhipCharge + 1, INSTAWHIP_TETHERBLOCK + 1);
if (player->instaWhipCharge == 1)
{
Obj_SpawnInstaWhipRecharge(player, 0);
Obj_SpawnInstaWhipRecharge(player, ANGLE_120);
Obj_SpawnInstaWhipRecharge(player, ANGLE_240);
}
if (player->instaWhipCharge == INSTAWHIP_CHARGETIME)
{
Obj_SpawnInstaWhipReject(player);
}
if (player->instaWhipCharge > INSTAWHIP_CHARGETIME)
{
if ((leveltime%(INSTAWHIP_RINGDRAINEVERY)) == 0 && !(gametyperules & GTR_SPHERES))
{
if (player->rings > -20 && P_IsDisplayPlayer(player))
S_StartSound(player->mo, sfx_antiri);
player->rings--;
}
}
}
else if (releasedwhip)
{
if (player->instaWhipCharge < INSTAWHIP_CHARGETIME)
{
S_StartSound(player->mo, sfx_kc50);
player->instaWhipCharge = 0;
}
else
{
player->instaWhipCharge = 0;
player->instaWhipCooldown = INSTAWHIP_COOLDOWN;
player->guardCooldown = INSTAWHIP_DROPGUARD;
if (!K_PowerUpRemaining(player, POWERUP_BARRIER))
{
player->guardCooldown = INSTAWHIP_CHARGETIME;
}
S_StartSound(player->mo, sfx_iwhp);
mobj_t *whip = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_INSTAWHIP);
P_SetTarget(&player->whip, whip);
P_SetScale(whip, player->mo->scale);
P_SetTarget(&whip->target, player->mo);
K_MatchGenericExtraFlags(whip, player->mo);
P_SpawnFakeShadow(whip, 20);
whip->fuse = INSTAWHIP_DURATION;
player->flashing = max(player->flashing, INSTAWHIP_DURATION);
if (P_IsObjectOnGround(player->mo))
{
whip->flags2 |= MF2_AMBUSH;
}
}
}
else if (!(player->instaWhipCharge >= INSTAWHIP_CHARGETIME && P_PlayerInPain(player))) // Allow reversal whip
player->instaWhipCharge = 0;
}
if (player && player->mo && player->mo->health > 0 && !player->spectator && !P_PlayerInPain(player) && !mapreset && leveltime > introtime)
{
// First, the really specific, finicky items that function without the item being directly in your item slot.
@ -10994,46 +11114,6 @@ void K_MoveKartPlayer(player_t *player, boolean onground)
// Ring boosting
if (player->pflags & PF_USERINGS)
{
if (ATTACK_IS_DOWN && player->rings <= 0)
{
if (player->instaShieldCooldown || leveltime < starttime || player->spindash)
{
S_StartSound(player->mo, sfx_kc50);
}
else
{
player->instaShieldCooldown = INSTAWHIP_COOLDOWN;
if (!K_PowerUpRemaining(player, POWERUP_BARRIER))
{
player->guardCooldown = INSTAWHIP_COOLDOWN;
}
S_StartSound(player->mo, sfx_iwhp);
mobj_t *whip = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_INSTAWHIP);
P_SetTarget(&player->whip, whip);
P_SetScale(whip, player->mo->scale);
P_SetTarget(&whip->target, player->mo);
K_MatchGenericExtraFlags(whip, player->mo);
P_SpawnFakeShadow(whip, 20);
whip->fuse = INSTAWHIP_DURATION;
player->flashing = max(player->flashing, INSTAWHIP_DURATION);
if (P_IsObjectOnGround(player->mo))
{
whip->flags2 |= MF2_AMBUSH;
}
if (!K_PowerUpRemaining(player, POWERUP_BADGE))
{
// Spawn in triangle formation
Obj_SpawnInstaWhipRecharge(player, 0);
Obj_SpawnInstaWhipRecharge(player, ANGLE_120);
Obj_SpawnInstaWhipRecharge(player, ANGLE_240);
}
}
}
if ((cmd->buttons & BT_ATTACK) && !player->ringdelay && player->rings > 0)
{
mobj_t *ring = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_RING);

View file

@ -30,10 +30,13 @@ Make sure this matches the actual number of states
#define SHRINK_PHYSICS_SCALE (3*FRACUNIT/4)
#define INSTAWHIP_DURATION (12)
#define INSTAWHIP_COOLDOWN (TICRATE*2)
#define INSTAWHIP_STARTOFRACE (255)
#define INSTAWHIP_STARTOFBATTLE (1)
#define INSTAWHIP_CHARGETIME (3*TICRATE/4)
#define INSTAWHIP_COOLDOWN (5*TICRATE/4)
#define INSTAWHIP_DROPGUARD (12)
#define INSTAWHIP_RINGDRAINEVERY (TICRATE/2)
#define INSTAWHIP_HOLD_DELAY (TICRATE*2)
// MUST be longer or equal to INSTAWHIP_CHARGETIME.
#define INSTAWHIP_TETHERBLOCK (TICRATE*4)
#define GUARDBREAK_COOLDOWN (TICRATE*4)
#define FLAMESHIELD_MAX (120)

View file

@ -118,6 +118,8 @@ boolean Obj_DropTargetMorphThink(mobj_t *morph);
void Obj_InstaWhipThink(mobj_t *whip);
void Obj_SpawnInstaWhipRecharge(player_t *player, angle_t angleOffset);
void Obj_InstaWhipRechargeThink(mobj_t *mobj);
void Obj_SpawnInstaWhipReject(player_t *player);
void Obj_InstaWhipRejectThink(mobj_t *mobj);
/* Block VFX */
void Obj_BlockRingThink(mobj_t *ring);

View file

@ -329,8 +329,10 @@ static int player_get(lua_State *L)
lua_pushinteger(L, plr->sliptideZipDelay);
else if (fastcmp(field,"sliptideZipBoost"))
lua_pushinteger(L, plr->sliptideZipBoost);
else if (fastcmp(field,"instaShieldCooldown"))
lua_pushinteger(L, plr->instaShieldCooldown);
else if (fastcmp(field,"instaWhipCharge"))
lua_pushinteger(L, plr->instaWhipCharge);
else if (fastcmp(field,"instaWhipCooldown"))
lua_pushinteger(L, plr->instaWhipCooldown);
else if (fastcmp(field,"guardCooldown"))
lua_pushinteger(L, plr->guardCooldown);
/*
@ -807,8 +809,10 @@ static int player_set(lua_State *L)
plr->sliptideZipDelay = luaL_checkinteger(L, 3);
else if (fastcmp(field,"sliptideZipBoost"))
plr->sliptideZipBoost = luaL_checkinteger(L, 3);
else if (fastcmp(field,"instaShieldCooldown"))
plr->instaShieldCooldown = luaL_checkinteger(L, 3);
else if (fastcmp(field,"instaWhipCharge"))
plr->instaWhipCharge = luaL_checkinteger(L, 3);
else if (fastcmp(field,"instaWhipCooldown"))
plr->instaWhipCharge = luaL_checkinteger(L, 3);
else if (fastcmp(field,"guardCooldown"))
plr->guardCooldown = luaL_checkinteger(L, 3);
/*

View file

@ -2,6 +2,7 @@
#include "../info.h"
#include "../k_objects.h"
#include "../p_local.h"
#include "../k_kart.h" // INSTAWHIP_COOLDOWN
#define recharge_target(o) ((o)->target)
#define recharge_offset(o) ((o)->movedir)
@ -49,7 +50,9 @@ void Obj_SpawnInstaWhipRecharge(player_t *player, angle_t angleOffset)
{
mobj_t *x = P_SpawnMobjFromMobj(player->mo, 0, 0, 0, MT_INSTAWHIP_RECHARGE);
x->tics = max(player->instaShieldCooldown - states[x->info->raisestate].tics, 0);
// This was previously used to delay the visual, back when this was VFX for a cooldown
// instead of VFX for a charge. We want to instantly bail out of that state now.
x->tics = 1;
x->renderflags |= RF_SLOPESPLAT | RF_NOSPLATBILLBOARD;
P_SetTarget(&recharge_target(x), player->mo);
@ -60,7 +63,7 @@ void Obj_InstaWhipRechargeThink(mobj_t *x)
{
mobj_t *target = recharge_target(x);
if (P_MobjWasRemoved(target))
if (P_MobjWasRemoved(target) || !target->player->instaWhipCharge)
{
P_RemoveMobj(x);
return;
@ -73,3 +76,25 @@ void Obj_InstaWhipRechargeThink(mobj_t *x)
// Flickers every other frame
x->renderflags ^= RF_DONTDRAW;
}
void Obj_SpawnInstaWhipReject(player_t *player)
{
mobj_t *x = P_SpawnMobjFromMobj(player->mo, 0, 0, 0, MT_INSTAWHIP_REJECT);
P_SetTarget(&recharge_target(x), player->mo);
}
void Obj_InstaWhipRejectThink(mobj_t *x)
{
mobj_t *target = x->target;
if (P_MobjWasRemoved(target) || !target->player->instaWhipCharge)
{
P_RemoveMobj(x);
return;
}
x->angle = x->target->angle;
P_MoveOrigin(x, target->x, target->y, target->z);
P_InstaScale(x, target->scale);
}

View file

@ -39,6 +39,7 @@ static const struct monitor_part_config {
#define monitor_emerald(o) ((o)->extravalue1)
#define monitor_damage(o) ((o)->extravalue2)
#define monitor_rammingspeed(o) ((o)->movefactor)
#define monitor_combohit(o) ((o)->cusval)
static inline UINT8
get_monitor_itemcount (const mobj_t *monitor)
@ -590,6 +591,11 @@ Obj_MonitorGetDamage
{
fixed_t damage;
if (leveltime - monitor_combohit(monitor) < 35) // Fast combo hits destroy monitors.
return FRACUNIT;
monitor_combohit(monitor) = leveltime;
switch (damagetype & DMG_TYPEMASK)
{
case DMG_VOLTAGE:

View file

@ -108,6 +108,7 @@ void P_RampConstant(const BasicFF_t *FFInfo, INT32 Start, INT32 End)
// GET STUFF
//
//
// P_CanPickupItem
//
@ -122,6 +123,10 @@ boolean P_CanPickupItem(player_t *player, UINT8 weapon)
// 1: Random Item / Capsule
// 2: Eggbox
// 3: Paperitem
if (weapon != 2 && player->instaWhipCharge)
return false;
if (weapon)
{
// Item slot already taken up
@ -438,6 +443,8 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
case KITEM_SUPERRING:
if (player->pflags & PF_RINGLOCK) // no cheaty rings
return;
if (player->instaWhipCharge)
return;
break;
default:
if (!P_CanPickupItem(player, 1))
@ -635,6 +642,10 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
if (player->pflags & PF_RINGLOCK)
return;
// Prepping instawhip? Don't ruin it by collecting rings
if (player->instaWhipCharge)
return;
// Don't immediately pick up spilled rings
if (special->threshold > 0 || P_PlayerInPain(player) || player->spindash) // player->spindash: Otherwise, players can pick up rings that are thrown out of them from invinc spindash penalty
return;

View file

@ -8463,6 +8463,16 @@ static boolean P_MobjRegularThink(mobj_t *mobj)
Obj_InstaWhipThink(mobj);
break;
}
case MT_INSTAWHIP_REJECT:
{
Obj_InstaWhipRejectThink(mobj);
if (P_MobjWasRemoved(mobj))
{
return false;
}
break;
}
case MT_BLOCKRING:
{
Obj_BlockRingThink(mobj);

View file

@ -404,6 +404,7 @@ struct mobj_t
// Custom values are not to be altered by us!
// They are for SOCs to store things in.
// (This rule is already broken by a bunch of shit so I'm just gonna believe in dreams - Tyron 2023-10-14)
INT32 cusval;
INT32 cvmem;

View file

@ -541,7 +541,8 @@ static void P_NetArchivePlayers(savebuffer_t *save)
WRITEMEM(save->p, players[i].public_key, PUBKEYLENGTH);
WRITEUINT8(save->p, players[i].instaShieldCooldown);
WRITEUINT8(save->p, players[i].instaWhipCharge);
WRITEUINT8(save->p, players[i].instaWhipCooldown);
WRITEUINT8(save->p, players[i].guardCooldown);
WRITEUINT8(save->p, players[i].handtimer);
@ -1051,7 +1052,8 @@ static void P_NetUnArchivePlayers(savebuffer_t *save)
READMEM(save->p, players[i].public_key, PUBKEYLENGTH);
players[i].instaShieldCooldown = READUINT8(save->p);
players[i].instaWhipCharge = READUINT8(save->p);
players[i].instaWhipCooldown = READUINT8(save->p);
players[i].guardCooldown = READUINT8(save->p);
players[i].handtimer = READUINT8(save->p);

View file

@ -23,7 +23,7 @@ INT32 R_ThingLightLevel(mobj_t* thing)
if (player)
{
if (player->instaShieldCooldown && !player->whip && (player->rings <= 0) && (leveltime & 1))
if ((player->instaWhipCharge || player->instaWhipCooldown) && !player->whip && (leveltime & 1))
{
// Darken on every other frame of instawhip cooldown
lightlevel -= 128;

View file

@ -1191,6 +1191,10 @@ sfxinfo_t S_sfx[NUMSFX] =
{"clawk1", false, 64, 16, -1, NULL, 0, -1, -1, LUMPERROR, ""}, // SF_X8AWAYSOUND
{"clawk2", false, 64, 16, -1, NULL, 0, -1, -1, LUMPERROR, ""}, // SF_X8AWAYSOUND
// SRB2Kart - whip charge/hold
{"wchrg1", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR, ""}, // SF_X2AWAYSOUND
{"wchrg2", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR, ""}, // SF_X2AWAYSOUND
{"horn00", false, 255, 0, -1, NULL, 0, -1, -1, LUMPERROR, "/"}, // HORNCODE
{"monch", false, 255, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""},
{"etexpl", false, 255, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Game crash"},

View file

@ -1261,6 +1261,9 @@ typedef enum
sfx_clawk1,
sfx_clawk2,
sfx_wchrg1,
sfx_wchrg2,
sfx_horn00,
sfx_monch,
sfx_etexpl,