From 30b7fc2f2ba748ce34dea42efc58d23ebe473f1b Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 5 Oct 2024 08:26:06 +0200 Subject: [PATCH] make function for quakes, scale with mobjscale --- src/doomstat.h | 2 +- src/k_kart.c | 3 +-- src/lua_baselib.c | 8 +++----- src/p_inter.c | 3 +-- src/p_spec.c | 33 ++++++++++++++++++++++++++------- src/p_spec.h | 2 ++ 6 files changed, 34 insertions(+), 17 deletions(-) diff --git a/src/doomstat.h b/src/doomstat.h index fad4d4521..ccf69e1cc 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -192,7 +192,7 @@ extern struct quake // camera offsets and duration fixed_t x,y,z; angle_t roll; - UINT16 time; + tic_t time; // location, radius, and intensity... mappoint_t *epicenter; diff --git a/src/k_kart.c b/src/k_kart.c index 1e8d381d2..608a43e09 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -2712,8 +2712,7 @@ void K_ExplodePlayer(player_t *player, mobj_t *source, mobj_t *inflictor) // A b if (P_IsLocalPlayer(player)) { - quake.intensity = 64*FRACUNIT; - quake.time = 5; + P_StartQuake(5, 64<kartstuff[k_instashield] = 15; diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 185055e7f..e040a0cd7 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -1559,8 +1559,9 @@ static int lib_pSetSkyboxMobj(lua_State *L) // Shhh, neither does P_StartQuake. static int lib_pStartQuake(lua_State *L) { + tic_t q_time = (tic_t)luaL_checkinteger(L, 2); fixed_t q_intensity = luaL_checkinteger(L, 1); - UINT16 q_time = (UINT16)luaL_checkinteger(L, 2); + fixed_t q_radius = luaL_optinteger(L, 4, 512<sidenum[0]].textureoffset; - quake.radius = sides[line->sidenum[0]].rowoffset; - quake.time = P_AproxDistance(line->dx, line->dy)>>FRACBITS; + fixed_t intensity = sides[line->sidenum[0]].textureoffset; + fixed_t radius = sides[line->sidenum[0]].rowoffset; + tic_t time = P_AproxDistance(line->dx, line->dy)>>FRACBITS; quake.epicenter = NULL; /// \todo // reasonable defaults. - if (!quake.intensity) - quake.intensity = 8< 0) + { + quake.radius = FixedMul(radius, mapobjectscale); + } +} + static void P_SearchForDisableLinedefs(void) { size_t i; diff --git a/src/p_spec.h b/src/p_spec.h index 477dd4950..7612ac657 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -454,4 +454,6 @@ void P_CalcHeight(player_t *player); sector_t *P_ThingOnSpecial3DFloor(mobj_t *mo); +void P_StartQuake(tic_t time, fixed_t intensity, fixed_t radius); + #endif