From e5afa5475e572ded7077b46084f4ef90c5ef4067 Mon Sep 17 00:00:00 2001 From: minenice55 Date: Thu, 4 Dec 2025 03:16:54 -0500 Subject: [PATCH] (non-functioning) lua overrides for K_DropHnextList seems the hook isn't receiving the returned droptype? --- src/k_kart.c | 16 +++++++++++++--- src/lua_hook.h | 2 ++ src/lua_hooklib.c | 37 ++++++++++++++++++++++++++++++++++++- 3 files changed, 51 insertions(+), 4 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 3f52923dd..0493d77a7 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -5006,8 +5006,10 @@ void K_DropHnextList(player_t *player) { mobj_t *work = player->mo, *nextwork, *dropwork; INT32 flip; - mobjtype_t type; - boolean orbit, ponground, dropall = true; + mobjtype_t type = MT_NULL; + boolean orbit = true; + boolean dropall = true; + boolean ponground = true; if (work == NULL || P_MobjWasRemoved(work)) { @@ -5066,8 +5068,16 @@ void K_DropHnextList(player_t *player) case MT_ROCKETSNEAKER: case MT_SINK_SHIELD: return; + // fall-through to the lua-scriptable condition default: - continue; + break; + } + + LUA_HookDropHnextList(work, &type, &orbit, &dropall); + if (type == MT_NULL) // who's the fucking bitch + { + P_RemoveMobj(work); + continue; // that took my shit } if ((!itemlittering) && (type == MT_SSMINE)) diff --git a/src/lua_hook.h b/src/lua_hook.h index b4a10c616..cef07606e 100644 --- a/src/lua_hook.h +++ b/src/lua_hook.h @@ -93,6 +93,7 @@ automatically. X (KartStripOther),/*SRB2KART*/\ X (CanPickupItem),/*SRB2KART*/\ X (GetItemEquipStyle),/*SRB2KART*/\ + X (DropHnextList),/*SRB2KART*/\ #define STRING_HOOK_LIST(X) \ X (SpecialExecute),\ @@ -187,6 +188,7 @@ boolean LUA_HookKartStripItems(player_t *player, UINT8 item); // SRB2Kart: Hook boolean LUA_HookKartStripOther(player_t *player); // SRB2Kart: Hook for K_StripOther. boolean LUA_HookCanPickupItem(player_t *player, UINT8 weapon, boolean *force); // SRB2Kart: Hook for P_CanPickupItem. int LUA_HookGetItemEquipStyle(mobjtype_t mobjtype); // SRB2Kart: Hook for K_GetItemEquipStyle. +boolean LUA_HookDropHnextList(mobj_t *mobj, mobjtype_t *droptype, boolean *orbit, boolean *dropall); // SRB2Kart: Hook for K_DropHnextList. #ifdef __cplusplus } // extern "C" diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 12ce4629d..7edd38da6 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -1432,7 +1432,6 @@ static void res_itemequipstyle(Hook_State *hook) } } - int LUA_HookGetItemEquipStyle(mobjtype_t type) { Hook_State hook; @@ -1446,3 +1445,39 @@ int LUA_HookGetItemEquipStyle(mobjtype_t type) return hook.status; } + +typedef struct { + mobjtype_t *droptype; + boolean *orbit; + boolean *dropall; +} KartDropHnextList_State; + +static void res_kartdrophnext(Hook_State *hook) +{ + KartDropHnextList_State *state = (KartDropHnextList_State*)hook->userdata; + if (lua_isnumber(gL, -3)) + *state->droptype = lua_tonumber(gL, -3); + if (lua_isboolean(gL, -2)) + *state->orbit = lua_toboolean(gL, -2); + if (lua_isboolean(gL, -1)) + *state->dropall = lua_toboolean(gL, -1); +} + +boolean LUA_HookDropHnextList(mobj_t *mobj, mobjtype_t *droptype, boolean *orbit, boolean *dropall) +{ + Hook_State hook; + KartDropHnextList_State state = {0}; + state.droptype = droptype; + state.orbit = orbit; + state.dropall = dropall; + + if (prepare_mobj_hook(&hook, false, HOOK(DropHnextList), mobj->type)) + { + LUA_PushUserdata(gL, mobj, META_MOBJ); + hook.userdata = &state; + + call_hooks(&hook, 3, res_kartdrophnext); + } + + return hook.status; +}