From 92bbd82c730384d9730539150660e4a5eeaa1c81 Mon Sep 17 00:00:00 2001 From: AJ Martinez Date: Mon, 5 Feb 2024 20:09:04 -0700 Subject: [PATCH] Add "Move Your Car" for antigrief --- src/d_clisrv.c | 1 + src/d_player.h | 1 + src/lua_playerlib.c | 4 ++++ src/p_saveg.c | 2 ++ src/p_user.c | 13 +++++++++++++ src/sounds.c | 5 +++++ src/sounds.h | 5 +++++ 7 files changed, 31 insertions(+) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index bef24f02a..483457cdb 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3068,6 +3068,7 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum) kickreason = KR_LEAVE; break; case KICK_MSG_GRIEF: + S_StartSound(NULL, sfx_cftbl1); HU_AddChatText(va("\x82*%s has been kicked (Automatic grief detection)", player_names[pnum]), false); kickreason = KR_KICK; break; diff --git a/src/d_player.h b/src/d_player.h index ab6a1d917..c938a94e6 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -923,6 +923,7 @@ struct player_t UINT32 griefValue; UINT8 griefStrikes; + boolean griefWarned; UINT8 typing_timer; // Counts down while keystrokes are not emitted UINT8 typing_duration; // How long since resumed timer diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index fe2291cab..6dd9aa3f8 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -641,6 +641,8 @@ static int player_get(lua_State *L) lua_pushinteger(L, plr->griefValue); else if (fastcmp(field,"griefStrikes")) lua_pushinteger(L, plr->griefStrikes); + else if (fastcmp(field,"griefWarned")) + lua_pushinteger(L, plr->griefWarned); else if (fastcmp(field,"splitscreenindex")) lua_pushinteger(L, plr->splitscreenindex); #ifdef HWRENDER @@ -1160,6 +1162,8 @@ static int player_set(lua_State *L) plr->griefValue = (UINT32)luaL_checkinteger(L, 3); else if (fastcmp(field,"griefStrikes")) plr->griefStrikes = (UINT8)luaL_checkinteger(L, 3); + else if (fastcmp(field,"griefWarned")) + plr->griefWarned = luaL_checkinteger(L, 3); else if (fastcmp(field,"splitscreenindex")) return NOSET; #ifdef HWRENDER diff --git a/src/p_saveg.c b/src/p_saveg.c index 6a4fe39aa..008ba535f 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -296,6 +296,7 @@ static void P_NetArchivePlayers(savebuffer_t *save) WRITEUINT32(save->p, players[i].spectatorReentry); WRITEUINT32(save->p, players[i].griefValue); WRITEUINT8(save->p, players[i].griefStrikes); + WRITEUINT8(save->p, players[i].griefWarned); WRITEUINT8(save->p, players[i].splitscreenindex); @@ -914,6 +915,7 @@ static void P_NetUnArchivePlayers(savebuffer_t *save) players[i].spectatorReentry = READUINT32(save->p); players[i].griefValue = READUINT32(save->p); players[i].griefStrikes = READUINT8(save->p); + players[i].griefWarned = READUINT8(save->p); players[i].splitscreenindex = READUINT8(save->p); diff --git a/src/p_user.c b/src/p_user.c index ca7f8cc2b..9c02e6c64 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -69,6 +69,7 @@ #include "k_objects.h" #include "k_endcam.h" #include "k_credits.h" +#include "k_hud.h" // K_AddMessage #ifdef HWRENDER #include "hardware/hw_light.h" @@ -4633,6 +4634,9 @@ void P_IncrementGriefValue(player_t *player, UINT32 *grief, const UINT32 griefMa { // Playing normally. *grief = *grief - 1; + + if (*grief == 0) + player->griefWarned = false; } } @@ -4650,6 +4654,14 @@ void P_CheckRaceGriefing(player_t *player, boolean dopunishment) P_IncrementGriefValue(player, &player->griefValue, griefMax); + if (dopunishment && !player->griefWarned && player->griefValue >= (griefMax/2)) + { + K_AddMessageForPlayer(player, "Get moving!", true, false); + if (P_IsLocalPlayer(player)) + S_StartSound(NULL, sfx_cftbl0); + player->griefWarned = true; + } + if (dopunishment && player->griefValue >= griefMax) { if (player->griefStrikes < 3) @@ -4658,6 +4670,7 @@ void P_CheckRaceGriefing(player_t *player, boolean dopunishment) } player->griefValue = 0; + player->griefWarned = false; if (server) { diff --git a/src/sounds.c b/src/sounds.c index 828f67242..4640f48f2 100644 --- a/src/sounds.c +++ b/src/sounds.c @@ -1492,6 +1492,11 @@ sfxinfo_t S_sfx[NUMSFX] = {"gshf0", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, {"gshf1", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + // Pinball + {"cftbl0", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cftbl1", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cftbl2", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + // SRB2kart - Skin sounds {"kwin", false, 64, 96, -1, NULL, 0, SKSKWIN, -1, LUMPERROR, ""}, {"klose", false, 64, 96, -1, NULL, 0, SKSKLOSE, -1, LUMPERROR, ""}, diff --git a/src/sounds.h b/src/sounds.h index bfbd06887..55dda062f 100644 --- a/src/sounds.h +++ b/src/sounds.h @@ -1566,6 +1566,11 @@ typedef enum sfx_gshf0, sfx_gshf1, + // Pinball + sfx_cftbl0, + sfx_cftbl1, + sfx_cftbl2, + // And LASTLY, Kart's skin sounds. sfx_kwin, sfx_klose,