Talk:Flaming

From CrawlWiki
Revision as of 18:45, 27 November 2023 by Hordes (talk | contribs)
Jump to: navigation, search

Rounding for %-based brands

Simple question. How is the damage for flaming/freezing/etc. calculated? Because if it truncates, it makes quickblade of flaming worse than an executioner's axe of freezing. Hordes (talk) 07:19, 27 November 2023 (CET)

Start at apply_damage_brand() in attack.cc, and check for case SPWPN_FLAMING:. It has a call to calc_elemental_brand_damage() there, which does special_damage = resist_adjust_damage(defender, flavour, random2(damage_done) / 2 + 1);, which is flaming's +0-50% damage. Then there's a check for the target's resists in resist_adjust_damage(), and so on and so forth. Ge0ff (talk) 17:32, 27 November 2023 (CET)
"it makes quickblade of flaming worse than an executioner's axe of freezing" This makes no practical sense, regardless of how the game calculates weapon damage. Ge0ff (talk) 17:36, 27 November 2023 (CET)
Re: "it makes quickblade of flaming worse than an executioner's axe of freezing", that meant something along the lines of "do quickblades receive a less than an avg. 25% boost from the flaming brand?" a.k.a "is flaming on a quickblade less damage than flaming on an exe's axe".
E.g. say the game rolled a number from 1/100 to 50/100, multiplied it, then rounded down. A given quickblade swing might go from 7 -> 8 (14% boost) while a similar executioner's axe swing might go from 19 -> 23 (+21% boost). If it rounds down, then flaming/freezing/etc. have a smaller % boost with short blades and co. This would make a practical difference, like if you wanted to compare venom v flaming for a quickblade.
With the code provided, I don't think the rounding problem I presented matters, assuming no resistances.
  • A QB that dealt 7 damage would have a range of {0,1,2,3,4,5,6} from the random2 function.
  • C++ defaults to round down, and resist_adjust_damage() doesn't have any special rounding that I found. So random2(7)/2 + 1 would be rounded down. This gives a range of {0,0,1,1,2,2,3} + 1
  • Average damage is (0+0+1+1+2+2+3)/7 + 1 = 1.286 + 1 -> 2.286. So 2.286 (added damage) / 7 (base damage) = +32.65% damage on average.
Hordes (talk) 18:45, 27 November 2023 (CET)