(non-functioning) lua overrides for K_DropHnextList

seems the hook isn't receiving the returned droptype?
This commit is contained in:
minenice55 2025-12-04 03:16:54 -05:00
parent bbcf2bb6f9
commit e5afa5475e
3 changed files with 51 additions and 4 deletions

View file

@ -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))

View file

@ -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"

View file

@ -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;
}