From 1a5f0d94f3379ed2c07e83190c140cd3246359bf Mon Sep 17 00:00:00 2001 From: Radicalicious Date: Sat, 1 May 2021 14:05:01 -0400 Subject: [PATCH 1/3] Expose P_ThrustEvenIn2D and P_VectorInstaThrust --- src/p_user.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index c5f919c78..6a879c785 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -104,8 +104,7 @@ void P_Thrust(mobj_t *mo, angle_t angle, fixed_t move) mo->momy += FixedMul(move, FINESINE(angle)); } -#if 0 -static inline void P_ThrustEvenIn2D(mobj_t *mo, angle_t angle, fixed_t move) +void P_ThrustEvenIn2D(mobj_t *mo, angle_t angle, fixed_t move) { angle >>= ANGLETOFINESHIFT; @@ -113,7 +112,7 @@ static inline void P_ThrustEvenIn2D(mobj_t *mo, angle_t angle, fixed_t move) mo->momy += FixedMul(move, FINESINE(angle)); } -static inline void P_VectorInstaThrust(fixed_t xa, fixed_t xb, fixed_t xc, fixed_t ya, fixed_t yb, fixed_t yc, +void P_VectorInstaThrust(fixed_t xa, fixed_t xb, fixed_t xc, fixed_t ya, fixed_t yb, fixed_t yc, fixed_t za, fixed_t zb, fixed_t zc, fixed_t momentum, mobj_t *mo) { fixed_t a1, b1, c1, a2, b2, c2, i, j, k; @@ -143,7 +142,6 @@ static inline void P_VectorInstaThrust(fixed_t xa, fixed_t xb, fixed_t xc, fixed mo->momy = j; mo->momz = k; } -#endif // // P_InstaThrust From 47a2710ec292b551ce559813863611ef1805c3f7 Mon Sep 17 00:00:00 2001 From: Radicalicious Date: Sat, 1 May 2021 14:05:07 -0400 Subject: [PATCH 2/3] Expose P_ThrustEvenIn2D, P_InstaThrustEvenIn2D, and P_VectorInstaThrust to Lua --- src/lua_baselib.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 4667fdbf4..64c5967b8 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -1514,6 +1514,19 @@ static int lib_pInstaThrust(lua_State *L) return 0; } +static int lib_pInstaThrustEvenIn2D(lua_State *L) +{ + mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + angle_t angle = luaL_checkangle(L, 2); + fixed_t move = luaL_checkfixed(L, 3); + NOHUD + INLEVEL + if (!mo) + return LUA_ErrInvalid(L, "mobj_t"); + P_InstaThrustEvenIn2D(mo, angle, move); + return 0; +} + static int lib_pReturnThrustX(lua_State *L) { angle_t angle; @@ -2075,6 +2088,40 @@ static int lib_pThrust(lua_State *L) return 0; } +static int lib_pThrustEvenIn2D(lua_State *L) +{ + mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + angle_t angle = luaL_checkangle(L, 2); + fixed_t move = luaL_checkfixed(L, 3); + NOHUD + INLEVEL + if (!mo) + return LUA_ErrInvalid(L, "mobj_t"); + P_ThrustEvenIn2D(mo, angle, move); + return 0; +} + +static int lib_pVectorInstaThrust(lua_State *L) +{ + fixed_t xa = luaL_checkfixed(L, 1); + fixed_t xb = luaL_checkfixed(L, 2); + fixed_t xc = luaL_checkfixed(L, 3); + fixed_t ya = luaL_checkfixed(L, 4); + fixed_t yb = luaL_checkfixed(L, 5); + fixed_t yc = luaL_checkfixed(L, 6); + fixed_t za = luaL_checkfixed(L, 7); + fixed_t zb = luaL_checkfixed(L, 8); + fixed_t zc = luaL_checkfixed(L, 9); + fixed_t momentum = luaL_checkfixed(L, 10); + mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 11, META_MOBJ)); + NOHUD + INLEVEL + if (!mo) + return LUA_ErrInvalid(L, "mobj_t"); + P_VectorInstaThrust(xa, xb, xc, ya, yb, yc, za, zb, zc, momentum, mo); + return 0; +} + static int lib_pSetMobjStateNF(lua_State *L) { mobj_t *mobj = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); @@ -3853,6 +3900,7 @@ static luaL_Reg lib[] = { {"P_DoPlayerFinish",lib_pDoPlayerFinish}, {"P_DoPlayerExit",lib_pDoPlayerExit}, {"P_InstaThrust",lib_pInstaThrust}, + {"P_InstaThrustEvenIn2D",lib_pInstaThrustEvenIn2D}, {"P_ReturnThrustX",lib_pReturnThrustX}, {"P_ReturnThrustY",lib_pReturnThrustY}, {"P_LookForEnemies",lib_pLookForEnemies}, @@ -3900,6 +3948,8 @@ static luaL_Reg lib[] = { // p_spec {"P_Thrust",lib_pThrust}, + {"P_ThrustEvenIn2D",lib_pThrustEvenIn2D}, + {"P_VectorInstaThrust",lib_pVectorInstaThrust}, {"P_SetMobjStateNF",lib_pSetMobjStateNF}, {"P_DoSuperTransformation",lib_pDoSuperTransformation}, {"P_ExplodeMissile",lib_pExplodeMissile}, From e16a8946807349c5b308e422aaf09a1f29b8252b Mon Sep 17 00:00:00 2001 From: Radicalicious Date: Sat, 1 May 2021 20:47:01 -0400 Subject: [PATCH 3/3] Actually define newly exposed thrust functions. Oops. --- src/p_local.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/p_local.h b/src/p_local.h index 8a5084962..ab6ef0177 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -527,6 +527,9 @@ boolean P_Teleport(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle boolean P_SetMobjStateNF(mobj_t *mobj, statenum_t state); boolean P_CheckMissileSpawn(mobj_t *th); void P_Thrust(mobj_t *mo, angle_t angle, fixed_t move); +void P_ThrustEvenIn2D(mobj_t *mo, angle_t angle, fixed_t move); +void P_VectorInstaThrust(fixed_t xa, fixed_t xb, fixed_t xc, fixed_t ya, fixed_t yb, fixed_t yc, + fixed_t za, fixed_t zb, fixed_t zc, fixed_t momentum, mobj_t *mo); void P_DoSuperTransformation(player_t *player, boolean giverings); void P_ExplodeMissile(mobj_t *mo); void P_CheckGravity(mobj_t *mo, boolean affect);