make equip style a property of the items proper

KNOWN ISSUE: rockets and eggman leave the item slot empty when equipped, should probably add a "equipped item type" field to the player struct
This commit is contained in:
minenice55 2025-12-06 00:33:51 -05:00
parent ab378d7494
commit 83176e4c9f
8 changed files with 18 additions and 48 deletions

View file

@ -94,7 +94,7 @@
#define ASSET_HASH_TEXTURES_KART 0xb4211b2f32b6a291
#define ASSET_HASH_CHARS_KART 0x1e68a3e01aa5c68b
#define ASSET_HASH_MAPS_KART 0x38558ed00da41ce9
#define ASSET_HASH_MAIN_PK3 0x4d652be9c2a6d2a7
#define ASSET_HASH_MAIN_PK3 0xbd8469ee97e7f1cc
#define ASSET_HASH_MAPPATCH_PK3 0x0afd8afc6fc50175
#define ASSET_HASH_BONUSCHARS_KART 0x60e6f13d822a7461
#ifdef USE_PATCH_FILE

View file

@ -4107,6 +4107,10 @@ void readkartitem(MYFILE *f, kartitem_t *item)
{
item->flags[word[5] == 'A' ? 1 : 0] = get_number(word2);
}
else if (fastcmp(word, "EQUIP") || fastcmp(word, "EQUIPALT"))
{
item->equipstyle[word[5] == 'A' ? 1 : 0] = get_number(word2);
}
else
WARN("unknown word '%s'", word);
}

View file

@ -1553,6 +1553,7 @@ struct int_const_s const INT_CONST[] = {
{"KITEMEQUIP_ORBIT",KITEMEQUIP_ORBIT},
{"KITEMEQUIP_TRAIL",KITEMEQUIP_TRAIL},
{"KITEMEQUIP_ROCKETS",KITEMEQUIP_ROCKETS},
{"KITEMEQUIP_SHIELD",KITEMEQUIP_SHIELD},
// kartroulettetype_e
{"KROULETTETYPE_NORMAL",KROULETTETYPE_NORMAL},

View file

@ -184,6 +184,14 @@ kartitemflags_e K_GetItemFlags(kartitemtype_e itemtype)
return kartitems[itemtype].flags[K_IsKartItemAlternate(itemtype) ? 1 : 0];
}
kartitemequip_e K_GetItemEquipStyle(kartitemtype_e itemtype)
{
if (itemtype >= numkartitems)
return KITEMEQUIP_NONE;
return kartitems[itemtype].equipstyle[K_IsKartItemAlternate(itemtype) ? 1 : 0];
}
UINT8 K_GetItemNumberDisplayMin(kartitemtype_e type, boolean tiny)
{
if (type == MAXKARTITEMS)
@ -2430,28 +2438,4 @@ void K_AltShrinkPityIncrease(player_t *player)
shrinktime = min(INT16_MAX, shrinktime + PITY_SHRINKINCREASE_BASE + FixedMul(PITY_SHRINKINCREASE, dimin));
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

@ -49,6 +49,7 @@ typedef enum
KITEMEQUIP_ORBIT, // orbiters (orbi, jawz)
KITEMEQUIP_TRAIL, // dragged items (bananas, mines, sinks)
KITEMEQUIP_ROCKETS, // direct player position with offset (rockets)
KITEMEQUIP_SHIELD, //TODO: spawns a shield when active (currently acts like KITEMEQUIP_NONE)
} kartitemequip_e;
typedef enum
@ -114,16 +115,13 @@ struct kartitemgraphics_t
struct kartitem_t
{
dehinfo_t info;
kartitemequip_e equipstyle[2];
kartitemflags_e flags[2];
kartitemgraphics_t graphics[2];
spritedef_t spritedef;
consvar_t *altcvar; // if not NULL, an altitem exists
boolean altenabled;
// note: could be how we do this?
// int (*oddsOverrideFunc)(player_t *p, int pos, int mashed, boolean spbrush, fixed_t seconddist, int pingame, int pexiting);
// int (*resultOverrideFunc)(player_t *p);
};
struct kartresult_t
@ -185,6 +183,7 @@ void K_SetupItemOdds(void);
boolean K_ItemResultEnabled(const kartresult_t *result);
boolean K_IsKartItemAlternate(kartitemtype_e itemtype);
kartitemflags_e K_GetItemFlags(kartitemtype_e itemtype);
kartitemequip_e K_GetItemEquipStyle(kartitemtype_e mobjtype);
UINT8 K_GetItemNumberDisplayMin(kartitemtype_e type, boolean tiny);
patch_t *K_GetCachedItemPatch(kartitemtype_e type, boolean tiny, UINT8 amount);
@ -219,8 +218,6 @@ 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

@ -5666,7 +5666,7 @@ static void K_MoveHeldObjects(player_t *player)
return;
}
equipstyle = K_GetItemEquipStyle(player->mo->hnext->type);
equipstyle = K_GetItemEquipStyle(player->itemtype);
switch (equipstyle)
{

View file

@ -93,7 +93,6 @@ automatically.
X (KartStripItems),/*SRB2KART*/\
X (KartStripOther),/*SRB2KART*/\
X (CanPickupItem),/*SRB2KART*/\
X (GetItemEquipStyle),/*SRB2KART*/\
#define STRING_HOOK_LIST(X) \
X (SpecialExecute),\
@ -187,7 +186,6 @@ 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.
int LUA_HookDropHnextList(mobj_t *mobj, mobjtype_t droptype, boolean *orbit, boolean *dropall); // SRB2Kart: Hook for K_DropHnextList.
#ifdef __cplusplus

View file

@ -1432,20 +1432,6 @@ static void res_itemequipstyle(Hook_State *hook)
}
}
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;
}
typedef struct {
mobjtype_t droptype;
boolean *orbit;