Fandom

Pixel Dungeon Wiki

Game mechanics/Attacking

< Game mechanics

616pages on
this wiki
Add New Page
Comments13 Share


When one actor (Hero/ine, Rat, Goo, etc.) attacks another, two stages take place:

  1. test if the attack was successful
  2. damage done is calculated

Test for successful attack Edit

  • The attacker generates a random real number between 0 and its accuracy stat, uniformly distributed.
  • The defender generates a random real number between 0 and its dodge stat, uniformly distributed.
  • If the attacker's number is greater than or equal to the defender's number, the hit is successful.
An example

A level 5 Berserker with strength 15 carrying a +0 War hammer attacks a Gnoll scout:

  • The Hero's accuracy depends on his level. At level 5, his accuracy is 14. This accuracy is then multiplied by the weapon's accuracy, which is 1.2, so his accuracy = 14×1.2 = 16.8.
  • The Hero generates a real number between 0 and 16.8; lets say he got 8.6
  • The Gnoll scout has a dodge stat of 4, so he generates a real number between 0 and 4; lets say he got 2.5.
  • Since 8.6 ≥ 2.5, the hit is successful.
Exceptions
  • An attack using magic (eg. Wand, Dwarf warlock, Gnoll shaman) will multiply the generated accuracy by 2.
  • The Hero/ine's accuracy is decreased when using weapons with a required strength higher than the Hero/ine's strength. The weapons' accuracy is divided by 1.5requiredStrength-heroStrength. In this case, the required strength is 18, and the Hero's strength is 15. So the weapon's accuracy should have been 1.2/(1.518-15) ≈ 0.356; so the Hero's accuracy should have been 14×0.356 ≈ 4.98, instead of 16.8.
In code
  float acuRoll = randomFloat(attacker.accuracy);
  float defRoll = randomFloat(defender.dodge);
  if (attacker.usingMagic) {
    acuRoll *= 2.0F;
  }
  if (acuRoll >= defRoll) {
    // successful hit
  } else {
    // unsuccessful hit
  }
}

Calculate damage Edit

On a successful hit:

  • The attacker generates a random integer between its minimum and maximum hit values, with higher probability to get an integer near the center of the range than near the extremities.
  • The defender generates a random integer between 0 and its armor stat.
  • The defender takes damage equal to the attackersNumber-defendersNumber, or 0 if the subtraction is negative.
An example

Our level 5 Berserker with strength 15 and +0 War hammer attacks the Gnoll scout:

  • The Hero's min/max hit is taken from his weapon which for the War hammer is 5 to 25 (15 ±4.3).
  • The Hero generates a random integer between 5 and 25, let's say it equals 18.
  • The Gnoll scout has an armor stat of 4, so it generates a damage reduction randomly between 0 and 4; let's say 2.
  • The Gnoll scout then takes 18-2=16 damage points. Since the Gnoll scout only has 12 HP, he dies.
Exceptions
  • If the Sniper is attacking, then the damage reduction is 0.
  • A Furious Berserker damage attack will be multiplied by 1.5 (rounded down if the result is not an integer).
  • If the Hero/ine has excess strength when using a weapon, then s/he gains an extra random damage 0 to hero/ineStrength-weaponStrength.
In code
if attacker is Sniper {
 absorption = 0;
} else {
 absorption = randomInteger(0, defender.armor);
}
damage = max(attacker.damageRoll() - absorption, 0);
// attackProc applies additional effects like debuffs, defenseProc applies resistances and immunities
effectiveDamage = defender.defenseProc(attacker, attacker.attackProc(defender, damage));

Surprise attack Edit

A surprise attack is an attack that can be made by the Hero/ine or by an enemy. Surprise attacks have 100 % accuracy, even on non-assassin classes.

The Assassin sub-class will get 50 % more damage from surprise attacks.

Surprise attacks can be made if:

  • An enemy is sleeping (the Hero/ine can't get surprise-attacked while sleeping because s/he will get a warning if the enemy is in his/her field of view).
  • An enemy, or the Hero/ine, has just appeared in the field of view of his/her/its opponent (the one that gets attacked first will be surprise-attacked).
    • One instance of that case is the door strategy: Closing a door will make you leave the enemy's field of view, so when that enemy opens the door afterwards, you just appear (again) in its field of view, hence the surprise attack.
    • Another instance is when you go around a corner with enough distance from the enemy (if it's just following you, it will still see you all along the way, the Hero/ine won't leave/re-enter its field of view).
  • An enemy, or the Hero/ine, is paralyzed with the stunning enchantment/curare dart, even when it is actively hunting the Hero/ine.
  • An enemy, or the Hero/ine, is wandering and gets hit (they will get surprise-attacked).

Tips Edit

See also: Door Strategies

Vision Edit

FORMULA NEEDED: This is the formula that determines whether or not the Hero/ine can see an enemy. Specifically of interest is seeing around corners.

Tips Edit

The Scrolls of Psionic Blast, Terror, and Lullaby, and the Huntress Cloak’s Spectral Blades ability, will affect all enemies within your Hero/ine's field of view. When combined with the Potion of Mind Vision, they will affect all enemies currently at that depth.

Targeting Edit

FORMULA NEEDED: This is the formula that determines where you have to tap, to hit an enemy.

It was seen somewhere, that Watabou has stated, that if an enemy is visible, then it can be hit with a ranged weapon or wand by tapping at the appropriate tile; and that, sometimes, the tile with the visible enemy is not the tile you need to tap to hit it.

Ranged-hitting an enemy positioned just behind a corner: http://i.imgur.com/k5YjhIl.png

Start a Discussion Discussions about Game mechanics/Attacking

  • Damage explanation confusing

    4 messages
    • Hello, not the same Fandom User. Even reading everywhere, the damage stat still remains not clear to me. For instance here: "...
    • 95.120.9.218 wrote:Hello, not the same Fandom User. Even reading everywhere, the damage stat still remains not clear to me. For instance her...
  • 11 Tips from a Veteran

    69 messages
    • Jawer1337 wrote: 20/24 badges unlocked. Step up your game my friend
    • Balorer wrote: Jawer1337 wrote: 20/24 badges unlocked. Step up your game my friend I just need the "All rings/wands identified&qu...

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.