Skip to content

Commit dfad40e

Browse files
committed
Fix small quirks with adding/removing innate (or wisp) Book of Virtues
(cherry picked from commit 5d29483)
1 parent 5ef17ff commit dfad40e

2 files changed

Lines changed: 26 additions & 5 deletions

File tree

libzhl/functions/EntityPlayer.zhl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,9 @@ __thiscall void Entity_Player::AddUrnSouls(unsigned int amount);
403403
"558bec83e4f8518b0d????????568b75":
404404
__thiscall bool Entity_Player::CanAddCollectibleToInventory(int id);
405405

406+
"558bec83e4f8565733ff":
407+
__thiscall void Entity_Player::UpdateBookOfVirtues(bool addedBookOfVirtues);
408+
406409
"558bec568b75??83fe03":
407410
__thiscall bool Entity_Player::CanOverrideActiveItem(unsigned int slot);
408411

repentogon/LuaInterfaces/CustomCallbacks.cpp

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,19 @@ HOOK_STATIC(Isaac, GetBuiltInCallbackState, (const int callbackid)-> bool, __cde
5858
// MC_POST_TRIGGER_COLLECTIBLE_ADDED (1053)
5959
// (Runs for normal items, wisps, and innate collectibles)
6060
void CustomCallbacks::TriggerCollectibleAdded(Entity_Player& player, int collectibleID, bool firsttime, bool wispOrInnate) {
61-
// Fixes a minor bug where the effect/costume for the charge being ready may not trigger.
62-
if (wispOrInnate && collectibleID == COLLECTIBLE_MARS) {
63-
player._marsCooldown = 0;
64-
player._marsUnk2 = -1;
65-
player._marsUnkBool = true;
61+
if (wispOrInnate) {
62+
switch (collectibleID) {
63+
// Fixes a minor bug where the effect/costume for the charge being ready may not trigger.
64+
case COLLECTIBLE_MARS:
65+
player._marsCooldown = 0;
66+
player._marsUnk2 = -1;
67+
player._marsUnkBool = true;
68+
break;
69+
// Properly updates the active hud stuff.
70+
case COLLECTIBLE_BOOK_OF_VIRTUES:
71+
player.UpdateBookOfVirtues(true);
72+
break;
73+
}
6674
}
6775

6876
const int callbackid = 1053;
@@ -3024,6 +3032,16 @@ HOOK_METHOD(Entity_Player, TriggerCollectibleRemoved, (int collectibleID) -> voi
30243032
this->RemoveCostume(g_Manager->GetItemConfig()->GetNullItem(58));
30253033
}
30263034

3035+
// Properly updates the active hud stuff.
3036+
if (collectibleID == COLLECTIBLE_BOOK_OF_VIRTUES && wispOrInnate) {
3037+
auto* activeDesc = this->GetActiveItemDesc(0);
3038+
if (activeDesc->_item == COLLECTIBLE_BOOK_OF_VIRTUES) {
3039+
activeDesc->_item = COLLECTIBLE_NULL;
3040+
activeDesc->_batteryCharge = 0;
3041+
}
3042+
this->UpdateBookOfVirtues(false);
3043+
}
3044+
30273045
super(collectibleID);
30283046

30293047
const int callbackid = 1095;

0 commit comments

Comments
 (0)