From b6e935e51daf4222fd2893515bee8c7bcdf8482e Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sun, 2 Jan 2022 21:42:20 -0500 Subject: [PATCH] Add required speed percent --- src/k_terrain.c | 24 +++++++++++++++++++++++- src/k_terrain.h | 2 ++ src/lua_mobjlib.c | 3 --- src/lua_playerlib.c | 5 +---- 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/k_terrain.c b/src/k_terrain.c index 8c7a0643d..323e55734 100644 --- a/src/k_terrain.c +++ b/src/k_terrain.c @@ -618,16 +618,29 @@ static void K_SpawnFootstepParticle(mobj_t *mo, t_footstep_t *fs) angle_t pushAngle = ANGLE_MAX; angle_t tireAngle = ANGLE_MAX; fixed_t momentum = INT32_MAX; + fixed_t speedValue = INT32_MAX; fixed_t momH = INT32_MAX; fixed_t momV = INT32_MAX; + momentum = P_AproxDistance(mo->momx, mo->momy); + if (mo->player != NULL) { tireAngle = (mo->player->drawangle + ANGLE_180); + speedValue = K_GetKartSpeedFromStat(mo->player->kartspeed); } else { tireAngle = (mo->angle + ANGLE_180); + speedValue = K_GetKartSpeedFromStat(5); + } + + speedValue = FixedMul(speedValue, mo->scale); + speedValue = FixedMul(speedValue, fs->requiredSpeed); + + if (momentum < speedValue) + { + return; } pushAngle = K_MomentumAngle(mo) + ANGLE_180; @@ -662,7 +675,6 @@ static void K_SpawnFootstepParticle(mobj_t *mo, t_footstep_t *fs) dust->momy = mo->momy; dust->momz = P_GetMobjZMovement(mo) / 2; - momentum = P_AproxDistance(mo->momx, mo->momy); momH = FixedMul(momentum, fs->pushH); momV = FixedMul(momentum, fs->pushV); @@ -872,6 +884,8 @@ static void K_FootstepDefaults(t_footstep_t *footstep) footstep->cone = ANGLE_11hh; footstep->sfxFreq = 6; + footstep->frequency = 1; + footstep->requiredSpeed = 0; } /*-------------------------------------------------- @@ -946,6 +960,14 @@ static void K_ParseFootstepParameter(size_t i, char *param, char *val) { footstep->sfxFreq = (tic_t)atoi(val); } + else if (stricmp(param, "frequency") == 0) + { + footstep->frequency = (tic_t)atoi(val); + } + else if (stricmp(param, "requiredSpeed") == 0) + { + footstep->requiredSpeed = FLOAT_TO_FIXED(atof(val)); + } } /*-------------------------------------------------- diff --git a/src/k_terrain.h b/src/k_terrain.h index e4055be23..924f7a1b1 100644 --- a/src/k_terrain.h +++ b/src/k_terrain.h @@ -60,6 +60,8 @@ typedef struct t_footstep_s angle_t cone; // Randomized angle of the push-out. tic_t sfxFreq; // How frequently to play the sound. + tic_t frequency; // How frequently to spawn the particles. + fixed_t requiredSpeed; // Speed percentage you need to be at to trigger the particles. } t_footstep_t; typedef enum diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 8a4a1e7a5..4c2a4f24d 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -494,9 +494,6 @@ static int mobj_set(lua_State *L) if (hook_cmd_running) return luaL_error(L, "Do not alter mobj_t in CMD building code!"); - if (hook_cmd_running) - return luaL_error(L, "Do not alter mobj_t in BuildCMD code!"); - switch(field) { case mobj_valid: diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index 23e2e2b67..17e1a39b1 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -499,9 +499,6 @@ static int player_set(lua_State *L) if (hook_cmd_running) return luaL_error(L, "Do not alter player_t in CMD building code!"); - if (hook_cmd_running) - return luaL_error(L, "Do not alter player_t in BuildCMD code!"); - if (fastcmp(field,"mo")) { mobj_t *newmo = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ)); plr->mo->player = NULL; // remove player pointer from old mobj @@ -861,7 +858,7 @@ static int karthud_set(lua_State *L) if (hud_running) return luaL_error(L, "Do not alter player_t in HUD rendering code!"); if (hook_cmd_running) - return luaL_error(L, "Do not alter player_t in BuildCMD code!"); + return luaL_error(L, "Do not alter player_t in CMD building code!"); karthud[ks] = i; return 0; }