From c6897688d011ee573f382d0247d39fc644f7f517 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sat, 23 Sep 2023 10:42:00 -0400 Subject: [PATCH] Delay ring burst after damage --- src/d_player.h | 1 + src/lua_playerlib.c | 4 ++++ src/p_inter.c | 3 +-- src/p_mobj.c | 8 ++++++++ src/p_saveg.c | 2 ++ src/sounds.c | 16 ++++++++-------- 6 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index b325137ea..b70a315ed 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -668,6 +668,7 @@ struct player_t UINT16 superring; // You were awarded rings, and have this many of them left to spawn on yourself. UINT8 nextringaward; // When should we spawn our next superring ring? UINT16 ringvolume; // When consuming lots of rings, lower the sound a little. + UINT16 ringburst; // Queued number of rings to lose after hitlag ends UINT8 curshield; // see kartshields_t UINT8 bubblecool; // Bubble Shield use cooldown diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index dca270903..c30d0d54d 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -361,6 +361,8 @@ static int player_get(lua_State *L) lua_pushinteger(L, plr->nextringaward); else if (fastcmp(field,"ringvolume")) lua_pushinteger(L, plr->ringvolume); + else if (fastcmp(field,"ringburst")) + lua_pushinteger(L, plr->ringburst); else if (fastcmp(field,"curshield")) lua_pushinteger(L, plr->curshield); else if (fastcmp(field,"bubblecool")) @@ -775,6 +777,8 @@ static int player_set(lua_State *L) plr->nextringaward = luaL_checkinteger(L, 3); else if (fastcmp(field,"ringvolume")) plr->ringvolume = luaL_checkinteger(L, 3); + else if (fastcmp(field,"ringburst")) + plr->ringburst = luaL_checkinteger(L, 3); else if (fastcmp(field,"curshield")) plr->curshield = luaL_checkinteger(L, 3); else if (fastcmp(field,"bubblecool")) diff --git a/src/p_inter.c b/src/p_inter.c index 2c29b0c19..fcf301f3c 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -2752,8 +2752,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da if (type != DMG_STING) player->flashing = K_GetKartFlashing(player); - //P_PlayRinglossSound(target); - P_PlayerRingBurst(player, ringburst); + player->ringburst += ringburst; K_PopPlayerShield(player); player->instashield = 15; diff --git a/src/p_mobj.c b/src/p_mobj.c index 599dd37e8..dc3dd037a 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10031,6 +10031,14 @@ void P_MobjThinker(mobj_t *mobj) if (mobj->player != NULL && mobj->hitlag == 0 && (mobj->eflags & MFE_DAMAGEHITLAG)) { + if (mobj->player->ringburst > 0) + { + // Delayed ring loss + P_PlayRinglossSound(mobj); + P_PlayerRingBurst(mobj->player, mobj->player->ringburst); + mobj->player->ringburst = 0; + } + K_HandleDirectionalInfluence(mobj->player); } diff --git a/src/p_saveg.c b/src/p_saveg.c index 21414f22c..6c61e7f6a 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -468,6 +468,7 @@ static void P_NetArchivePlayers(savebuffer_t *save) WRITEUINT16(save->p, players[i].superring); WRITEUINT8(save->p, players[i].nextringaward); WRITEUINT8(save->p, players[i].ringvolume); + WRITEUINT16(save->p, players[i].ringburst); WRITEUINT8(save->p, players[i].curshield); WRITEUINT8(save->p, players[i].bubblecool); @@ -946,6 +947,7 @@ static void P_NetUnArchivePlayers(savebuffer_t *save) players[i].superring = READUINT16(save->p); players[i].nextringaward = READUINT8(save->p); players[i].ringvolume = READUINT8(save->p); + players[i].ringburst = READUINT16(save->p); players[i].curshield = READUINT8(save->p); players[i].bubblecool = READUINT8(save->p); diff --git a/src/sounds.c b/src/sounds.c index 747331ff7..e802d0664 100644 --- a/src/sounds.c +++ b/src/sounds.c @@ -1211,14 +1211,14 @@ sfxinfo_t S_sfx[NUMSFX] = {"rank", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, // Rank slam // Damage sounds - {"dmga1", false, 64, 8, -1, NULL, 0, -1, -1, LUMPERROR, "Damaged"}, - {"dmga2", false, 64, 8, -1, NULL, 0, -1, -1, LUMPERROR, "Damaged"}, - {"dmga3", false, 64, 8, -1, NULL, 0, -1, -1, LUMPERROR, "Damaged"}, - {"dmga4", false, 64, 8, -1, NULL, 0, -1, -1, LUMPERROR, "Damaged"}, - {"dmgb1", false, 64, 8, -1, NULL, 0, -1, -1, LUMPERROR, "Damaged"}, - {"dmgb2", false, 64, 8, -1, NULL, 0, -1, -1, LUMPERROR, "Damaged"}, - {"dmgb3", false, 64, 8, -1, NULL, 0, -1, -1, LUMPERROR, "Damaged"}, - {"dmgb4", false, 64, 8, -1, NULL, 0, -1, -1, LUMPERROR, "Damaged"}, + {"dmga1", false, 255, 8, -1, NULL, 0, -1, -1, LUMPERROR, "Damaged"}, + {"dmga2", false, 255, 8, -1, NULL, 0, -1, -1, LUMPERROR, "Damaged"}, + {"dmga3", false, 255, 8, -1, NULL, 0, -1, -1, LUMPERROR, "Damaged"}, + {"dmga4", false, 255, 8, -1, NULL, 0, -1, -1, LUMPERROR, "Damaged"}, + {"dmgb1", false, 255, 8, -1, NULL, 0, -1, -1, LUMPERROR, "Damaged"}, + {"dmgb2", false, 255, 8, -1, NULL, 0, -1, -1, LUMPERROR, "Damaged"}, + {"dmgb3", false, 255, 8, -1, NULL, 0, -1, -1, LUMPERROR, "Damaged"}, + {"dmgb4", false, 255, 8, -1, NULL, 0, -1, -1, LUMPERROR, "Damaged"}, // SRB2Kart - Engine sounds // Engine class A