View Single Post
  #1  
Old 08-22-2012, 03:55 AM
MattCaspermeyer MattCaspermeyer is offline
Approved Member
 
Join Date: Aug 2010
Posts: 553
Exclamation King's Bounty Attack Description / Code Bug

I'm not even sure where to post this since it has gone unnoticed for the entire King's Bounty Lineage (i.e. TL, AP, and CW), but thought that I'd post it here to make everyone aware of this issue.

Here is what the attack tip states:

"Determines the effectiveness of the hero's attack. If the attack exceeds the target's defense, the target suffers more damage. At maximum, the damage increases to 300%."

Here is the code snippet present from ARENA.LUA (similar code is in all 3 KB releases, although the "local k" line may be different due to different bonuses, but in the end it is always at least attack - defense):

Code:
  local k = ( attacker_attack * total_attack_bonus + holy_rage_bonus ) - receiver_defense
.
.
.
  if k >= 0
  and k < 60 then
    sdmg = sdmg * ( 1 + k * 0.0333 )
  end

  if k >= 60 then
    sdmg = sdmg * 3
  end

  if k < 0
  and k >= -60 then
    sdmg = sdmg / ( 1 - k * 0.0333 )
  end

  if k < -60 then
    sdmg = sdmg / 3
  end
Note that k is the damage scalar to sdmg, which is the accumulated damage of all attacks. Look at the bold italics code. If k >= 60, then sdmg is simply multiplied by 3. If you're following me, scaling a value by 3 is only a 200% increase from nominal - not 300%!

This is always a confusing aspect of math and sometimes people get it wrong. A 100% increase in a value is a 2 times increase. A 200% increase in a value is a 3 times increase. And a 300% increase in a value is a 4 times increase.

So, the description should state:

"Determines the effectiveness of the hero's attack. If the attack exceeds the target's defense, the target suffers more damage. At maximum, the damage increases to 200%."

Or the code should be changed to:

Code:
  local k = ( attacker_attack * total_attack_bonus + holy_rage_bonus ) - receiver_defense

  if k >= 0
  and k < 90 then
    sdmg = sdmg * ( 1 + k * 0.0333 )
  end

  if k >= 90 then
    sdmg = sdmg * 4
  end

  if k < 0
  and k >= -60 then
    sdmg = sdmg / ( 1 - k * 0.0333 )
  end

  if k < -60 then
    sdmg = sdmg / 3
  end
Note again the bold italics code.

So, anyway, I just wanted to point out that either the description is wrong or the code is wrong. I'm guessing at this point, but since with the original code limits the damage to between 3 times and 1/3 that the code is correct and the description is simply wrong.

/C\/C\
Reply With Quote