diff --git a/src/game/game.cpp b/src/game/game.cpp index 5dcba79adc1..893a9dcec8d 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -5990,6 +5990,31 @@ bool Game::combatBlockHit(CombatDamage &damage, std::shared_ptr attack std::shared_ptr targetPlayer = target->getPlayer(); if (damage.primary.type != COMBAT_NONE) { + + damage.primary.value = -damage.primary.value; + // Damage healing primary + if (attacker) { + if (target->getMonster()) { + uint32_t primaryHealing = target->getMonster()->getHealingCombatValue(damage.primary.type); + if (primaryHealing > 0) { + damageHeal.primary.value = std::ceil((damage.primary.value) * (primaryHealing / 100.)); + canHeal = true; + } + } + if (targetPlayer && attacker->getAbsorbPercent(damage.primary.type) != 0) { + damageAbsorbMessage = true; + } + if (attacker->getPlayer() && attacker->getIncreasePercent(damage.primary.type) != 0) { + damageIncreaseMessage = true; + } + damage.primary.value *= attacker->getBuff(BUFF_DAMAGEDEALT) / 100.; + } + damage.primary.value *= target->getBuff(BUFF_DAMAGERECEIVED) / 100.; + + primaryBlockType = target->blockHit(attacker, damage.primary.type, damage.primary.value, checkDefense, checkArmor, field); + + damage.primary.value = -damage.primary.value; + InternalGame::sendBlockEffect(primaryBlockType, damage.primary.type, target->getPosition(), attacker); // Damage reflection primary if (!damage.extension && attacker) { if (targetPlayer && attacker->getMonster() && damage.primary.type != COMBAT_HEALING) { @@ -6028,57 +6053,12 @@ bool Game::combatBlockHit(CombatDamage &damage, std::shared_ptr attack } } } - damage.primary.value = -damage.primary.value; - // Damage healing primary - if (attacker) { - if (target->getMonster()) { - uint32_t primaryHealing = target->getMonster()->getHealingCombatValue(damage.primary.type); - if (primaryHealing > 0) { - damageHeal.primary.value = std::ceil((damage.primary.value) * (primaryHealing / 100.)); - canHeal = true; - } - } - if (targetPlayer && attacker->getAbsorbPercent(damage.primary.type) != 0) { - damageAbsorbMessage = true; - } - if (attacker->getPlayer() && attacker->getIncreasePercent(damage.primary.type) != 0) { - damageIncreaseMessage = true; - } - damage.primary.value *= attacker->getBuff(BUFF_DAMAGEDEALT) / 100.; - } - damage.primary.value *= target->getBuff(BUFF_DAMAGERECEIVED) / 100.; - - primaryBlockType = target->blockHit(attacker, damage.primary.type, damage.primary.value, checkDefense, checkArmor, field); - - damage.primary.value = -damage.primary.value; - InternalGame::sendBlockEffect(primaryBlockType, damage.primary.type, target->getPosition(), attacker); } else { primaryBlockType = BLOCK_NONE; } if (damage.secondary.type != COMBAT_NONE) { - // Damage reflection secondary - if (!damage.extension && attacker && target->getMonster()) { - uint32_t secondaryReflectPercent = target->getReflectPercent(damage.secondary.type, true); - uint32_t secondaryReflectFlat = target->getReflectFlat(damage.secondary.type, true); - if (secondaryReflectPercent > 0 || secondaryReflectFlat > 0) { - if (!canReflect) { - damageReflected.primary.type = damage.secondary.type; - damageReflected.primary.value = std::ceil(damage.secondary.value * secondaryReflectPercent / 100.) + std::max(-static_cast(std::ceil(attacker->getMaxHealth() * 0.01)), std::max(damage.secondary.value, -(static_cast(secondaryReflectFlat)))); - if (!damageReflected.exString.empty()) { - damageReflected.exString += ", "; - } - damageReflected.extension = true; - damageReflected.exString += "damage reflection"; - damageReflectedParams.combatType = damage.primary.type; - damageReflectedParams.aggressive = true; - canReflect = true; - } else { - damageReflected.secondary.type = damage.secondary.type; - damageReflected.primary.value = std::ceil(damage.secondary.value * secondaryReflectPercent / 100.) + std::max(-static_cast(std::ceil(attacker->getMaxHealth() * 0.01)), std::max(damage.secondary.value, -(static_cast(secondaryReflectFlat)))); - } - } - } + damage.secondary.value = -damage.secondary.value; // Damage healing secondary if (attacker && target->getMonster()) { @@ -6102,9 +6082,32 @@ bool Game::combatBlockHit(CombatDamage &damage, std::shared_ptr attack damage.secondary.value = -damage.secondary.value; InternalGame::sendBlockEffect(secondaryBlockType, damage.secondary.type, target->getPosition(), attacker); + + if (!damage.extension && attacker && target->getMonster()) { + int32_t secondaryReflectPercent = target->getReflectPercent(damage.secondary.type, true); + int32_t secondaryReflectFlat = target->getReflectFlat(damage.secondary.type, true); + if (secondaryReflectPercent > 0 || secondaryReflectFlat > 0) { + if (!canReflect) { + damageReflected.primary.type = damage.secondary.type; + damageReflected.primary.value = std::ceil(damage.secondary.value * secondaryReflectPercent / 100.) + std::max(-static_cast(std::ceil(attacker->getMaxHealth() * 0.01)), std::max(damage.secondary.value, -(static_cast(secondaryReflectFlat)))); + if (!damageReflected.exString.empty()) { + damageReflected.exString += ", "; + } + damageReflected.extension = true; + damageReflected.exString += "damage reflection"; + damageReflectedParams.combatType = damage.primary.type; + damageReflectedParams.aggressive = true; + canReflect = true; + } else { + damageReflected.secondary.type = damage.secondary.type; + damageReflected.primary.value = std::ceil(damage.secondary.value * secondaryReflectPercent / 100.) + std::max(-static_cast(std::ceil(attacker->getMaxHealth() * 0.01)), std::max(damage.secondary.value, -(static_cast(secondaryReflectFlat)))); + } + } + } } else { secondaryBlockType = BLOCK_NONE; } + // Damage reflection secondary if (damage.primary.type == COMBAT_HEALING) { damage.primary.value *= target->getBuff(BUFF_HEALINGRECEIVED) / 100.; @@ -7223,13 +7226,7 @@ bool Game::combatChangeMana(std::shared_ptr attacker, std::shared_ptr< } target->drainMana(attacker, manaLoss); - if (targetPlayer) { - std::string cause = "(other)"; - if (attacker) { - cause = attacker->getName(); - } - targetPlayer->updateInputAnalyzer(damage.primary.type, damage.primary.value * -1, cause); - } + std::stringstream ss; std::string damageString = std::to_string(manaLoss);