diff --git a/src/items/weapons/weapons.cpp b/src/items/weapons/weapons.cpp index 2ec09945f36..6a544276f3b 100644 --- a/src/items/weapons/weapons.cpp +++ b/src/items/weapons/weapons.cpp @@ -248,7 +248,6 @@ void Weapon::internalUseWeapon(const std::shared_ptr &player, const std: var.type = VARIANT_NUMBER; var.number = target->getID(); executeUseWeapon(player, var); - g_logger().debug("Weapon::internalUseWeapon - Lua callback executed."); } else { CombatDamage damage; const WeaponType_t weaponType = item->getWeaponType(); @@ -257,12 +256,24 @@ void Weapon::internalUseWeapon(const std::shared_ptr &player, const std: } else { damage.origin = ORIGIN_MELEE; } - damage.primary.type = params.combatType; - damage.primary.value = (getWeaponDamage(player, target, item) * damageModifier) / 100; damage.secondary.type = getElementType(); - // Cleave damage + const int32_t totalDamage = (getWeaponDamage(player, target, item) * damageModifier) / 100; + const int32_t physicalAttack = item->getAttack(); + const int32_t elementalAttack = getElementDamageValue(); + const int32_t combinedAttack = physicalAttack + elementalAttack; + if (elementalAttack > 0) { + float physicalPercentage = static_cast(physicalAttack) / combinedAttack; + float elementalPercentage = static_cast(elementalAttack) / combinedAttack; + damage.primary.value = static_cast(totalDamage * physicalPercentage); + damage.secondary.value = static_cast(totalDamage * elementalPercentage); + } else { + damage.primary.value = totalDamage; + damage.secondary.value = 0; + } + + // Apply cleave adjustments if applicable uint16_t damagePercent = 100; if (cleavePercent != 0) { damage.extension = true; @@ -271,24 +282,17 @@ void Weapon::internalUseWeapon(const std::shared_ptr &player, const std: damage.exString += ", "; } damage.exString += "cleave damage"; + damage.primary.value = (damage.primary.value * damagePercent) / 100; + damage.secondary.value = (damage.secondary.value * damagePercent) / 100; } - if (damage.secondary.type == COMBAT_NONE) { - damage.primary.value = (getWeaponDamage(player, target, item) * damageModifier / 100) * damagePercent / 100; - damage.secondary.value = 0; - } else { - damage.primary.value = (getWeaponDamage(player, target, item) * damageModifier / 100) * damagePercent / 100; - damage.secondary.value = (getElementDamage(player, target, item) * damageModifier / 100) * damagePercent / 100; - } - + // Handle chain system if (g_configManager().getBoolean(TOGGLE_CHAIN_SYSTEM) && params.chainCallback) { m_combat->doCombatChain(player, target, params.aggressive); g_logger().debug("Weapon::internalUseWeapon - Chain callback executed."); } else { Combat::doCombatHealth(player, target, damage, params); } - - g_logger().debug("Weapon::internalUseWeapon - cpp callback executed."); } onUsedWeapon(player, item, target->getTile()); @@ -629,7 +633,7 @@ int32_t WeaponMelee::getWeaponDamage(const std::shared_ptr &player, cons return -maxValue; } - return -normal_random(minValue, (maxValue * static_cast(player->getVocation()->meleeDamageMultiplier))); + return -normal_random(minValue, maxValue); } WeaponDistance::WeaponDistance() {