Official Fulqrum Publishing forum

Official Fulqrum Publishing forum (http://forum.fulqrumpublishing.com/index.php)
-   King's Bounty (http://forum.fulqrumpublishing.com/forumdisplay.php?f=180)
-   -   King's Bounty Attack Description / Code Bug (http://forum.fulqrumpublishing.com/showthread.php?t=34001)

MattCaspermeyer 08-22-2012 03:55 AM

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\

Lord deSword 09-29-2012 11:29 AM

Quote:

Originally Posted by MattCaspermeyer (Post 455776)
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\


Technically it states "increases to 300%" which is 1*3
The thing you suggest is "increased by 300%" which would be 1+1*3 i.e. 1*4
So the statement is correct.

MattCaspermeyer 10-04-2012 05:18 AM

Maybe you're right...
 
You know, when you word it that way, it sounds right - so maybe it's okay the way it is...

Quote:

Originally Posted by Lord deSword (Post 464928)
Technically it states "increases to 300%" which is 1*3
The thing you suggest is "increased by 300%" which would be 1+1*3 i.e. 1*4
So the statement is correct.



All times are GMT. The time now is 03:50 PM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright © 2007 Fulqrum Publishing. All rights reserved.