Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions src/game/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7895,6 +7895,7 @@ int32_t Game::calculateLeechAmount(const int32_t &realDamage, const uint16_t &sk
bool Game::combatChangeMana(const std::shared_ptr<Creature> &attacker, const std::shared_ptr<Creature> &target, CombatDamage &damage) {
const Position &targetPos = target->getPosition();
auto manaChange = damage.primary.value + damage.secondary.value;
auto spectators = Spectators().find<Player>(targetPos);
if (manaChange > 0) {
std::shared_ptr<Player> attackerPlayer;
if (attacker) {
Expand Down Expand Up @@ -7946,7 +7947,7 @@ bool Game::combatChangeMana(const std::shared_ptr<Creature> &attacker, const std
message.primary.value = realManaChange;
message.primary.color = TEXTCOLOR_MAYABLUE;

for (const auto &spectator : Spectators().find<Player>(targetPos)) {
for (const auto &spectator : spectators) {
const auto &tmpPlayer = spectator->getPlayer();
if (!tmpPlayer) {
continue;
Expand Down Expand Up @@ -8043,7 +8044,7 @@ bool Game::combatChangeMana(const std::shared_ptr<Creature> &attacker, const std
message.primary.value = manaLoss;
message.primary.color = TEXTCOLOR_BLUE;

for (const auto &spectator : Spectators().find<Player>(targetPos)) {
for (const auto &spectator : spectators) {
const auto &tmpPlayer = spectator->getPlayer();
if (!tmpPlayer) {
continue;
Expand All @@ -8056,7 +8057,7 @@ bool Game::combatChangeMana(const std::shared_ptr<Creature> &attacker, const std
message.text = ss.str();
} else if (tmpPlayer == targetPlayer) {
ss.str({});
ss << "You lose " << damageString << " mana";
ss << "You lose " << damageString << "";
if (!attacker) {
ss << '.';
} else if (targetPlayer == attackerPlayer) {
Expand Down Expand Up @@ -8086,6 +8087,20 @@ bool Game::combatChangeMana(const std::shared_ptr<Creature> &attacker, const std
}
tmpPlayer->sendTextMessage(message);
}

if (targetPlayer) {
std::string cause = "(other)";
if (attacker) {
cause = attacker->getName();
}

targetPlayer->updateInputAnalyzer(damage.primary.type, -damage.primary.value, cause);
if (attackerPlayer) {
if (damage.secondary.type != COMBAT_NONE) {
attackerPlayer->updateInputAnalyzer(damage.secondary.type, -damage.secondary.value, cause);
}
}
}
}

return true;
Expand Down
Loading