Fuzzing monkey-input mode

This commit is contained in:
AJ Martinez 2023-08-27 16:57:39 -07:00
parent 2eb8180dd1
commit fa13e7d5bf
4 changed files with 20 additions and 0 deletions

View file

@ -838,6 +838,7 @@ consvar_t cv_palettenum = PlayerCheat("palettenum", "0").values(CV_Unsigned).onc
extern CV_PossibleValue_t renderhitbox_cons_t[];
consvar_t cv_renderhitbox = PlayerCheat("renderhitbox", "Off").values(renderhitbox_cons_t).description("Show hitboxes around objects");
consvar_t cv_fuzz = PlayerCheat("fuzz", "Off").on_off().description("Human players spam random inputs, get random items");
//
// Dummy variables used solely in the menu system.

View file

@ -37,6 +37,9 @@
#include "p_mobj.h"
#include "p_tick.h"
#include "tables.h"
#include "m_random.h" // monkey input
extern "C" consvar_t cv_fuzz;
namespace
{
@ -143,6 +146,14 @@ class TiccmdBuilder
cmd->turning = clamp(cmd->turning, KART_FULLTURN);
cmd->throwdir = clamp(cmd->throwdir, KART_FULLTURN);
if (cv_fuzz.value)
{
cmd->forwardmove = P_RandomRange(PR_FUZZ, -MAXPLMOVE, MAXPLMOVE);
cmd->turning = P_RandomRange(PR_FUZZ, -KART_FULLTURN, KART_FULLTURN);
cmd->throwdir = P_RandomRange(PR_FUZZ, -KART_FULLTURN, KART_FULLTURN);
cmd->buttons = P_RandomRange(PR_FUZZ, 0, 255);
}
// Send leveltime when this tic was generated to the server for control lag calculations.
// Only do this when in a level. Also do this after the hook, so that it can't overwrite this.
cmd->latency = (leveltime & TICCMD_LATENCYMASK);

View file

@ -8284,6 +8284,12 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd)
}
}
extern consvar_t cv_fuzz;
if (cv_fuzz.value && P_CanPickupItem(player, 1))
{
K_StartItemRoulette(player, P_RandomRange(PR_FUZZ, 0, 1));
}
if (player->instashield)
player->instashield--;

View file

@ -80,6 +80,8 @@ typedef enum
PR_AUTOROULETTE, // Item box accessibility
PR_FUZZ, // Stability testing
PRNUMCLASS
} pr_class_t;