From f2ee8783dd1d35e2475eebad0d28f7dfcc2826f9 Mon Sep 17 00:00:00 2001 From: JugadorXEI Date: Tue, 5 Aug 2025 23:47:55 +0200 Subject: [PATCH 01/34] Lua: Allow angle to be set and fix userdata type for K_FindJawzTarget --- src/lua_baselib.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index aa84c76d0..9d2d015a7 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -4175,12 +4175,13 @@ static int lib_kFindJawzTarget(lua_State *L) { mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); player_t *source = *((player_t **)luaL_checkudata(L, 2, META_PLAYER)); - //HUDSAFE + angle_t angle = luaL_checkangle(L, 3); + INLEVEL if (!actor) return LUA_ErrInvalid(L, "mobj_t"); if (!source) return LUA_ErrInvalid(L, "player_t"); - LUA_PushUserdata(L, K_FindJawzTarget(actor, source, ANGLE_45), META_PLAYER); + LUA_PushUserdata(L, K_FindJawzTarget(actor, source, angle), META_MOBJ); return 1; } From 107142f4931fe1005c4c8add0a4e286b37869573 Mon Sep 17 00:00:00 2001 From: JugadorXEI Date: Fri, 22 Aug 2025 08:39:37 +0200 Subject: [PATCH 02/34] Expose K_KartSolidBounce to Lua --- src/lua_baselib.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 9d2d015a7..06be93703 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -3713,6 +3713,20 @@ static int lib_kFlipFromObject(lua_State *L) return 0; } +static int lib_kKartSolidBounce(lua_State *L) +{ + mobj_t *bounceMobj = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + mobj_t *solidMobj = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ)); + NOHUD + INLEVEL + if (!bounceMobj) + return LUA_ErrInvalid(L, "mobj_t"); + if (!solidMobj) + return LUA_ErrInvalid(L, "mobj_t"); + lua_pushboolean(L, K_KartSolidBounce(bounceMobj, solidMobj)); + return 1; +} + static int lib_kMatchGenericExtraFlags(lua_State *L) { mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); @@ -5446,6 +5460,7 @@ static luaL_Reg lib[] = { {"K_KartBouncing",lib_kKartBouncing}, {"K_KartPainEnergyFling",lib_kKartPainEnergyFling}, {"K_FlipFromObject",lib_kFlipFromObject}, + {"K_KartSolidBounce",lib_kKartSolidBounce}, {"K_MatchGenericExtraFlags",lib_kMatchGenericExtraFlags}, {"K_SpawnDashDustRelease",lib_kSpawnDashDustRelease}, {"K_SpawnDriftBoostClip",lib_kSpawnDriftBoostClip}, From 2027ccd8da8f44b66811aab82fa62c1ffd3e049e Mon Sep 17 00:00:00 2001 From: JugadorXEI Date: Fri, 22 Aug 2025 08:42:05 +0200 Subject: [PATCH 03/34] Expose K_AwardPlayerRings to Lua --- src/lua_baselib.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 06be93703..e1465f4d7 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -3751,6 +3751,20 @@ static int lib_kSpawnDashDustRelease(lua_State *L) return 0; } +static int lib_kAwardPlayerRings(lua_State *L) +{ + player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + UINT16 rings = luaL_checkinteger(L, 2); + boolean overload = lua_opttrueboolean(L, 3); + NOHUD + INLEVEL + if (!player) + return LUA_ErrInvalid(L, "player_t"); + + K_AwardPlayerRings(player, rings, overload); + return 0; +} + static int lib_kSpawnDriftBoostClip(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); @@ -5474,6 +5488,7 @@ static luaL_Reg lib[] = { {"K_MomentumAngleEx",lib_kMomentumAngleEx}, {"K_MomentumAngleReal",lib_kMomentumAngleReal}, {"K_MomentumAngle",lib_kMomentumAngle}, + {"K_AwardPlayerRings",lib_kAwardPlayerRings}, {"K_DoInstashield",lib_kDoInstashield}, {"K_SpawnBattlePoints",lib_kSpawnBattlePoints}, {"K_RemoveGrowShrink",lib_kRemoveGrowShrink}, From f73697ad0ab5e8051c7681827ca909b2750628de Mon Sep 17 00:00:00 2001 From: JugadorXEI Date: Tue, 5 Aug 2025 19:05:00 +0200 Subject: [PATCH 04/34] Expose K_DoPowerClash to Lua --- src/lua_baselib.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index e1465f4d7..2dde5580f 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -3895,6 +3895,18 @@ static int lib_kDoInstashield(lua_State *L) return 0; } +static int lib_kDoPowerClash(lua_State *L) +{ + mobj_t *t1 = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + mobj_t *t2 = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ)); + NOHUD + INLEVEL + if (!t1 || !t2) + return LUA_ErrInvalid(L, "mobj_t"); + K_DoPowerClash(t1, t2); + return 0; +} + static int lib_kSpawnBattlePoints(lua_State *L) { player_t *source = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); @@ -5490,6 +5502,7 @@ static luaL_Reg lib[] = { {"K_MomentumAngle",lib_kMomentumAngle}, {"K_AwardPlayerRings",lib_kAwardPlayerRings}, {"K_DoInstashield",lib_kDoInstashield}, + {"K_DoPowerClash",lib_kDoPowerClash}, {"K_SpawnBattlePoints",lib_kSpawnBattlePoints}, {"K_RemoveGrowShrink",lib_kRemoveGrowShrink}, {"K_IsBigger",lib_kIsBigger}, From e313411e7b04002bcbcd3fd8a826d1274be3d16c Mon Sep 17 00:00:00 2001 From: JugadorXEI Date: Fri, 22 Aug 2025 08:44:17 +0200 Subject: [PATCH 05/34] Expose K_CreatePaperItem to Lua --- src/lua_baselib.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 2dde5580f..59e2c40eb 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -4303,6 +4303,21 @@ static int lib_kDropPaperItem(lua_State *L) return 0; } +static int lib_kCreatePaperItem(lua_State *L) +{ + fixed_t x = luaL_checkfixed(L, 1); + fixed_t y = luaL_checkfixed(L, 2); + fixed_t z = luaL_checkfixed(L, 3); + angle_t angle = luaL_optinteger(L, 4, 0); + SINT8 flip = luaL_optinteger(L, 5, 0); + UINT8 type = luaL_optinteger(L, 6, 0); + UINT16 amount = luaL_optinteger(L, 7, 1); + NOHUD + INLEVEL + LUA_PushUserdata(L, K_CreatePaperItem(x, y, z, angle, flip, type, amount), META_MOBJ); + return 1; +} + static int lib_kPopPlayerShield(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); @@ -5536,6 +5551,7 @@ static luaL_Reg lib[] = { {"K_SpawnDriftElectricSparks",lib_kSpawnDriftElectricSparks}, {"K_KartUpdatePosition",lib_kKartUpdatePosition}, {"K_DropPaperItem",lib_kDropPaperItem}, + {"K_CreatePaperItem",lib_kCreatePaperItem}, {"K_PopPlayerShield",lib_kPopPlayerShield}, {"K_DropHnextList",lib_kDropHnextList}, {"K_DropItems",lib_kDropItems}, From 3bbdab552809759951dcc8760cb348fa9fc5c1f5 Mon Sep 17 00:00:00 2001 From: JugadorXEI Date: Tue, 5 Aug 2025 23:00:54 +0200 Subject: [PATCH 06/34] Expose K_FlingPaperItem to Lua --- src/lua_baselib.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 59e2c40eb..6e5a13726 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -4318,6 +4318,21 @@ static int lib_kCreatePaperItem(lua_State *L) return 1; } +static int lib_kFlingPaperItem(lua_State *L) +{ + fixed_t x = luaL_checkfixed(L, 1); + fixed_t y = luaL_checkfixed(L, 2); + fixed_t z = luaL_checkfixed(L, 3); + angle_t angle = luaL_optinteger(L, 4, 0); + SINT8 flip = luaL_optinteger(L, 5, 0); + UINT8 type = luaL_optinteger(L, 6, 0); + UINT16 amount = luaL_optinteger(L, 7, 1); + NOHUD + INLEVEL + LUA_PushUserdata(L, K_FlingPaperItem(x, y, z, angle, flip, type, amount), META_MOBJ); + return 1; +} + static int lib_kPopPlayerShield(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); @@ -5552,6 +5567,7 @@ static luaL_Reg lib[] = { {"K_KartUpdatePosition",lib_kKartUpdatePosition}, {"K_DropPaperItem",lib_kDropPaperItem}, {"K_CreatePaperItem",lib_kCreatePaperItem}, + {"K_FlingPaperItem",lib_kFlingPaperItem}, {"K_PopPlayerShield",lib_kPopPlayerShield}, {"K_DropHnextList",lib_kDropHnextList}, {"K_DropItems",lib_kDropItems}, From f53ae302cf38aa36b4ee7580aa9189847d017a87 Mon Sep 17 00:00:00 2001 From: JugadorXEI Date: Fri, 22 Aug 2025 08:47:42 +0200 Subject: [PATCH 07/34] Expose K_PlayerGuard to Lua --- src/lua_baselib.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 6e5a13726..ea386deaa 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -4715,6 +4715,16 @@ static int lib_kPlayerEBrake(lua_State *L) return 1; } +static int lib_kPlayerGuard(lua_State *L) +{ + player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + INLEVEL + if (!player) + return LUA_ErrInvalid(L, "player_t"); + lua_pushboolean(L, K_PlayerGuard(player)); + return 1; +} + static int lib_kSliptiding(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); @@ -5623,6 +5633,7 @@ static luaL_Reg lib[] = { {"K_BumperInflate",lib_kBumperInflate}, {"K_ThunderDome",lib_kThunderDome}, {"K_PlayerCanUseItem",lib_kPlayerCanUseItem}, + {"K_PlayerGuard",lib_kPlayerGuard}, {"K_GetCollideAngle",lib_kGetCollideAngle}, {"K_AddHitLag",lib_kAddHitLag}, From 607e6cd39db1b49f05cafb12db60be730fa38abb Mon Sep 17 00:00:00 2001 From: JugadorXEI Date: Fri, 22 Aug 2025 08:48:29 +0200 Subject: [PATCH 08/34] Expose K_SetTireGrease to Lua --- src/lua_baselib.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index ea386deaa..f9a7a9a33 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -4885,6 +4885,18 @@ static int lib_kPlayerCanUseItem(lua_State *L) return 1; } +static int lib_kSetTireGrease(lua_State *L) +{ + player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + tic_t tics = luaL_checkinteger(L, 2); + INLEVEL + NOHUD + if (!player) + return LUA_ErrInvalid(L, "player_t"); + K_SetTireGrease(player, tics); + return 0; +} + static int lib_kGetCollideAngle(lua_State *L) { mobj_t *t1 = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); @@ -5634,6 +5646,7 @@ static luaL_Reg lib[] = { {"K_ThunderDome",lib_kThunderDome}, {"K_PlayerCanUseItem",lib_kPlayerCanUseItem}, {"K_PlayerGuard",lib_kPlayerGuard}, + {"K_SetTireGrease",lib_kSetTireGrease}, {"K_GetCollideAngle",lib_kGetCollideAngle}, {"K_AddHitLag",lib_kAddHitLag}, From 6fb9a98896b2a2ec32ac836d27551d6e21bf6e60 Mon Sep 17 00:00:00 2001 From: JugadorXEI Date: Fri, 22 Aug 2025 08:50:03 +0200 Subject: [PATCH 09/34] Expose K_PlayerJustBumped to Lua --- src/k_kart.c | 2 +- src/k_kart.h | 1 + src/lua_baselib.c | 12 ++++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index 729a30848..e30e99399 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -815,7 +815,7 @@ static void K_SpawnBumpForObjs(mobj_t *mobj1, mobj_t *mobj2) } } -static void K_PlayerJustBumped(player_t *player) +void K_PlayerJustBumped(player_t *player) { mobj_t *playerMobj = NULL; diff --git a/src/k_kart.h b/src/k_kart.h index ab0c8d794..a21f8695d 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -107,6 +107,7 @@ boolean K_TimeAttackRules(void); boolean K_CapsuleTimeAttackRules(void); fixed_t K_GetMobjWeight(mobj_t *mobj, mobj_t *against); +void K_PlayerJustBumped(player_t *player); boolean K_KartBouncing(mobj_t *mobj1, mobj_t *mobj2); boolean K_KartSolidBounce(mobj_t *bounceMobj, mobj_t *solidMobj); void K_KartPainEnergyFling(player_t *player); diff --git a/src/lua_baselib.c b/src/lua_baselib.c index f9a7a9a33..21cae6cb2 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -3676,6 +3676,17 @@ static int lib_kGetMobjWeight(lua_State *L) return 1; } +static int lib_kPlayerJustBumped(lua_State *L) +{ + player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + NOHUD + INLEVEL + if (!player) + return LUA_ErrInvalid(L, "player_t"); + K_PlayerJustBumped(player); + return 0; +} + static int lib_kKartBouncing(lua_State *L) { mobj_t *mobj1 = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); @@ -5535,6 +5546,7 @@ static luaL_Reg lib[] = { {"K_GetKartGameSpeedScalar",lib_kGetKartGameSpeedScalar}, {"K_IsPlayerWanted",lib_kIsPlayerWanted}, {"K_GetMobjWeight",lib_kGetMobjWeight}, + {"K_PlayerJustBumped",lib_kPlayerJustBumped}, {"K_KartBouncing",lib_kKartBouncing}, {"K_KartPainEnergyFling",lib_kKartPainEnergyFling}, {"K_FlipFromObject",lib_kFlipFromObject}, From c493ef93557147cf1670f3940bd97f14272ef5b2 Mon Sep 17 00:00:00 2001 From: JugadorXEI Date: Fri, 22 Aug 2025 08:51:17 +0200 Subject: [PATCH 10/34] Expose K_TumbleInterrupt to Lua --- src/lua_baselib.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 21cae6cb2..a4c5cb8b9 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -3998,6 +3998,17 @@ static int lib_kStumbleSlope(lua_State *L) return 1; } +static int lib_kTumbleInterrupt(lua_State *L) +{ + player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + NOHUD + INLEVEL + if (!player) + return LUA_ErrInvalid(L, "player_t"); + K_TumbleInterrupt(player); + return 0; +} + static int lib_kStumblePlayer(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); @@ -5573,6 +5584,7 @@ static luaL_Reg lib[] = { {"K_SpinPlayer",lib_kSpinPlayer}, {"K_TumblePlayer",lib_kTumblePlayer}, {"K_StumbleSlope",lib_kStumbleSlope}, + {"K_TumbleInterrupt",lib_kTumbleInterrupt}, {"K_StumblePlayer",lib_kStumblePlayer}, {"K_CheckStumble",lib_kCheckStumble}, {"K_ExplodePlayer",lib_kExplodePlayer}, From 8a403752b7f3f92435ef704eece81c04e1dd65b9 Mon Sep 17 00:00:00 2001 From: JugadorXEI Date: Wed, 6 Aug 2025 00:31:16 +0200 Subject: [PATCH 11/34] Expose K_DoInvincibility to Lua --- src/lua_baselib.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index a4c5cb8b9..5d5fc623e 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -4207,6 +4207,18 @@ static int lib_kDoPogoSpring(lua_State *L) return 0; } +static int lib_kDoInvincibility(lua_State *L) +{ + player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + tic_t time = luaL_checkinteger(L, 2); + NOHUD + INLEVEL + if (!player) + return LUA_ErrInvalid(L, "player_t"); + K_DoInvincibility(player, time); + return 0; +} + static int lib_kKillBananaChain(lua_State *L) { mobj_t *banana = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); @@ -5602,6 +5614,7 @@ static luaL_Reg lib[] = { {"K_Squish",lib_kSquish}, {"K_DoSneaker",lib_kDoSneaker}, {"K_DoPogoSpring",lib_kDoPogoSpring}, + {"K_DoInvincibility",lib_kDoInvincibility}, {"K_KillBananaChain",lib_kKillBananaChain}, {"K_RepairOrbitChain",lib_kRepairOrbitChain}, {"K_FindJawzTarget",lib_kFindJawzTarget}, From 00ce9bcfa24a75eaa1d6e72e83ee3444c0b22565 Mon Sep 17 00:00:00 2001 From: JugadorXEI Date: Fri, 8 Aug 2025 01:40:07 +0200 Subject: [PATCH 12/34] Expose P_GivePlayerSpheres to Lua --- src/lua_baselib.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 5d5fc623e..8baaa9c7b 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -1680,6 +1680,18 @@ static int lib_pGivePlayerRings(lua_State *L) return 1; } +static int lib_pGivePlayerSpheres(lua_State *L) +{ + player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + INT32 num_spheres = (INT32)luaL_checkinteger(L, 2); + NOHUD + INLEVEL + if (!player) + return LUA_ErrInvalid(L, "player_t"); + lua_pushinteger(L, P_GivePlayerSpheres(player, num_spheres)); + return 1; +} + static int lib_pGivePlayerLives(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); @@ -5423,6 +5435,7 @@ static luaL_Reg lib[] = { {"P_SpawnGhostMobj",lib_pSpawnGhostMobj}, {"P_SpawnFakeShadow",lib_pSpawnFakeShadow}, {"P_GivePlayerRings",lib_pGivePlayerRings}, + {"P_GivePlayerSpheres",lib_pGivePlayerSpheres}, {"P_GivePlayerLives",lib_pGivePlayerLives}, {"P_MovePlayer",lib_pMovePlayer}, {"P_DoPlayerExit",lib_pDoPlayerExit}, From 4a2078aaa186fb242a1e4152569be23bf9767f9d Mon Sep 17 00:00:00 2001 From: JugadorXEI Date: Fri, 8 Aug 2025 01:50:47 +0200 Subject: [PATCH 13/34] Expose P_DoAllPlayersExit to Lua --- src/lua_baselib.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 8baaa9c7b..91686743f 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -1729,6 +1729,16 @@ static int lib_pDoPlayerExit(lua_State *L) return 0; } +static int lib_pDoAllPlayersExit(lua_State *L) +{ + pflags_t flags = luaL_checkinteger(L, 1); + boolean trygivelife = lua_optboolean(L, 2); + NOHUD + INLEVEL + P_DoAllPlayersExit(flags, trygivelife); + return 0; +} + static int lib_pInstaThrust(lua_State *L) { mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); @@ -5439,6 +5449,7 @@ static luaL_Reg lib[] = { {"P_GivePlayerLives",lib_pGivePlayerLives}, {"P_MovePlayer",lib_pMovePlayer}, {"P_DoPlayerExit",lib_pDoPlayerExit}, + {"P_DoAllPlayersExit",lib_pDoAllPlayersExit}, {"P_InstaThrust",lib_pInstaThrust}, {"P_ReturnThrustX",lib_pReturnThrustX}, {"P_ReturnThrustY",lib_pReturnThrustY}, From eb23e8037688fd526678b4ddf4a2953d71fbc852 Mon Sep 17 00:00:00 2001 From: JugadorXEI Date: Fri, 8 Aug 2025 02:45:20 +0200 Subject: [PATCH 14/34] Expose K_DoGuardBreak to Lua --- src/lua_baselib.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 91686743f..e6563b14b 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -3940,6 +3940,18 @@ static int lib_kDoPowerClash(lua_State *L) return 0; } +static int lib_kDoGuardBreak(lua_State *L) +{ + mobj_t *t1 = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + mobj_t *t2 = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ)); + NOHUD + INLEVEL + if (!t1 || !t2) + return LUA_ErrInvalid(L, "mobj_t"); + K_DoGuardBreak(t1, t2); + return 0; +} + static int lib_kSpawnBattlePoints(lua_State *L) { player_t *source = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); @@ -5614,6 +5626,7 @@ static luaL_Reg lib[] = { {"K_AwardPlayerRings",lib_kAwardPlayerRings}, {"K_DoInstashield",lib_kDoInstashield}, {"K_DoPowerClash",lib_kDoPowerClash}, + {"K_DoGuardBreak",lib_kDoGuardBreak}, {"K_SpawnBattlePoints",lib_kSpawnBattlePoints}, {"K_RemoveGrowShrink",lib_kRemoveGrowShrink}, {"K_IsBigger",lib_kIsBigger}, From 7de76dc1300a8a242ea535be55b3e301a1675c96 Mon Sep 17 00:00:00 2001 From: JugadorXEI Date: Fri, 8 Aug 2025 02:52:24 +0200 Subject: [PATCH 15/34] Expose K_DebtStingPlayer to Lua --- src/k_kart.c | 2 +- src/lua_baselib.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index e30e99399..63b5ed3e5 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -5008,7 +5008,7 @@ void K_DebtStingPlayer(player_t *player, mobj_t *source) { INT32 length = TICRATE; - if (source->player) + if (source && source->player) { length += (4 * (source->player->kartweight - player->kartweight)); } diff --git a/src/lua_baselib.c b/src/lua_baselib.c index e6563b14b..d66cc2553 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -4083,6 +4083,20 @@ static int lib_kExplodePlayer(lua_State *L) return 1; } +static int lib_kDebtStingPlayer(lua_State *L) +{ + player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + mobj_t *source = NULL; + NOHUD + INLEVEL + if (!player) + return LUA_ErrInvalid(L, "player_t"); + if (!lua_isnone(L, 2) && lua_isuserdata(L, 2)) + source = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ)); + K_DebtStingPlayer(player, source); + return 0; +} + static int lib_kTakeBumpersFromPlayer(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); @@ -5637,6 +5651,7 @@ static luaL_Reg lib[] = { {"K_StumblePlayer",lib_kStumblePlayer}, {"K_CheckStumble",lib_kCheckStumble}, {"K_ExplodePlayer",lib_kExplodePlayer}, + {"K_DebtStingPlayer",lib_kDebtStingPlayer}, {"K_TakeBumpersFromPlayer",lib_kTakeBumpersFromPlayer}, {"K_MineFlashScreen",lib_kMineFlashScreen}, {"K_SpawnMineExplosion",lib_kSpawnMineExplosion}, From 1eb2ddf4a1e4c256b896aed13da549baa8b83e6b Mon Sep 17 00:00:00 2001 From: JugadorXEI Date: Fri, 8 Aug 2025 12:11:34 +0200 Subject: [PATCH 16/34] Expose K_StartRoundWinCamera to Lua --- src/lua_baselib.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index d66cc2553..288885555 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -31,6 +31,7 @@ #include "k_boss.h" #include "k_collide.h" #include "k_color.h" +#include "k_endcam.h" #include "k_hud.h" #include "d_netcmd.h" // IsPlayerAdmin #include "k_menu.h" // Player Setup menu color stuff @@ -3485,6 +3486,22 @@ static int lib_gTicsToMilliseconds(lua_State *L) return 1; } +// K_ENDCAM +//////////// + +static int lib_kStartRoundWinCamera(lua_State *L) +{ + mobj_t *origin = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + angle_t focusAngle = luaL_checkangle(L, 2); + fixed_t finalRadius = luaL_checkfixed(L, 3); + tic_t panDuration = luaL_checkinteger(L, 4); + fixed_t panSpeed = luaL_checkfixed(L, 5); + NOHUD + INLEVEL + K_StartRoundWinCamera(origin, focusAngle, finalRadius, panDuration, panSpeed); + return 0; +} + // K_HUD //////////// @@ -5597,6 +5614,9 @@ static luaL_Reg lib[] = { {"G_TicsToMilliseconds",lib_gTicsToMilliseconds}, {"getTimeMicros",lib_getTimeMicros}, + // k_endcam + {"K_StartRoundWinCamera",lib_kStartRoundWinCamera}, + // k_hud {"K_AddMessage", lib_kAddMessage}, {"K_AddMessageForPlayer", lib_kAddMessageForPlayer}, From ac39ef87181394e2eda83947895c10a1d3876788 Mon Sep 17 00:00:00 2001 From: JugadorXEI Date: Fri, 8 Aug 2025 12:17:39 +0200 Subject: [PATCH 17/34] Expose K_EndCameraIsFreezing to Lua --- src/lua_baselib.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 288885555..18c643373 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -3502,6 +3502,13 @@ static int lib_kStartRoundWinCamera(lua_State *L) return 0; } +static int lib_kEndCameraIsFreezing(lua_State *L) +{ + INLEVEL + lua_pushboolean(L, K_EndCameraIsFreezing()); + return 1; +} + // K_HUD //////////// @@ -5616,6 +5623,7 @@ static luaL_Reg lib[] = { // k_endcam {"K_StartRoundWinCamera",lib_kStartRoundWinCamera}, + {"K_EndCameraIsFreezing",lib_kEndCameraIsFreezing}, // k_hud {"K_AddMessage", lib_kAddMessage}, From 8ac6b657dd8aa3bedc581b4e7b69cc3580a32919 Mon Sep 17 00:00:00 2001 From: JugadorXEI Date: Fri, 8 Aug 2025 13:37:22 +0200 Subject: [PATCH 18/34] Expose K_SetHitLagForObjects to Lua --- src/lua_baselib.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 18c643373..0a59885a2 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -5028,6 +5028,20 @@ static int lib_kAddHitLag(lua_State *L) return 0; } +static int lib_kSetHitLagForObjects(lua_State *L) +{ + mobj_t *victim = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + mobj_t *inflictor = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ)); + mobj_t *source = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ)); + tic_t tics = (tic_t)luaL_checkinteger(L, 4); + boolean fromdamage = lua_opttrueboolean(L, 5); + INLEVEL + NOHUD + if (!victim || !inflictor || !source) + return LUA_ErrInvalid(L, "mobj_t"); + K_SetHitLagForObjects(victim, inflictor, source, tics, fromdamage); + return 0; +} static int lib_kPowerUpRemaining(lua_State *L) { @@ -5766,7 +5780,10 @@ static luaL_Reg lib[] = { {"K_SetTireGrease",lib_kSetTireGrease}, {"K_GetCollideAngle",lib_kGetCollideAngle}, + + // k_hitlag {"K_AddHitLag",lib_kAddHitLag}, + {"K_SetHitLagForObjects",lib_kSetHitLagForObjects}, // k_powerup {"K_PowerUpRemaining",lib_kPowerUpRemaining}, From ae1c25495d309093bd5c8eddca221c565029cb6a Mon Sep 17 00:00:00 2001 From: JugadorXEI Date: Fri, 8 Aug 2025 16:39:13 +0200 Subject: [PATCH 19/34] Expose K_BattleAwardHit to Lua --- src/lua_baselib.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 0a59885a2..3eb5e2cff 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -3976,6 +3976,22 @@ static int lib_kDoGuardBreak(lua_State *L) return 0; } +static int lib_kBattleAwardHit(lua_State *L) +{ + player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + player_t *victim = *((player_t **)luaL_checkudata(L, 2, META_PLAYER));; + mobj_t *inflictor = NULL; + INT32 damage = (INT32)luaL_optinteger(L, 4, 0); + NOHUD + INLEVEL + if (!player || !victim) + return LUA_ErrInvalid(L, "player_t"); + if (!lua_isnone(L, 3) && lua_isuserdata(L, 3)) + inflictor = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ)); + K_BattleAwardHit(player, victim, inflictor, damage); + return 0; +} + static int lib_kSpawnBattlePoints(lua_State *L) { player_t *source = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); @@ -5683,6 +5699,7 @@ static luaL_Reg lib[] = { {"K_DoInstashield",lib_kDoInstashield}, {"K_DoPowerClash",lib_kDoPowerClash}, {"K_DoGuardBreak",lib_kDoGuardBreak}, + {"K_BattleAwardHit",lib_kBattleAwardHit}, {"K_SpawnBattlePoints",lib_kSpawnBattlePoints}, {"K_RemoveGrowShrink",lib_kRemoveGrowShrink}, {"K_IsBigger",lib_kIsBigger}, From 742e61df9149359222bef59ad0946d3b9252eb1e Mon Sep 17 00:00:00 2001 From: JugadorXEI Date: Fri, 8 Aug 2025 18:29:26 +0200 Subject: [PATCH 20/34] Expose K_GiveBumpersToPlayer to Lua --- src/lua_baselib.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 3eb5e2cff..7313852bc 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -4137,6 +4137,21 @@ static int lib_kDebtStingPlayer(lua_State *L) return 0; } +static int lib_kGiveBumpersToPlayer(lua_State *L) +{ + player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + player_t *victim = NULL; + UINT8 amount = (UINT8)luaL_optinteger(L, 3, 1); + NOHUD + INLEVEL + if (!player) + return LUA_ErrInvalid(L, "player_t"); + if (!lua_isnone(L, 2) && lua_isuserdata(L, 2)) + victim = *((player_t **)luaL_checkudata(L, 2, META_PLAYER)); + K_GiveBumpersToPlayer(player, victim, amount); + return 0; +} + static int lib_kTakeBumpersFromPlayer(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); @@ -5711,6 +5726,7 @@ static luaL_Reg lib[] = { {"K_CheckStumble",lib_kCheckStumble}, {"K_ExplodePlayer",lib_kExplodePlayer}, {"K_DebtStingPlayer",lib_kDebtStingPlayer}, + {"K_GiveBumpersToPlayer",lib_kGiveBumpersToPlayer}, {"K_TakeBumpersFromPlayer",lib_kTakeBumpersFromPlayer}, {"K_MineFlashScreen",lib_kMineFlashScreen}, {"K_SpawnMineExplosion",lib_kSpawnMineExplosion}, From bcc276949c7edbcc8cccf398fe2c6c3530549477 Mon Sep 17 00:00:00 2001 From: JugadorXEI Date: Fri, 22 Aug 2025 08:52:12 +0200 Subject: [PATCH 21/34] Expose K_GivePointsToPlayer to Lua --- src/lua_baselib.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 7313852bc..13f9b243c 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -4177,6 +4177,21 @@ static int lib_kMineFlashScreen(lua_State *L) return 0; } +static int lib_kGivePointsToPlayer(lua_State *L) +{ + player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + player_t *victim = NULL; + UINT8 amount = (UINT8)luaL_optinteger(L, 3, 1); + NOHUD + INLEVEL + if (!player) + return LUA_ErrInvalid(L, "player_t"); + if (!lua_isnone(L, 2) && lua_isuserdata(L, 2)) + victim = *((player_t **)luaL_checkudata(L, 2, META_PLAYER)); + K_GivePointsToPlayer(player, victim, amount); + return 0; +} + static int lib_kSpawnMineExplosion(lua_State *L) { mobj_t *source = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); @@ -5729,6 +5744,7 @@ static luaL_Reg lib[] = { {"K_GiveBumpersToPlayer",lib_kGiveBumpersToPlayer}, {"K_TakeBumpersFromPlayer",lib_kTakeBumpersFromPlayer}, {"K_MineFlashScreen",lib_kMineFlashScreen}, + {"K_GivePointsToPlayer",lib_kGivePointsToPlayer}, {"K_SpawnMineExplosion",lib_kSpawnMineExplosion}, {"K_SpawnLandMineExplosion",lib_kSpawnLandMineExplosion}, {"K_DriftSparkColor",lib_kDriftSparkColor}, From 2103df6cddbdf50982214ae819a0de645d6a5e1b Mon Sep 17 00:00:00 2001 From: JugadorXEI Date: Fri, 22 Aug 2025 08:53:19 +0200 Subject: [PATCH 22/34] Expose K_ThrowKartItem to Lua --- src/lua_baselib.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 13f9b243c..8a4fd98e9 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -4302,6 +4302,27 @@ static int lib_kSquish(lua_State *L) return 0; } +static int lib_kThrowKartItem(lua_State *L) +{ + tm_t ptm = g_tm; + player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + boolean missile = luaL_checkboolean(L, 2); + mobjtype_t mapthing = luaL_checkinteger(L, 3); + INT32 defaultDir = luaL_optinteger(L, 4, 0); + INT32 altthrow = luaL_optinteger(L, 5, 0); + angle_t angleOffset = luaL_optinteger(L, 6, 0); + NOHUD + INLEVEL + if (!player) + return LUA_ErrInvalid(L, "player_t"); + if (mapthing >= NUMMOBJTYPES) + return luaL_error(L, "mobj type %d out of range (0 - %d)", mapthing, NUMMOBJTYPES-1); + LUA_PushUserdata(L, K_ThrowKartItem(player, missile, mapthing, + defaultDir, altthrow, angleOffset), META_MOBJ); + P_RestoreTMStruct(ptm); // This avoids a g_tm assert. + return 1; +} + static int lib_kDoSneaker(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); @@ -5755,6 +5776,7 @@ static luaL_Reg lib[] = { {"K_SpawnMagicianParticles",lib_kSpawnMagicianParticles}, {"K_DriftDustHandling",lib_kDriftDustHandling}, {"K_Squish",lib_kSquish}, + {"K_ThrowKartItem",lib_kThrowKartItem}, {"K_DoSneaker",lib_kDoSneaker}, {"K_DoPogoSpring",lib_kDoPogoSpring}, {"K_DoInvincibility",lib_kDoInvincibility}, From e75f02963b97c5e96ec53cf70587b3926d05ab0e Mon Sep 17 00:00:00 2001 From: JugadorXEI Date: Fri, 22 Aug 2025 08:54:27 +0200 Subject: [PATCH 23/34] Expose K_GetKartRingPower to Lua --- src/lua_baselib.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 8a4fd98e9..d300ff73d 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -4410,6 +4410,17 @@ static int lib_kCheckPlayersRespawnColliding(lua_State *L) return 1; } +static int lib_kGetKartRingPower(lua_State *L) +{ + player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + boolean boosted = lua_opttrueboolean(L, 2); + INLEVEL + if (!player) + return LUA_ErrInvalid(L, "player_t"); + lua_pushinteger(L, K_GetKartRingPower(player, boosted)); + return 1; +} + static int lib_kGetKartDriftSparkValue(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); @@ -5784,6 +5795,7 @@ static luaL_Reg lib[] = { {"K_RepairOrbitChain",lib_kRepairOrbitChain}, {"K_FindJawzTarget",lib_kFindJawzTarget}, {"K_CheckPlayersRespawnColliding",lib_kCheckPlayersRespawnColliding}, + {"K_GetKartRingPower",lib_kGetKartRingPower}, {"K_GetKartDriftSparkValue",lib_kGetKartDriftSparkValue}, {"K_StairJankFlip",lib_kStairJankFlip}, {"K_SpawnDriftBoostExplosion",lib_kSpawnDriftBoostExplosion}, From 195b0ceb33165981085f014a9b8b9eec184de62f Mon Sep 17 00:00:00 2001 From: JugadorXEI Date: Sat, 9 Aug 2025 12:32:07 +0200 Subject: [PATCH 24/34] Expose K_UpdateSteeringValue to Lua --- src/lua_baselib.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index d300ff73d..28f2dc8d4 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -4421,6 +4421,14 @@ static int lib_kGetKartRingPower(lua_State *L) return 1; } +static int lib_kUpdateSteeringValue(lua_State *L) +{ + fixed_t inputSteering = luaL_checkinteger(L, 1); + fixed_t destSteering = luaL_checkinteger(L, 2); + lua_pushinteger(L, K_UpdateSteeringValue(inputSteering, destSteering)); + return 1; +} + static int lib_kGetKartDriftSparkValue(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); @@ -5796,6 +5804,7 @@ static luaL_Reg lib[] = { {"K_FindJawzTarget",lib_kFindJawzTarget}, {"K_CheckPlayersRespawnColliding",lib_kCheckPlayersRespawnColliding}, {"K_GetKartRingPower",lib_kGetKartRingPower}, + {"K_UpdateSteeringValue",lib_kUpdateSteeringValue}, {"K_GetKartDriftSparkValue",lib_kGetKartDriftSparkValue}, {"K_StairJankFlip",lib_kStairJankFlip}, {"K_SpawnDriftBoostExplosion",lib_kSpawnDriftBoostExplosion}, From 6c9baee31681198a0f36f6c5f192c24675db8443 Mon Sep 17 00:00:00 2001 From: JugadorXEI Date: Sat, 9 Aug 2025 12:38:46 +0200 Subject: [PATCH 25/34] Expose K_GetKartTurnValue to Lua --- src/lua_baselib.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 28f2dc8d4..70f1f51f6 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -4429,6 +4429,17 @@ static int lib_kUpdateSteeringValue(lua_State *L) return 1; } +static int lib_kGetKartTurnValue(lua_State *L) +{ + player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + INT16 turnvalue = luaL_checkinteger(L, 2); + INLEVEL + if (!player) + return LUA_ErrInvalid(L, "player_t"); + lua_pushinteger(L, K_GetKartTurnValue(player, turnvalue)); + return 1; +} + static int lib_kGetKartDriftSparkValue(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); @@ -5805,6 +5816,7 @@ static luaL_Reg lib[] = { {"K_CheckPlayersRespawnColliding",lib_kCheckPlayersRespawnColliding}, {"K_GetKartRingPower",lib_kGetKartRingPower}, {"K_UpdateSteeringValue",lib_kUpdateSteeringValue}, + {"K_GetKartTurnValue",lib_kGetKartTurnValue}, {"K_GetKartDriftSparkValue",lib_kGetKartDriftSparkValue}, {"K_StairJankFlip",lib_kStairJankFlip}, {"K_SpawnDriftBoostExplosion",lib_kSpawnDriftBoostExplosion}, From 30a20b970ce347a2abd3286eef1e0873612e9555 Mon Sep 17 00:00:00 2001 From: JugadorXEI Date: Sat, 9 Aug 2025 12:51:36 +0200 Subject: [PATCH 26/34] Expose K_GetUnderwaterTurnAdjust to Lua --- src/lua_baselib.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 70f1f51f6..404e54782 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -4440,6 +4440,19 @@ static int lib_kGetKartTurnValue(lua_State *L) return 1; } +static int lib_kGetUnderwaterTurnAdjust(lua_State *L) +{ + player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + INLEVEL + if (!player) + return LUA_ErrInvalid(L, "player_t"); + if (player->mo) // the function itself doesn't do this check. + lua_pushinteger(L, K_GetUnderwaterTurnAdjust(player)); + else + lua_pushinteger(L, 0); + return 1; +} + static int lib_kGetKartDriftSparkValue(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); @@ -5817,6 +5830,7 @@ static luaL_Reg lib[] = { {"K_GetKartRingPower",lib_kGetKartRingPower}, {"K_UpdateSteeringValue",lib_kUpdateSteeringValue}, {"K_GetKartTurnValue",lib_kGetKartTurnValue}, + {"K_GetUnderwaterTurnAdjust",lib_kGetUnderwaterTurnAdjust}, {"K_GetKartDriftSparkValue",lib_kGetKartDriftSparkValue}, {"K_StairJankFlip",lib_kStairJankFlip}, {"K_SpawnDriftBoostExplosion",lib_kSpawnDriftBoostExplosion}, From f7beb971d3bb6474261fc44383b2b1014f65e3db Mon Sep 17 00:00:00 2001 From: JugadorXEI Date: Fri, 22 Aug 2025 08:57:14 +0200 Subject: [PATCH 27/34] Expose K_GetKartDriftSparkValueForStage to Lua --- src/lua_baselib.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 404e54782..05b571853 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -4496,6 +4496,17 @@ static int lib_kSpawnDriftElectricSparks(lua_State *L) return 0; } +static int lib_kGetKartDriftSparkValueForStage(lua_State *L) +{ + player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + UINT8 stage = luaL_checkinteger(L, 2); + INLEVEL + if (!player) + return LUA_ErrInvalid(L, "player_t"); + lua_pushinteger(L, K_GetKartDriftSparkValueForStage(player, stage)); + return 1; +} + static int lib_kKartUpdatePosition(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); @@ -5835,6 +5846,7 @@ static luaL_Reg lib[] = { {"K_StairJankFlip",lib_kStairJankFlip}, {"K_SpawnDriftBoostExplosion",lib_kSpawnDriftBoostExplosion}, {"K_SpawnDriftElectricSparks",lib_kSpawnDriftElectricSparks}, + {"K_GetKartDriftSparkValueForStage",lib_kGetKartDriftSparkValueForStage}, {"K_KartUpdatePosition",lib_kKartUpdatePosition}, {"K_DropPaperItem",lib_kDropPaperItem}, {"K_CreatePaperItem",lib_kCreatePaperItem}, From 9173c555c35ab26a301b90dff192301e2fb237a5 Mon Sep 17 00:00:00 2001 From: JugadorXEI Date: Fri, 22 Aug 2025 08:58:30 +0200 Subject: [PATCH 28/34] Expose K_UpdateAllPlayerPositions to Lua --- src/lua_baselib.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 05b571853..8857846a4 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -4530,6 +4530,14 @@ static int lib_kDropPaperItem(lua_State *L) return 0; } +static int lib_kUpdateAllPlayerPositions(lua_State *L) +{ + NOHUD + INLEVEL + K_UpdateAllPlayerPositions(); + return 0; +} + static int lib_kCreatePaperItem(lua_State *L) { fixed_t x = luaL_checkfixed(L, 1); @@ -5849,6 +5857,7 @@ static luaL_Reg lib[] = { {"K_GetKartDriftSparkValueForStage",lib_kGetKartDriftSparkValueForStage}, {"K_KartUpdatePosition",lib_kKartUpdatePosition}, {"K_DropPaperItem",lib_kDropPaperItem}, + {"K_UpdateAllPlayerPositions",lib_kUpdateAllPlayerPositions}, {"K_CreatePaperItem",lib_kCreatePaperItem}, {"K_FlingPaperItem",lib_kFlingPaperItem}, {"K_PopPlayerShield",lib_kPopPlayerShield}, From 42502c23f64a1b6b873907bc658a478e29f1f4fc Mon Sep 17 00:00:00 2001 From: JugadorXEI Date: Sat, 9 Aug 2025 13:45:12 +0200 Subject: [PATCH 29/34] Expose K_GetTotallyRandomResult to Lua --- src/lua_baselib.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 8857846a4..eb91c55c9 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -33,6 +33,7 @@ #include "k_color.h" #include "k_endcam.h" #include "k_hud.h" +#include "k_specialstage.h" #include "d_netcmd.h" // IsPlayerAdmin #include "k_menu.h" // Player Setup menu color stuff #include "p_spec.h" // P_StartQuake @@ -4538,6 +4539,22 @@ static int lib_kUpdateAllPlayerPositions(lua_State *L) return 0; } +static int lib_kGetTotallyRandomResult(lua_State *L) +{ + UINT32 useodds = luaL_optinteger(L, 1, 0); + NOHUD + INLEVEL + // useodds can't be higher than these values to prevent an assert: + useodds = min(7, useodds); // race + if (gametype == GT_BATTLE) // battle + useodds = min(1, useodds); + else if (specialstageinfo.valid == true) // special + useodds = min(3, useodds); + + lua_pushinteger(L, K_GetTotallyRandomResult(useodds)); + return 1; +} + static int lib_kCreatePaperItem(lua_State *L) { fixed_t x = luaL_checkfixed(L, 1); @@ -5858,6 +5875,7 @@ static luaL_Reg lib[] = { {"K_KartUpdatePosition",lib_kKartUpdatePosition}, {"K_DropPaperItem",lib_kDropPaperItem}, {"K_UpdateAllPlayerPositions",lib_kUpdateAllPlayerPositions}, + {"K_GetTotallyRandomResult",lib_kGetTotallyRandomResult}, {"K_CreatePaperItem",lib_kCreatePaperItem}, {"K_FlingPaperItem",lib_kFlingPaperItem}, {"K_PopPlayerShield",lib_kPopPlayerShield}, From c3f60dff44fdb3ae8c21c20d280bb50c42523f81 Mon Sep 17 00:00:00 2001 From: JugadorXEI Date: Fri, 22 Aug 2025 08:59:41 +0200 Subject: [PATCH 30/34] Expose K_ApplyTripWire to Lua, expose tripwirestate_t values to Lua --- src/deh_tables.c | 5 +++++ src/lua_baselib.c | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/deh_tables.c b/src/deh_tables.c index 0d91f51ad..c22fe33e1 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -5166,6 +5166,11 @@ struct int_const_s const INT_CONST[] = { {"FOLLOWERMODE_FLOAT",FOLLOWERMODE_FLOAT}, {"FOLLOWERMODE_GROUND",FOLLOWERMODE_GROUND}, + // tripwirestate_t + {"TRIPSTATE_NONE",TRIPSTATE_NONE}, + {"TRIPSTATE_PASSED",TRIPSTATE_PASSED}, + {"TRIPSTATE_BLOCKED",TRIPSTATE_BLOCKED}, + // tripwirepass_t {"TRIPWIRE_NONE",TRIPWIRE_NONE}, {"TRIPWIRE_IGNORE",TRIPWIRE_IGNORE}, diff --git a/src/lua_baselib.c b/src/lua_baselib.c index eb91c55c9..b5a041489 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -4829,6 +4829,18 @@ static int lib_kGetKartSpeedFromStat(lua_State *L) return 1; } +static int lib_kApplyTripwire(lua_State *L) +{ + player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + tripwirestate_t state = luaL_checkinteger(L, 2); + NOHUD + INLEVEL + if (!player) + return LUA_ErrInvalid(L, "player_t"); + K_ApplyTripWire(player, state); + return 0; +} + static int lib_kGetKartSpeed(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); @@ -5902,6 +5914,7 @@ static luaL_Reg lib[] = { {"K_GetSpindashChargeSpeed",lib_kGetSpindashChargeSpeed}, {"K_GrowShrinkSpeedMul",lib_kGrowShrinkSpeedMul}, {"K_GetKartSpeedFromStat",lib_kGetKartSpeedFromStat}, + {"K_ApplyTripWire",lib_kApplyTripwire}, {"K_GetKartSpeed",lib_kGetKartSpeed}, {"K_GetKartAccel",lib_kGetKartAccel}, {"K_GetKartFlashing",lib_kGetKartFlashing}, From c831549bbd5d26d8600500fc5edc74b52803d624 Mon Sep 17 00:00:00 2001 From: JugadorXEI Date: Fri, 22 Aug 2025 09:01:42 +0200 Subject: [PATCH 31/34] Expose K_FastFallBounce to Lua --- src/lua_baselib.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index b5a041489..6cae8f5fa 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -5048,6 +5048,17 @@ static int lib_kSetItemOut(lua_State *L) return 0; } +static int lib_kFastFallBounce(lua_State *L) +{ + player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + NOHUD + INLEVEL + if (!player) + return LUA_ErrInvalid(L, "player_t"); + lua_pushboolean(L, K_FastFallBounce(player)); + return 1; +} + static int lib_kUnsetItemOut(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); @@ -5947,6 +5958,7 @@ static luaL_Reg lib[] = { {"K_ThunderDome",lib_kThunderDome}, {"K_PlayerCanUseItem",lib_kPlayerCanUseItem}, {"K_PlayerGuard",lib_kPlayerGuard}, + {"K_FastFallBounce",lib_kFastFallBounce}, {"K_SetTireGrease",lib_kSetTireGrease}, {"K_GetCollideAngle",lib_kGetCollideAngle}, From 8fecb320cb3709d96c8c432c52533ca1fa60e8d5 Mon Sep 17 00:00:00 2001 From: JugadorXEI Date: Fri, 22 Aug 2025 09:02:16 +0200 Subject: [PATCH 32/34] Expose K_EggmanTransfer to Lua --- src/lua_baselib.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 6cae8f5fa..77a6461ee 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -5160,6 +5160,18 @@ static int lib_kPlayerCanUseItem(lua_State *L) return 1; } +static int lib_kEggmanTransfer(lua_State *L) +{ + player_t *source = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + player_t *victim = *((player_t **)luaL_checkudata(L, 2, META_PLAYER)); + NOHUD + INLEVEL + if (!source || !victim) + return LUA_ErrInvalid(L, "player_t"); + K_EggmanTransfer(source, victim); + return 0; +} + static int lib_kSetTireGrease(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); @@ -5959,6 +5971,7 @@ static luaL_Reg lib[] = { {"K_PlayerCanUseItem",lib_kPlayerCanUseItem}, {"K_PlayerGuard",lib_kPlayerGuard}, {"K_FastFallBounce",lib_kFastFallBounce}, + {"K_EggmanTransfer",lib_kEggmanTransfer}, {"K_SetTireGrease",lib_kSetTireGrease}, {"K_GetCollideAngle",lib_kGetCollideAngle}, From d8b07202283e87faf770ffbab82419cba327ce4f Mon Sep 17 00:00:00 2001 From: FreakyMutantMan Date: Sun, 15 Dec 2024 13:33:07 -0800 Subject: [PATCH 33/34] Flickering hud elements (spraycan aura, super flicky) are instead transparent with reducevfx. --- src/k_hud_track.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/k_hud_track.cpp b/src/k_hud_track.cpp index afadb95e8..84a0eb734 100644 --- a/src/k_hud_track.cpp +++ b/src/k_hud_track.cpp @@ -454,7 +454,11 @@ Visibility is_object_visible(const mobj_t* mobj) case MT_SPRAYCAN: case MT_SUPER_FLICKY: // Always flickers. - return Visibility::kFlicker; + // Actually no, it gave my friend a migraine, this will *not* always flicker + if (cv_reducevfx.value) + return Visibility::kTransparent; + else + return Visibility::kFlicker; default: // Transparent when not visible. From 9cd9f68ef085c61e6bb7ea36d6b88a7467772b27 Mon Sep 17 00:00:00 2001 From: FreakyMutantMan Date: Sun, 15 Dec 2024 14:06:27 -0800 Subject: [PATCH 34/34] Remove cup select emerald flashing if reducevfx is enabled. (Changing setting requires menu reload to take effect.) --- src/k_menudraw.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/k_menudraw.c b/src/k_menudraw.c index ac09774a4..9dce49251 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -3257,14 +3257,28 @@ void M_DrawCupSelect(void) if (windata) { - M_DrawCupWinData( - x, - y, - templevelsearch.cup, - cv_dummygpdifficulty.value, - (cupgrid.previewanim & 1), - false - ); + if (cv_reducevfx.value) + { + M_DrawCupWinData( + x, + y, + templevelsearch.cup, + cv_dummygpdifficulty.value, + false, + false + ); + } + else + { + M_DrawCupWinData( + x, + y, + templevelsearch.cup, + cv_dummygpdifficulty.value, + (cupgrid.previewanim & 1), + false + ); + } } } }