-
-
Notifications
You must be signed in to change notification settings - Fork 677
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: wrong calculation from elemental damage for weapons #3187
fix: wrong calculation from elemental damage for weapons #3187
Conversation
…ps://github.com/opentibiabr/canary into dudantas/fix-elemental-damage-wrong-calculation
|
This is ready for testing now. |
This PR is stale because it has been open 45 days with no activity. |
Function Edit:
It also fixes this issue: #3341 I suggest to change |
I think you didn't understand the formula, the calculation should be done based on the weapon's attack (configured in items.xml) and not the currently damage. |
Yes I did undertood the formula. The issue is that getWeaponDamage returns the damage using the physical attack only, ignoring the elemental part of the attack which does make part of the total damage. The way it is, the damage distribuition will be calculated based on that attack. Take phantasmal axe which has Atk:5 physical + 49 fire, for example. The "totalDamage" variable will be calculated using the 5 atk only, that will be returned from getWeaponDamage. The +49 attack will not contribute to the damage, so the damage calculated from 5 atk will be distributed according to proportional damage of phys/elemental, which is correct. Theres no issue with the proportional distribution, but with the totalDamage calculation. |
Based on the logs and the breakpoint values, the current formula is intentional. We use the weapon’s base physical attack to compute totalDamage, then split that total proportionally according to item->getAttack() (physical) vs. getElementDamageValue() (elemental). If we added the elemental value directly into getWeaponDamage, we would be double-counting the elemental portion and inflating the final damage. So, getElementDamageValue() is correctly returning the weapon’s elemental attack for the distribution stage, rather than raw damage, and this matches our intended formula. |
Debug WeaponMelee::getWeaponDamage. Where does the damage calculation accounts for the elemental attack? Because I can't see it. The 49 attack is completely ignored.
Edit I hope this help you see the issue i'm talking about: https://onecompiler.com/lua/43c79juqw
|
fb7b1ae
to
0a294da
Compare
Thanks for the review! Initially, your explanation was quite complex to follow, but your last comment was much more direct and clear. I appreciate your patience in breaking it down. Now I see the issue more clearly— Your input was valuable, and I appreciate the detailed breakdown! Fixed here: 0a294da |
|
Description
This PR fixes an issue with the calculation of elemental weapon damage. Previously, the damage calculation for elemental weapons duplicated the damage instead of distributing it as 60% elemental and 40% physical. This resulted in incorrect damage values and an overpowered effect for certain weapons.
The corrected logic ensures that the total damage remains consistent, splitting appropriately based on the elemental and physical proportions while applying target resistances/weaknesses correctly.
Behaviour
Actual
Using elemental weapons caused the damage calculation to incorrectly duplicate the total damage, leading to inflated results that did not respect the intended 60/40% distribution.
Expected
Using elemental weapons distributes the total damage correctly as 60% elemental and 40% physical, with adjustments for the target's resistances or weaknesses to the specific element.
Type of change
How Has This Been Tested
The fix has been tested thoroughly to verify the proper distribution of elemental and physical damage. Test cases include:
Checklist
Font: https://forum.portaltibia.com.br/topic/36599-armas-dano-elemental/