Page 1 of 1

How Damage is Determined (Long Post)

PostPosted: February 28th, 2006, 8:00 pm
by Curulan
<preface>
8 January 2007
For those of you who are coming here from the link on Wikipedia, please note that this post was created using code from the game as of 19 April 2001 and was first posted on 29 December 2002. I have not been able to sufficiently read through and interpret the game's code in newer versions. This being said, please keep in mind that while I have not personally seen any indication to this document's invalidity, it is possible that the game's code has since changed at the time you are reading this.

Thank you for your time.

~ Curulan Angelicos
</preface>


Okay people. You asked for it, and you got it. This is going to be very long.

First, I must explain some concepts and notation you will see in this post:
  • [x..y] means "a random number between x and y, inclusive"
  • "Attacker" means the one who hits first
  • "Defender" means the one who hits second
  • The game treats any action in battle as an attack
  • "Hero" means player
  • "Mob" means the monster you are fighting
  • "Actor" is the universal class the source uses to identify the Hero and all the Mobs in the game

Please note that this will be stated in reference of the attacker being the one who hits first. The game uses the same code to determine mob and hero damage.

Who Goes First
Since the identity of the Attacker and Defender determine what values go into the raw equation, it is important to determine this order. How the game goes first is determined in one of two ways:
  • If either the Hero or Mob attempts to run, but not the other, the running Actor goes first
  • heroFirst = Tools.contest(hspeed, mspeed)
The second choice runs the following code:
roll(a + b) < a
In common notation: "Return true if [0..((Hero's Skill - 1) + (Mob's Skill - 1))] is less than Hero's Skill".

To summarize: Whichever Actor (Hero or Mob) is deterimined to go first is the Attacker.

Raw Damage Equation
The equation for raw damage is as follows:
dmg = ((guts * (2 + hit)) / 10 + at.getAttack()) - df.getDefend()

The following variables are defined as follows:
  • "guts" is the Attacker's Guts statistic
  • "hit" is the hit-value, a number used to add a sense of randomness to the attack
  • "at.getAttack()" is the Attacker's Attack statistic
  • "df.getDefend()" is the Defender's Defense statistic

To Summarize: The equation for raw damage is independant of the variables that are modified according to the choices made in battle.

Normal Attack
For a normal attack, all variables are unmodified from their core (base) values, with the exception of "hit": "hit" equals [0..4] (or more accurately, [0..2]+[0..2]).

In this (and my other examples), Curulan is sparring Glofinje. Curulan's Guts are currently 394, his Attack is currently 248, and Glofinje's Defence is currently 322.

In this example, Curulan hits first, and rolls a 4 on his "hit" (a POWER HIT! in the game). He does (((394 * (2 + 4)) / 10) + 248) - 322 damage, which simplifies to 162 Damage on Glofinje.

Backstab
Backstab applies the following modifications to the core values:
  • hguts *= 2
  • hspeed *= 2
  • mhit = 1
This means that the Attacker's Guts and total Skill are doubled for this attack, and the Defender's attack is reduced to a Weak Blow.

In the spar example, Curulan Scores a Backstab against Glofinje with a "hit" of 3 (Potent Hit), and deals (((394 * 2) * (2 + 3)) / 10) + 248) - 322 damage, or 320 damage. Glofinje's retaliatory attack is reduced to only 44 damage as a result, instead of the 83 he would have gotten (Good Hit).

Berzerk and Ieatsu
Berzerks and Ieatsus have the same effect, with the exception that Berzerks must be done after the first round of combat. Ieatsus can be done on the first round. They apply the following modifications:
  • hguts *= 2
  • hspeed *= 2
  • hhit = 4
Berzerks and Ieatsus are essentially the same as backstabs with the following exception: all Berzerks and Ieatsus are always POWER HIT!s. Always.
In this example, Curulan uses a Ieatsu on Glofinje and does 398 Damage, which would normally kill him.

Special Condition: Blind
Blind has the following effects on your Hero for all rounds of battle until you cure it:
  • hspeed /= 2
  • hhit /= 2

This means that your Skill and hit-value are halved, rounded down. POWER HIT!s become Good Hits, Potent Hits and Good Hits become Weak Blows, and Weak Blows become Fly Swats. These modifications are made after Backstab/Berzerk/Ieatsu modifications.

In this example, Curulan is Blinded, but is still able to score a Backstab. He scores a Good Hit, but it is reduced to a Weak Blow. He only does 162 damage, instead of the 241 Damage the Backstab would normally do. If he had attacked normally, and still made the first shot, he would only have dealt 44 damage.