1C Home   |   Register   |   Today Posts   |   Members   |   UserCP   |   Calendar   |   Search   |   FAQ

Go Back   Official 1C Company forum > 1C Publishing > King's Bounty

King's Bounty Famous series of Fantasy Real-time RPG with turn-based battles.

Reply
 
Thread Tools Display Modes
  #1  
Old 08-22-2012, 03:55 AM
MattCaspermeyer MattCaspermeyer is offline
Approved Member
 
Join Date: Aug 2010
Posts: 530
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
  #2  
Old 09-29-2012, 11:29 AM
Lord deSword Lord deSword is offline
Approved Member
 
Join Date: Sep 2012
Location: Bulgaria
Posts: 9
Default

Quote:
Originally Posted by MattCaspermeyer View Post
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.
Reply With Quote
  #3  
Old 10-04-2012, 05:18 AM
MattCaspermeyer MattCaspermeyer is offline
Approved Member
 
Join Date: Aug 2010
Posts: 530
Smile 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 View Post
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.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:39 AM.

Based on a design by: Miner Skinz.com

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © 2007 1C Company. All rights reserved.