From 1b088d9999e5bc532e6f64bb71093f86dce5f31e Mon Sep 17 00:00:00 2001 From: Eduardo Dantas Date: Sat, 21 Dec 2024 00:15:18 -0300 Subject: [PATCH 01/10] fix: wrong calculation from elemental damage for weapons --- src/creatures/monsters/monster.cpp | 17 ++++++++ src/creatures/monsters/monster.hpp | 5 +++ src/items/weapons/weapons.cpp | 67 +++++++++++++++++++++++++----- src/items/weapons/weapons.hpp | 4 ++ 4 files changed, 83 insertions(+), 10 deletions(-) diff --git a/src/creatures/monsters/monster.cpp b/src/creatures/monsters/monster.cpp index 7276bea19d1..95c06766da1 100644 --- a/src/creatures/monsters/monster.cpp +++ b/src/creatures/monsters/monster.cpp @@ -20,6 +20,7 @@ #include "lua/callbacks/event_callback.hpp" #include "lua/callbacks/events_callbacks.hpp" #include "map/spectators.hpp" +#include "items/weapons/weapons.hpp" int32_t Monster::despawnRange; int32_t Monster::despawnRadius; @@ -2660,3 +2661,19 @@ void Monster::onExecuteAsyncTasks() { updateIdleStatus(); } } + +std::map Monster::calculateElementalDamage(CombatType_t weaponElement, int32_t baseDamage +) const { + std::map damageByElement; + // Start with the base damage assigned to the weapon's element type + int32_t elementDamage = baseDamage; + // Check the monster's resistance/weakness for the element type + auto it = mType->info.elementMap.find(weaponElement); + if (it != mType->info.elementMap.end()) { + int32_t elementMod = it->second; // Monster's resistance or weakness + elementDamage = static_cast(std::round(elementDamage * ((100 - elementMod) / 100.0))); + } + // Add the calculated damage to the result map + damageByElement[weaponElement] = elementDamage; + return damageByElement; +} diff --git a/src/creatures/monsters/monster.hpp b/src/creatures/monsters/monster.hpp index b8a6087acc1..d373fb373f1 100644 --- a/src/creatures/monsters/monster.hpp +++ b/src/creatures/monsters/monster.hpp @@ -221,6 +221,11 @@ class Monster final : public Creature { void setDead(bool isDead); + std::map calculateElementalDamage( + CombatType_t weaponElement, + int32_t baseDamage + ) const; + protected: void onExecuteAsyncTasks() override; diff --git a/src/items/weapons/weapons.cpp b/src/items/weapons/weapons.cpp index 2ec09945f36..5181ae6dff4 100644 --- a/src/items/weapons/weapons.cpp +++ b/src/items/weapons/weapons.cpp @@ -258,11 +258,26 @@ void Weapon::internalUseWeapon(const std::shared_ptr &player, const std: damage.origin = ORIGIN_MELEE; } + // Define the primary and secondary damage types damage.primary.type = params.combatType; damage.primary.value = (getWeaponDamage(player, target, item) * damageModifier) / 100; damage.secondary.type = getElementType(); - // Cleave damage + // Step 1: Calculate total damage + const int32_t totalDamage = (getWeaponDamage(player, target, item) * damageModifier) / 100; + if (damage.secondary.type != COMBAT_NONE) { + // Step 2: Use the helper function to distribute the damage + auto [physicalDamage, elementalDamage] = calculateDamageDistribution(target, totalDamage); + // Step 3: Assign the calculated values to the damage object + damage.primary.value = physicalDamage; + damage.secondary.value = elementalDamage; + } else { + // Step 2: Assign the total damage to the primary value + damage.primary.value = totalDamage; + damage.secondary.value = 0; + } + + // Apply cleave adjustments if applicable uint16_t damagePercent = 100; if (cleavePercent != 0) { damage.extension = true; @@ -271,16 +286,11 @@ 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."); @@ -484,6 +494,43 @@ std::shared_ptr Weapon::getCombat() { return m_combat; } +std::pair Weapon::calculateDamageDistribution( + const std::shared_ptr &target, + int32_t totalDamage +) const { + // Default damage distribution percentages + constexpr float DEFAULT_ELEMENTAL_PERCENTAGE = 0.666f; // 2/3 elemental damage + constexpr float DEFAULT_PHYSICAL_PERCENTAGE = 1.0f - DEFAULT_ELEMENTAL_PERCENTAGE; + // Initialize damage percentages + float elementalPercentage = DEFAULT_ELEMENTAL_PERCENTAGE; + float physicalPercentage = DEFAULT_PHYSICAL_PERCENTAGE; + // Check if the target is a player + const auto &targetPlayer = target ? target->getPlayer() : nullptr; + if (targetPlayer) { + // Players have no weaknesses, damage is split 50/50 + elementalPercentage = 0.5f; + physicalPercentage = 0.5f; + } + // Calculate base physical and elemental damage + int32_t physicalDamage = static_cast(totalDamage * physicalPercentage); + int32_t elementalDamage = static_cast(totalDamage * elementalPercentage); + // Apply resistance/weakness modifiers for monsters only + if (!targetPlayer && target) { + const auto &targetMonster = target->getMonster(); + // Use the Monster::calculateElementalDamage function + if (targetMonster) { + auto elementType = getElementType(); + auto elementDamageMap = targetMonster->calculateElementalDamage(elementType, elementalDamage); + auto it = elementDamageMap.find(elementType); + if (it != elementDamageMap.end()) { + elementalDamage = it->second; // Update elemental damage with calculated value + } + } + } + // Return the calculated damage distribution + return {physicalDamage, elementalDamage}; +} + WeaponMelee::WeaponMelee() { // Add combat type and blocked attributes to the weapon params.blockedByArmor = true; @@ -629,7 +676,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() { diff --git a/src/items/weapons/weapons.hpp b/src/items/weapons/weapons.hpp index dca7d814033..13883488430 100644 --- a/src/items/weapons/weapons.hpp +++ b/src/items/weapons/weapons.hpp @@ -206,6 +206,10 @@ class Weapon { std::shared_ptr getCombat(); bool calculateSkillFormula(const std::shared_ptr &player, int32_t &attackSkill, int32_t &attackValue, float &attackFactor, int16_t &elementAttack, CombatDamage &damage, bool useCharges = false) const; + std::pair calculateDamageDistribution( + const std::shared_ptr &target, + int32_t totalDamage + ) const; LuaScriptInterface* getScriptInterface() const; bool loadScriptId(); From a9b7c07f9344e85e68456986d0acfe5848c40afa Mon Sep 17 00:00:00 2001 From: Eduardo Dantas Date: Sat, 21 Dec 2024 00:18:39 -0300 Subject: [PATCH 02/10] fix: factor value for distance weapons --- src/items/weapons/weapons.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/items/weapons/weapons.cpp b/src/items/weapons/weapons.cpp index 5181ae6dff4..b9b3966adf6 100644 --- a/src/items/weapons/weapons.cpp +++ b/src/items/weapons/weapons.cpp @@ -932,7 +932,7 @@ int32_t WeaponDistance::getWeaponDamage(const std::shared_ptr &player, c const float attackFactor = player->getAttackFactor(); int32_t minValue = player->getLevel() / 5; - int32_t maxValue = std::round((0.09f * attackFactor) * attackSkill * attackValue + minValue); + int32_t maxValue = std::round((3.0f * attackFactor) * attackSkill * attackValue + minValue); if (maxDamage) { return -maxValue; } From bbe8a2ee3027e1c0ba1d0e699df3e5a9d5295389 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Sat, 21 Dec 2024 03:29:17 +0000 Subject: [PATCH 03/10] Code format - (Clang-format) --- src/creatures/monsters/monster.cpp | 3 +-- src/items/weapons/weapons.cpp | 4 ++-- src/items/weapons/weapons.hpp | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/creatures/monsters/monster.cpp b/src/creatures/monsters/monster.cpp index 95c06766da1..a5919702825 100644 --- a/src/creatures/monsters/monster.cpp +++ b/src/creatures/monsters/monster.cpp @@ -2662,8 +2662,7 @@ void Monster::onExecuteAsyncTasks() { } } -std::map Monster::calculateElementalDamage(CombatType_t weaponElement, int32_t baseDamage -) const { +std::map Monster::calculateElementalDamage(CombatType_t weaponElement, int32_t baseDamage) const { std::map damageByElement; // Start with the base damage assigned to the weapon's element type int32_t elementDamage = baseDamage; diff --git a/src/items/weapons/weapons.cpp b/src/items/weapons/weapons.cpp index b9b3966adf6..bedb2bb58dc 100644 --- a/src/items/weapons/weapons.cpp +++ b/src/items/weapons/weapons.cpp @@ -495,7 +495,7 @@ std::shared_ptr Weapon::getCombat() { } std::pair Weapon::calculateDamageDistribution( - const std::shared_ptr &target, + const std::shared_ptr &target, int32_t totalDamage ) const { // Default damage distribution percentages @@ -528,7 +528,7 @@ std::pair Weapon::calculateDamageDistribution( } } // Return the calculated damage distribution - return {physicalDamage, elementalDamage}; + return { physicalDamage, elementalDamage }; } WeaponMelee::WeaponMelee() { diff --git a/src/items/weapons/weapons.hpp b/src/items/weapons/weapons.hpp index 13883488430..9b8f9ba31d0 100644 --- a/src/items/weapons/weapons.hpp +++ b/src/items/weapons/weapons.hpp @@ -207,7 +207,7 @@ class Weapon { bool calculateSkillFormula(const std::shared_ptr &player, int32_t &attackSkill, int32_t &attackValue, float &attackFactor, int16_t &elementAttack, CombatDamage &damage, bool useCharges = false) const; std::pair calculateDamageDistribution( - const std::shared_ptr &target, + const std::shared_ptr &target, int32_t totalDamage ) const; From 6a56343f68807311cad5edbfc991b98c78ccb931 Mon Sep 17 00:00:00 2001 From: Eduardo Dantas Date: Sat, 21 Dec 2024 12:40:14 -0300 Subject: [PATCH 04/10] revert: factor --- src/items/weapons/weapons.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/items/weapons/weapons.cpp b/src/items/weapons/weapons.cpp index bedb2bb58dc..a4a1dc9915a 100644 --- a/src/items/weapons/weapons.cpp +++ b/src/items/weapons/weapons.cpp @@ -932,7 +932,7 @@ int32_t WeaponDistance::getWeaponDamage(const std::shared_ptr &player, c const float attackFactor = player->getAttackFactor(); int32_t minValue = player->getLevel() / 5; - int32_t maxValue = std::round((3.0f * attackFactor) * attackSkill * attackValue + minValue); + int32_t maxValue = std::round((0.09f * attackFactor) * attackSkill * attackValue + minValue); if (maxDamage) { return -maxValue; } From b3eee8b0ade916db439c2d4595bb9fdc851551b3 Mon Sep 17 00:00:00 2001 From: Eduardo Dantas Date: Sat, 21 Dec 2024 13:53:52 -0300 Subject: [PATCH 05/10] fix: add missing include --- src/items/weapons/weapons.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/items/weapons/weapons.cpp b/src/items/weapons/weapons.cpp index a4a1dc9915a..eb66f3c9f14 100644 --- a/src/items/weapons/weapons.cpp +++ b/src/items/weapons/weapons.cpp @@ -17,6 +17,7 @@ #include "lib/di/container.hpp" #include "lua/scripts/scripts.hpp" #include "lua/global/lua_variant.hpp" +#include "creatures/monsters/monster.hpp" #include "creatures/players/player.hpp" Weapons::Weapons() = default; From 6db14663e44a2be0b255317ef7a1df1c5abab850 Mon Sep 17 00:00:00 2001 From: Eduardo Dantas Date: Sat, 21 Dec 2024 14:02:45 -0300 Subject: [PATCH 06/10] fix: remove duplicated line --- src/items/weapons/weapons.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/items/weapons/weapons.cpp b/src/items/weapons/weapons.cpp index eb66f3c9f14..814970a8c6b 100644 --- a/src/items/weapons/weapons.cpp +++ b/src/items/weapons/weapons.cpp @@ -261,7 +261,6 @@ void Weapon::internalUseWeapon(const std::shared_ptr &player, const std: // Define the primary and secondary damage types damage.primary.type = params.combatType; - damage.primary.value = (getWeaponDamage(player, target, item) * damageModifier) / 100; damage.secondary.type = getElementType(); // Step 1: Calculate total damage From f8c78e226f37d0db4de14c60215fbd937578aa0b Mon Sep 17 00:00:00 2001 From: Eduardo Dantas Date: Tue, 21 Jan 2025 09:34:02 -0300 Subject: [PATCH 07/10] fix: damage --- src/creatures/monsters/monster.cpp | 15 ------- src/creatures/monsters/monster.hpp | 5 --- src/items/weapons/weapons.cpp | 64 ++++-------------------------- src/items/weapons/weapons.hpp | 4 -- 4 files changed, 8 insertions(+), 80 deletions(-) diff --git a/src/creatures/monsters/monster.cpp b/src/creatures/monsters/monster.cpp index 1fcaa007fcc..51bbec8c67d 100644 --- a/src/creatures/monsters/monster.cpp +++ b/src/creatures/monsters/monster.cpp @@ -2631,18 +2631,3 @@ void Monster::onExecuteAsyncTasks() { onThink_async(); } } - -std::map Monster::calculateElementalDamage(CombatType_t weaponElement, int32_t baseDamage) const { - std::map damageByElement; - // Start with the base damage assigned to the weapon's element type - int32_t elementDamage = baseDamage; - // Check the monster's resistance/weakness for the element type - auto it = mType->info.elementMap.find(weaponElement); - if (it != mType->info.elementMap.end()) { - int32_t elementMod = it->second; // Monster's resistance or weakness - elementDamage = static_cast(std::round(elementDamage * ((100 - elementMod) / 100.0))); - } - // Add the calculated damage to the result map - damageByElement[weaponElement] = elementDamage; - return damageByElement; -} diff --git a/src/creatures/monsters/monster.hpp b/src/creatures/monsters/monster.hpp index 0b21772efba..6e44d8f36bf 100644 --- a/src/creatures/monsters/monster.hpp +++ b/src/creatures/monsters/monster.hpp @@ -221,11 +221,6 @@ class Monster final : public Creature { void setDead(bool isDead); - std::map calculateElementalDamage( - CombatType_t weaponElement, - int32_t baseDamage - ) const; - protected: void onExecuteAsyncTasks() override; diff --git a/src/items/weapons/weapons.cpp b/src/items/weapons/weapons.cpp index 814970a8c6b..0403826fae7 100644 --- a/src/items/weapons/weapons.cpp +++ b/src/items/weapons/weapons.cpp @@ -17,7 +17,6 @@ #include "lib/di/container.hpp" #include "lua/scripts/scripts.hpp" #include "lua/global/lua_variant.hpp" -#include "creatures/monsters/monster.hpp" #include "creatures/players/player.hpp" Weapons::Weapons() = default; @@ -249,30 +248,21 @@ 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(); - if (weaponType == WEAPON_AMMO || weaponType == WEAPON_DISTANCE || weaponType == WEAPON_MISSILE) { - damage.origin = ORIGIN_RANGED; - } else { - damage.origin = ORIGIN_MELEE; - } - - // Define the primary and secondary damage types damage.primary.type = params.combatType; damage.secondary.type = getElementType(); - // Step 1: Calculate total damage const int32_t totalDamage = (getWeaponDamage(player, target, item) * damageModifier) / 100; - if (damage.secondary.type != COMBAT_NONE) { - // Step 2: Use the helper function to distribute the damage - auto [physicalDamage, elementalDamage] = calculateDamageDistribution(target, totalDamage); - // Step 3: Assign the calculated values to the damage object - damage.primary.value = physicalDamage; - damage.secondary.value = elementalDamage; + const int32_t physicalAttack = item->getAttack(); + const int32_t elementalAttack = getElementDamageValue(); + const int32_t combinedAttack = physicalAttack + element + 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 { - // Step 2: Assign the total damage to the primary value damage.primary.value = totalDamage; damage.secondary.value = 0; } @@ -297,8 +287,6 @@ void Weapon::internalUseWeapon(const std::shared_ptr &player, const std: } else { Combat::doCombatHealth(player, target, damage, params); } - - g_logger().debug("Weapon::internalUseWeapon - cpp callback executed."); } onUsedWeapon(player, item, target->getTile()); @@ -494,42 +482,6 @@ std::shared_ptr Weapon::getCombat() { return m_combat; } -std::pair Weapon::calculateDamageDistribution( - const std::shared_ptr &target, - int32_t totalDamage -) const { - // Default damage distribution percentages - constexpr float DEFAULT_ELEMENTAL_PERCENTAGE = 0.666f; // 2/3 elemental damage - constexpr float DEFAULT_PHYSICAL_PERCENTAGE = 1.0f - DEFAULT_ELEMENTAL_PERCENTAGE; - // Initialize damage percentages - float elementalPercentage = DEFAULT_ELEMENTAL_PERCENTAGE; - float physicalPercentage = DEFAULT_PHYSICAL_PERCENTAGE; - // Check if the target is a player - const auto &targetPlayer = target ? target->getPlayer() : nullptr; - if (targetPlayer) { - // Players have no weaknesses, damage is split 50/50 - elementalPercentage = 0.5f; - physicalPercentage = 0.5f; - } - // Calculate base physical and elemental damage - int32_t physicalDamage = static_cast(totalDamage * physicalPercentage); - int32_t elementalDamage = static_cast(totalDamage * elementalPercentage); - // Apply resistance/weakness modifiers for monsters only - if (!targetPlayer && target) { - const auto &targetMonster = target->getMonster(); - // Use the Monster::calculateElementalDamage function - if (targetMonster) { - auto elementType = getElementType(); - auto elementDamageMap = targetMonster->calculateElementalDamage(elementType, elementalDamage); - auto it = elementDamageMap.find(elementType); - if (it != elementDamageMap.end()) { - elementalDamage = it->second; // Update elemental damage with calculated value - } - } - } - // Return the calculated damage distribution - return { physicalDamage, elementalDamage }; -} WeaponMelee::WeaponMelee() { // Add combat type and blocked attributes to the weapon diff --git a/src/items/weapons/weapons.hpp b/src/items/weapons/weapons.hpp index 9b8f9ba31d0..dca7d814033 100644 --- a/src/items/weapons/weapons.hpp +++ b/src/items/weapons/weapons.hpp @@ -206,10 +206,6 @@ class Weapon { std::shared_ptr getCombat(); bool calculateSkillFormula(const std::shared_ptr &player, int32_t &attackSkill, int32_t &attackValue, float &attackFactor, int16_t &elementAttack, CombatDamage &damage, bool useCharges = false) const; - std::pair calculateDamageDistribution( - const std::shared_ptr &target, - int32_t totalDamage - ) const; LuaScriptInterface* getScriptInterface() const; bool loadScriptId(); From 0b579e375943be08fcf8b4cd5e7b5c7f3904396e Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Tue, 21 Jan 2025 12:34:49 +0000 Subject: [PATCH 08/10] Code format - (Clang-format) --- src/items/weapons/weapons.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/items/weapons/weapons.cpp b/src/items/weapons/weapons.cpp index 0403826fae7..f6da54e7eab 100644 --- a/src/items/weapons/weapons.cpp +++ b/src/items/weapons/weapons.cpp @@ -256,13 +256,13 @@ void Weapon::internalUseWeapon(const std::shared_ptr &player, const std: 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 + element - if (elementalAttack > 0) { + const int32_t combinedAttack = physicalAttack + element 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 { + } + else { damage.primary.value = totalDamage; damage.secondary.value = 0; } @@ -482,7 +482,6 @@ std::shared_ptr Weapon::getCombat() { return m_combat; } - WeaponMelee::WeaponMelee() { // Add combat type and blocked attributes to the weapon params.blockedByArmor = true; From d8aad37adb594b1f3186cc217d3ef4452a4d9623 Mon Sep 17 00:00:00 2001 From: Eduardo Dantas Date: Tue, 21 Jan 2025 09:37:02 -0300 Subject: [PATCH 09/10] fix: some things --- src/creatures/monsters/monster.cpp | 1 - src/items/weapons/weapons.cpp | 8 +++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/creatures/monsters/monster.cpp b/src/creatures/monsters/monster.cpp index 25bb7415698..3535cd0897c 100644 --- a/src/creatures/monsters/monster.cpp +++ b/src/creatures/monsters/monster.cpp @@ -20,7 +20,6 @@ #include "lua/callbacks/event_callback.hpp" #include "lua/callbacks/events_callbacks.hpp" #include "map/spectators.hpp" -#include "items/weapons/weapons.hpp" int32_t Monster::despawnRange; int32_t Monster::despawnRadius; diff --git a/src/items/weapons/weapons.cpp b/src/items/weapons/weapons.cpp index 0403826fae7..793e95148d4 100644 --- a/src/items/weapons/weapons.cpp +++ b/src/items/weapons/weapons.cpp @@ -250,13 +250,19 @@ void Weapon::internalUseWeapon(const std::shared_ptr &player, const std: executeUseWeapon(player, var); } else { CombatDamage damage; + const WeaponType_t weaponType = item->getWeaponType(); + if (weaponType == WEAPON_AMMO || weaponType == WEAPON_DISTANCE || weaponType == WEAPON_MISSILE) { + damage.origin = ORIGIN_RANGED; + } else { + damage.origin = ORIGIN_MELEE; + } damage.primary.type = params.combatType; damage.secondary.type = getElementType(); 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 + element + const int32_t combinedAttack = physicalAttack + elementalAttack; if (elementalAttack > 0) { float physicalPercentage = static_cast(physicalAttack) / combinedAttack; float elementalPercentage = static_cast(elementalAttack) / combinedAttack; From 24d6ecf2e88382a8fd363ab954959b3bf5dfa7d2 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Tue, 21 Jan 2025 12:39:43 +0000 Subject: [PATCH 10/10] Code format - (Clang-format) --- src/items/weapons/weapons.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/items/weapons/weapons.cpp b/src/items/weapons/weapons.cpp index afcacbc1c92..6a544276f3b 100644 --- a/src/items/weapons/weapons.cpp +++ b/src/items/weapons/weapons.cpp @@ -268,8 +268,7 @@ void Weapon::internalUseWeapon(const std::shared_ptr &player, const std: float elementalPercentage = static_cast(elementalAttack) / combinedAttack; damage.primary.value = static_cast(totalDamage * physicalPercentage); damage.secondary.value = static_cast(totalDamage * elementalPercentage); - } - else { + } else { damage.primary.value = totalDamage; damage.secondary.value = 0; }