stacking pt.4: Finish Chaining

Again thanks to Indev for helping me figure out why the last tick wouldn't deincrement
This commit is contained in:
NepDisk 2025-03-25 19:13:06 -04:00
parent f0b6ef89eb
commit 0ae44e0fa0
3 changed files with 47 additions and 6 deletions

View file

@ -5273,7 +5273,11 @@ void K_DoSneaker(player_t *player, INT32 type)
}
player->sneakertimer = sneakertime;
player->numsneakers = CLAMP(player->numsneakers+1, 0, stackingactive ? MAXSNEAKERSTACK : 1);
if (player->sneakertimer && (player->floorboost == 0 || player->floorboost == 3))
{
player->numsneakers = CLAMP(player->numsneakers+1, 0, stackingactive ? MAXSNEAKERSTACK : 1);
}
// set angle for spun out players:
player->boostangle = player->mo->angle;
@ -5294,7 +5298,12 @@ void K_DoWaterRunPanel(player_t *player)
K_SneakerPanelEffect(player, 0);
player->sneakertimer = TICRATE*2;
player->numsneakers = CLAMP(player->numsneakers+1, 0, stackingactive ? MAXSNEAKERSTACK : 1);
if (player->sneakertimer && (player->floorboost == 0 || player->floorboost == 3))
{
player->numsneakers = CLAMP(player->numsneakers+1, 0, stackingactive ? MAXSNEAKERSTACK : 1);
}
player->mo->flags2 |= MF2_WATERRUN;
// set angle for spun out players:
@ -7034,14 +7043,16 @@ boolean K_BoostChain(player_t *player, INT32 timer)
INT32 K_ChainOrDeincrementTime(player_t *player, INT32 timer, INT32 deincrement)
{
timer -= deincrement;
if (K_BoostChain(player, timer))
{
// Its time to chain.
return max(1, timer - deincrement);
return max(1, timer);
}
// Continue to drain the timer as normal.
return timer - deincrement;
return timer;
}
// Get the tic inverse sum using kartspeed, kartweight and your number of boosts.
@ -7096,11 +7107,11 @@ static void K_HandleRingDeincrement(player_t *player, boolean chainnerf)
subring = (player->ringboost*4)/insum;
}
finalringtimer -= subring;
finalringtimer += subring;
}
}
player->ringboost = K_ChainOrDeincrementTime(player, player->ringboost, finalringtimer);
player->ringboost = max(0, K_ChainOrDeincrementTime(player, player->ringboost, finalringtimer));
}
/** \brief Decreases various kart timers and powers per frame. Called in P_PlayerThink in p_user.c

View file

@ -196,6 +196,8 @@ boolean K_SafeRespawnPosition(mobj_t * mo);
boolean K_RingsActive(void);
boolean K_StackingActive(void);
boolean K_ChainingActive(void);
boolean K_BoostChain(player_t *player, INT32 timer);
INT32 K_ChainOrDeincrementTime(player_t *player, INT32 timer, INT32 deincrement);
boolean K_UsingLegacyCheckpoints(void);
void K_UpdateMobjItemOverlay(mobj_t *part, SINT8 itemType, UINT8 itemCount);

View file

@ -4032,6 +4032,31 @@ static int lib_kClearBoost(lua_State *L)
return 0;
}
static int lib_kBoostChain(lua_State *L)
{
player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
INT32 timer = luaL_checkinteger(L, 2);
//HUDSAFE
if (!player)
return LUA_ErrInvalid(L, "player_t");
lua_pushboolean(L, K_BoostChain(player, timer));
return 1;
}
static int lib_kChainOrDeincrementTime(lua_State *L)
{
player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
INT32 timer = luaL_checkinteger(L, 2);
INT32 deincrement = luaL_checkinteger(L, 3);
//HUDSAFE
if (!player)
return LUA_ErrInvalid(L, "player_t");
lua_pushinteger(L, K_ChainOrDeincrementTime(player, timer, deincrement));
return 1;
}
static int lib_getTimeMicros(lua_State *L)
{
lua_pushinteger(L, I_GetPreciseTime() / (I_GetPrecisePrecision() / 1000000));
@ -4336,6 +4361,9 @@ static luaL_Reg lib[] = {
{"K_UsingLegacyCheckpoints",lib_kUsingLegacyCheckpoints},
{"K_DoBoost",lib_kDoBoost},
{"K_ClearBoost",lib_kClearBoost},
{"K_BoostChain",lib_kBoostChain},
{"K_ChainOrDeincrementTime",lib_kChainOrDeincrementTime},
// k_boss
{"K_InitBossHealthBar", lib_kInitBossHealthBar},