Skip to content
This repository was archived by the owner on Feb 27, 2026. It is now read-only.

Commit ef98762

Browse files
authored
fix: Serene Monk not working properlly (zimbadev#433)
This PR fix issue zimbadev#430
1 parent 7eb2d2c commit ef98762

2 files changed

Lines changed: 51 additions & 5 deletions

File tree

src/game/game.cpp

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8387,12 +8387,13 @@ void Game::checkImbuementsAndSereneStatus() {
83878387
}
83888388

83898389
const auto &party = mapPlayer->getParty();
8390-
if (party) {
8391-
mapPlayer->setSerene(isPlayerNoBoxed(mapPlayer));
8392-
continue;
8393-
}
8390+
bool hasNearbyPartyMembers = party ? hasPartyMembersNearby(mapPlayer) : false;
8391+
bool hasLessThanSixMonsters = isPlayerNoBoxed(mapPlayer);
8392+
8393+
bool condition1 = !party || !hasNearbyPartyMembers;
8394+
bool condition2 = hasLessThanSixMonsters;
83948395

8395-
mapPlayer->setSerene(true);
8396+
mapPlayer->setSerene(condition1 && condition2);
83968397
}
83978398
}
83988399

@@ -11731,6 +11732,45 @@ void Game::createIllusion(const std::shared_ptr<Player> &player, const Outfit_t
1173111732
player->addCondition(outfitCondition);
1173211733
}
1173311734

11735+
bool Game::hasPartyMembersNearby(const std::shared_ptr<Player> &player) {
11736+
if (!player) {
11737+
return false;
11738+
}
11739+
11740+
const auto &party = player->getParty();
11741+
if (!party) {
11742+
return false;
11743+
}
11744+
11745+
const Position &centerPos = player->getPosition();
11746+
for (int offsetX = -3; offsetX <= 3; ++offsetX) {
11747+
for (int offsetY = -3; offsetY <= 3; ++offsetY) {
11748+
if (offsetX == 0 && offsetY == 0) {
11749+
continue;
11750+
}
11751+
11752+
const auto &tile = g_game().map.getTile(static_cast<uint16_t>(centerPos.x + offsetX), static_cast<uint16_t>(centerPos.y + offsetY), centerPos.z);
11753+
if (!tile) {
11754+
continue;
11755+
}
11756+
11757+
const auto &topCreature = tile->getTopCreature();
11758+
if (!topCreature) {
11759+
continue;
11760+
}
11761+
11762+
const auto &nearbyPlayer = topCreature->getPlayer();
11763+
if (nearbyPlayer && nearbyPlayer != player) {
11764+
if (nearbyPlayer->getParty() == party) {
11765+
return true;
11766+
}
11767+
}
11768+
}
11769+
}
11770+
11771+
return false;
11772+
}
11773+
1173411774
bool Game::isPlayerNoBoxed(const std::shared_ptr<Player> &player) {
1173511775
if (!player) {
1173611776
return true;
@@ -11759,6 +11799,11 @@ bool Game::isPlayerNoBoxed(const std::shared_ptr<Player> &player) {
1175911799
continue;
1176011800
}
1176111801

11802+
// Ignore other players (including party members)
11803+
if (topCreature->getPlayer()) {
11804+
continue;
11805+
}
11806+
1176211807
if (++monsterCount >= 6) {
1176311808
return false;
1176411809
}

src/game/game.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -980,6 +980,7 @@ class Game {
980980
std::string generateHighscoreOrGetCachedQueryForEntries(const std::string &categoryName, uint32_t page, uint8_t entriesPerPage, uint32_t vocation);
981981
std::string generateHighscoreOrGetCachedQueryForOurRank(const std::string &categoryName, uint8_t entriesPerPage, uint32_t playerGUID, uint32_t vocation);
982982

983+
bool hasPartyMembersNearby(const std::shared_ptr<Player> &player);
983984
bool isPlayerNoBoxed(const std::shared_ptr<Player> &player);
984985
};
985986

0 commit comments

Comments
 (0)