Skip to content

Commit 7ea1e9b

Browse files
authored
fix: Blessings Store issue (#506)
This PR fixes Blessings from Store not being deducted when the player dies.
1 parent de8e6d2 commit 7ea1e9b

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

src/creatures/players/player.cpp

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4164,16 +4164,28 @@ void Player::death(const std::shared_ptr<Creature> &lastHitCreature) {
41644164
bool hasSkull = (playerSkull == Skulls_t::SKULL_RED || playerSkull == Skulls_t::SKULL_BLACK);
41654165
uint8_t maxBlessing = 8;
41664166
if (!hasSkull && pvpDeath && hasBlessing(1)) {
4167-
removeBlessing(1, 1); // Remove TOF only
4167+
auto storeCount = getBlessingCount(1, true);
4168+
if (storeCount > 0) {
4169+
auto currentStore = kv()->scoped("summary")->scoped("blessings")->scoped(fmt::format("{}", 1))->get("amount");
4170+
if (currentStore) {
4171+
auto newAmount = std::max(0, static_cast<int>(currentStore->getNumber()) - 1);
4172+
kv()->scoped("summary")->scoped("blessings")->scoped(fmt::format("{}", 1))->set("amount", newAmount);
4173+
}
4174+
} else {
4175+
removeBlessing(1, 1);
4176+
}
41684177
} else {
41694178
for (int i = 2; i <= maxBlessing; i++) {
4170-
removeBlessing(i, 1);
4171-
}
4172-
4173-
const auto &playerAmulet = getThing(CONST_SLOT_NECKLACE);
4174-
bool usingAol = (playerAmulet && playerAmulet->getItem()->getID() == ITEM_AMULETOFLOSS);
4175-
if (usingAol) {
4176-
removeItemOfType(ITEM_AMULETOFLOSS, 1, -1);
4179+
auto storeCount = getBlessingCount(i, true);
4180+
if (storeCount > 0) {
4181+
auto currentStore = kv()->scoped("summary")->scoped("blessings")->scoped(fmt::format("{}", i))->get("amount");
4182+
if (currentStore) {
4183+
auto newAmount = std::max(0, static_cast<int>(currentStore->getNumber()) - 1);
4184+
kv()->scoped("summary")->scoped("blessings")->scoped(fmt::format("{}", i))->set("amount", newAmount);
4185+
}
4186+
} else {
4187+
removeBlessing(i, 1);
4188+
}
41774189
}
41784190
}
41794191
}

0 commit comments

Comments
 (0)