Skip to content

Commit

Permalink
fix: wands and rods chain damage (#3128)
Browse files Browse the repository at this point in the history
This fixes the damage when chain system enabled for wands and rods.

Fixes #2472
  • Loading branch information
phacUFPE authored Nov 18, 2024
1 parent 3bdad99 commit 93448b8
Showing 1 changed file with 1 addition and 29 deletions.
30 changes: 1 addition & 29 deletions src/items/weapons/weapons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -942,35 +942,7 @@ void WeaponWand::configureWeapon(const ItemType &it) {
}

int32_t WeaponWand::getWeaponDamage(const std::shared_ptr<Player> &player, const std::shared_ptr<Creature> &, const std::shared_ptr<Item> &, bool maxDamage /* = false*/) const {
if (!g_configManager().getBoolean(TOGGLE_CHAIN_SYSTEM)) {
// Returns maximum damage or a random value between minChange and maxChange
return maxDamage ? -maxChange : -normal_random(minChange, maxChange);
}

// If chain system is enabled, calculates magic-based damage
int32_t attackSkill = 0;
int32_t attackValue = 0;
float attackFactor = 0.0;
[[maybe_unused]] int16_t elementAttack = 0;
[[maybe_unused]] CombatDamage combatDamage;
calculateSkillFormula(player, attackSkill, attackValue, attackFactor, elementAttack, combatDamage);

const auto magLevel = player->getMagicLevel();
const auto level = player->getLevel();

// Check if level is greater than zero before performing division
const auto levelDivision = level > 0 ? level / 5.0 : 0.0;

const auto totalAttackValue = magLevel + attackValue;

// Check if magLevel is greater than zero before performing division
const auto magicLevelDivision = totalAttackValue > 0 ? totalAttackValue / 3.0 : 0.0;

const double min = levelDivision + magicLevelDivision;
const double max = levelDivision + totalAttackValue;

// Returns the calculated maximum damage or a random value between the calculated minimum and maximum
return maxDamage ? -max : -normal_random(min, max);
return maxDamage ? -maxChange : -normal_random(minChange, maxChange);
}

int16_t WeaponWand::getElementDamageValue() const {
Expand Down

0 comments on commit 93448b8

Please sign in to comment.