Skip to content

Commit a0f4785

Browse files
feat: POST/PRE_PLAYER_SHUFFLE_COSTUME
1 parent de68727 commit a0f4785

3 files changed

Lines changed: 40 additions & 1 deletion

File tree

libzhl/functions/EntityPlayer.zhl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ __thiscall void Entity_Player::AddRottenHearts(int amount, bool unk);
303303
__thiscall void Entity_Player::AddGigaBombs(int amount);
304304

305305
"558bec83ec68a1????????33c58945??a1":
306-
__thiscall void Entity_Player::ShuffleCostumes(int seed);
306+
__thiscall void Entity_Player::ShuffleCostumes(unsigned int seed);
307307

308308
"558bec83ec2ca1????????33c58945??538b5d":
309309
__thiscall void Entity_Player::RemoveCollectible(unsigned int CollectibleType, bool IgnoreModifiers, unsigned int ActiveSlot, bool RemoveFromPlayerForm);

repentogon/LuaInterfaces/CustomCallbacks.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6460,6 +6460,43 @@ HOOK_METHOD(Weapon_Brimstone, do_baby_brimstone_burst, (Vector* unused1, Vector*
64606460
return result;
64616461
}
64626462

6463+
// MC_PRE/POST_SHUFFLE_COSTUME (1494/1945)
6464+
HOOK_METHOD(Entity_Player, ShuffleCostumes, (unsigned int seed) -> void) {
6465+
const int preCallbackId = 1494;
6466+
6467+
if (CallbackState.test(preCallbackId - 1000)) {
6468+
lua_State* L = g_LuaEngine->_state;
6469+
lua::LuaStackProtector protector(L);
6470+
lua_rawgeti(L, LUA_REGISTRYINDEX, g_LuaEngine->runCallbackRegistry->key);
6471+
6472+
lua::LuaResults result = lua::LuaCaller(L).push(preCallbackId)
6473+
.push(this->GetPlayerType())
6474+
.push(this, lua::Metatables::ENTITY_PLAYER)
6475+
.push(seed)
6476+
.call(1);
6477+
6478+
if (!result && lua_isboolean(L, -1) && !lua_toboolean(L, -1)) {
6479+
return;
6480+
}
6481+
}
6482+
6483+
super(seed);
6484+
6485+
const int postCallbackId = 1495;
6486+
6487+
if (CallbackState.test(postCallbackId - 1000)) {
6488+
lua_State* L = g_LuaEngine->_state;
6489+
lua::LuaStackProtector protector(L);
6490+
lua_rawgeti(L, LUA_REGISTRYINDEX, g_LuaEngine->runCallbackRegistry->key);
6491+
6492+
lua::LuaCaller(L).push(preCallbackId)
6493+
.push(this->GetPlayerType())
6494+
.push(this, lua::Metatables::ENTITY_PLAYER)
6495+
.push(seed)
6496+
.call(0);
6497+
}
6498+
}
6499+
64636500
void CustomCallbacks::detail::ApplyPatches()
64646501
{
64656502
Patch_PlayerRemoveCollectible_TriggerCollectibleRemoved();

repentogon/resources/scripts/enums_ex.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,8 @@ ModCallbacks.MC_EVALUATE_TEAR_HIT_PARAMS = 1490
389389
ModCallbacks.MC_PRE_OPEN_CHEST = 1491
390390
ModCallbacks.MC_POST_OPEN_CHEST = 1492
391391
ModCallbacks.MC_GET_BOSS_THEMATIC_ITEM = 1493
392+
ModCallbacks.MC_PRE_SHUFFLE_COSTUME = 1494
393+
ModCallbacks.MC_POST_SHUFFLE_COSTUME = 1945
392394

393395
--Repentance+ Enums (🐱 catin: https://github.com/epfly6/RepentanceAPIIssueTracker/issues/597)
394396
EffectVariant.MEGA_BEAN_EXPLOSION = 202

0 commit comments

Comments
 (0)