semi-expose the item equipping logic

really just need enough to be able to prototype stuff with
This commit is contained in:
minenice55 2025-11-28 20:03:23 -05:00
parent 4748aee6fb
commit 2c71e4c18a
6 changed files with 78 additions and 8 deletions

View file

@ -1546,6 +1546,12 @@ struct int_const_s const INT_CONST[] = {
{"KSHIELD_FLAME",KSHIELD_FLAME},
{"NUMKARTSHIELDS",NUMKARTSHIELDS},
// kartitemequip_e
{"KITEMEQUIP_NONE",KITEMEQUIP_NONE},
{"KITEMEQUIP_ORBIT",KITEMEQUIP_ORBIT},
{"KITEMEQUIP_TRAIL",KITEMEQUIP_TRAIL},
{"KITEMEQUIP_ROCKETS",KITEMEQUIP_ROCKETS},
// kartroulettetype_e
{"KROULETTETYPE_NORMAL",KROULETTETYPE_NORMAL},
{"KROULETTETYPE_KARMA",KROULETTETYPE_KARMA},

View file

@ -2431,3 +2431,27 @@ void K_AltShrinkPityIncrease(player_t *player)
player->growshrinktimer = ((INT16)shrinktime) * -1;
}
// this shit is so ass 🥲
kartitemequip_e K_GetItemEquipStyle(mobjtype_t mobjtype)
{
//TODO: lua hook to use any of these for a given mobj
// if we could use tables or dicts I'd use those insteasd
switch (mobjtype)
{
case MT_ORBINAUT_SHIELD:
case MT_JAWZ_SHIELD:
return KITEMEQUIP_ORBIT;
case MT_BANANA_SHIELD:
case MT_SSMINE_SHIELD:
case MT_EGGMANITEM_SHIELD:
case MT_SINK_SHIELD:
return KITEMEQUIP_TRAIL;
case MT_ROCKETSNEAKER:
return KITEMEQUIP_ROCKETS;
default:
{
return LUA_HookGetItemEquipStyle(mobjtype);
}
}
}

View file

@ -43,6 +43,14 @@ typedef enum
#define MAXKARTRESULTS 255
typedef enum
{
KITEMEQUIP_NONE,
KITEMEQUIP_ORBIT, // orbiters (orbi, jawz)
KITEMEQUIP_TRAIL, // dragged items (bananas, mines, sinks)
KITEMEQUIP_ROCKETS, // direct player position with offset (rockets)
} kartitemequip_e;
typedef enum
{
KITEMBLINK_NORMAL,
@ -211,6 +219,8 @@ void K_AltShrinkPityIncrease(player_t *player);
void K_PlayerItemThink(player_t *player, boolean onground);
kartitemequip_e K_GetItemEquipStyle(mobjtype_t mobjtype);
#ifdef __cplusplus
} // extern "C"
#endif

View file

@ -5562,9 +5562,11 @@ void K_CalculateBananaSlope(mobj_t *mobj, fixed_t x, fixed_t y, fixed_t z, fixed
}
// Move the hnext chain!
//TODO: generalize further?
static void K_MoveHeldObjects(player_t *player)
{
TryMoveResult_t result = {0};
kartitemequip_e equipstyle = KITEMEQUIP_NONE;
if (!player->mo)
return;
@ -5598,10 +5600,11 @@ static void K_MoveHeldObjects(player_t *player)
return;
}
switch (player->mo->hnext->type)
equipstyle = K_GetItemEquipStyle(player->mo->hnext->type);
switch (equipstyle)
{
case MT_ORBINAUT_SHIELD: // Kart orbit items
case MT_JAWZ_SHIELD:
case KITEMEQUIP_ORBIT: // Kart orbit items
{
mobj_t *cur = player->mo->hnext;
fixed_t speed = ((8 - min(4, player->itemamount)) * cur->info->speed) / 7;
@ -5677,10 +5680,7 @@ static void K_MoveHeldObjects(player_t *player)
}
}
break;
case MT_BANANA_SHIELD: // Kart trailing items
case MT_SSMINE_SHIELD:
case MT_EGGMANITEM_SHIELD:
case MT_SINK_SHIELD:
case KITEMEQUIP_TRAIL: // Kart trailing items
{
mobj_t *cur = player->mo->hnext;
mobj_t *curnext;
@ -5789,7 +5789,7 @@ static void K_MoveHeldObjects(player_t *player)
}
}
break;
case MT_ROCKETSNEAKER: // Special rocket sneaker stuff
case KITEMEQUIP_ROCKETS: //TODO: generalize with customizable offsets (Special rocket sneaker stuff)
{
mobj_t *cur = player->mo->hnext;
INT32 num = 0;

View file

@ -92,6 +92,7 @@ automatically.
X (KartStripItems),/*SRB2KART*/\
X (KartStripOther),/*SRB2KART*/\
X (CanPickupItem),/*SRB2KART*/\
X (GetItemEquipStyle),/*SRB2KART*/\
#define STRING_HOOK_LIST(X) \
X (SpecialExecute),\
@ -185,6 +186,7 @@ boolean LUA_HookKartSneaker(player_t *player, int type); // SRB2Kart: Hook for K
boolean LUA_HookKartStripItems(player_t *player, UINT8 item); // SRB2Kart: Hook for K_StripItems.
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.
#ifdef __cplusplus
} // extern "C"

View file

@ -1418,3 +1418,31 @@ boolean LUA_HookCanPickupItem(player_t *player, UINT8 weapon, boolean *force)
*force = state.force;
return state.override;
}
static void res_itemequipstyle(Hook_State *hook)
{
if (!lua_isnil(gL, -1))
{
UINT32 ret = lua_tonumber(gL, -1);
hook->status = ret;
}
else
{
hook->status = 0;
}
}
int LUA_HookGetItemEquipStyle(mobjtype_t type)
{
Hook_State hook;
if (prepare_hook(&hook, 0, HOOK(GetItemEquipStyle)))
{
lua_pushinteger(gL, type);
call_hooks(&hook, 1, res_itemequipstyle);
}
return hook.status;
}