Game Internals › Nonograms Katana › Dungeon combat

Dungeon combat

One damage function handles every hit in the dungeon, from the hero, monsters, familiars and traps alike. Damage is a small random spread around the attacker's damage stat, minus the target's defence, with at least 1 always getting through.

Damage

B = attacker's damage stat s = 2 if B < 12, 3 if B is 12–14, B / 5 (rounded down) if B ≥ 15 raw = a whole number from B − s to B + s, all equally likely (never below 1) with a bonus: raw = max(raw × (100 + bonus) / 100, 2) rounded down final = max(raw − defence, 1) or at least 2 when a bonus applied

There is no miss roll and no percentage armour. Defence is subtracted as a flat number, so against high defence most of a hit disappears, but never all of it.

Bonuses

Only one bonus applies to a hit; they never stack.

BonusExtra damageWhen
Critical hit, hero side+100%Plain melee or throw only. Chance 5%, 10% with the Dagger artifact, +5% more with the level-4+ sword
Critical hit, monsters and familiars+50%Plain melee or throw. Chance 5%
Smashing blow, skill level 1 / 2+50% / +100%Hero's next melee. Can't crit, can't be dodged
Round kick, skill level 3+50%Every adjacent enemy
Kunai with Throwing level 3+50%A crit replaces it

Defence

  • Temporary buffs add flat defence: Pizza Diavola +1, the shrine transformation +2, a defence buff or standing in a mine cart +4, and since version 22.11 Mummy bandages +1.
  • The level-4+ sword pierces armour: defence above 10 drops by 2, but never below 10.
  • Demoralization multiplies defence by 0.4 on a monster, or 0.6 on the hero (rounded down). It's applied last.

Fixed-damage hits

  • Traps use B = the level's trap strength (at least 5): from 5 on 1A to 20 on 5C, 7–15 in the forest and 15–25 in the caves.
  • Greek grenade and flamethrower use B = max(your damage + 2, 8), plus 3 for a grenade with Throwing level 3. The madness grenade uses half your damage, and Mummy powder (22.11) two-thirds.
  • Counter damage is 3–5, capped at a quarter of the attacker's maximum HP, and can't kill.

Poison and protection (version 22.11)

  • Poison. Some monsters poison with their hits: 35% of the time, the target gains poison equal to 55% of the hit's damage before defence (at least 1), but its total poison never goes above its maximum health: at that limit, a poisoning hit adds nothing. Each action point a poisoned creature spends then has a 34% chance to cost it 1 health (1–3 while it has more than 5 poison), and that comes off the poison. A monster still poisoned when the fight ends takes all of it at once. Healing beyond full health burns poison off, and an Antidote neutralizes it. Some creatures are immune.
  • Protection. A creature with the new protected status takes no damage at all, except from poison. The Divine protection ability (once per run; "invulnerable to damage for 1 turn" in the game's text) appears to be what gives it.
  • The hero's shield (the level-4+ one) blocks 10% of thrown attacks outright, as before.
  • The tombs' guardian can't be brought below 1 health by any hit. (The tomb quests suggest its "secret names" are the way past it; we haven't traced that in the code.)

Damage calculator

Pick the attack and the numbers; the chart shows every possible result and how likely it is.

Poison calculator

How much health poison takes while you spend action points. Each point spent has a 34% chance to do damage: 1 to 3 (equally likely) while you have more than 5 poison, otherwise 1, and never more than the poison left. Whatever it takes comes off the poison too, so the total is limited by how much poison you have.

Health only: the poison damage before anything else happens at 0 health (the hero automatically drinks a Potion "Ambrosia" if one is in the bag, restoring 30 health; a few creatures can't drop below 1). A monster still poisoned when the fight ends takes all its remaining poison at once.

Exactly 34.002%, not 34%: the game rolls a number from 0 to 99 and checks it's under 34, and that number comes from a 15-bit random number v (0 to 32,767) as (v × 100) ÷ 32,768, rounded down. That's under 34 for v up to 11,141, so 11,142 of the 32,768 values hit: 11,142 ÷ 32,768 = 34.002%. The calculator uses these exact odds (and 10,923, 10,923 and 10,922 in 32,768 for 1, 2 and 3 damage).

Dodges, counters and blocks

A plain melee hit is resolved in this order:

  1. Dodge. Monsters with the dodge ability avoid a plain melee hit 20% of the time (30% for tameable wild monsters). The monster steps aside, pays 1 action point and takes nothing. Smashing blow, throws and abilities can't be dodged.
  2. Damage, as above.
  3. Vampire. An attacker with the vampire ability heals half the damage dealt (at least 1).
  4. Counter. A defender with counter strikes back for 3–5: monsters 20% of the time, the hero 10% with the level-4 or level-4+ shield.
  5. Stun. The level-4+ shield also stuns a melee attacker 10% of the time (not bosses). That costs the attacker a full turn of action points.

The level-4+ shield also blocks 10% of thrown attacks outright.

Stats

The hero

Levelling up only raises health, energy and mental power. Damage, defence and action points come from skills and equipment.

StatBaseGrows with
Health20+1 per level; +5 Helmet artifact; +5 level-4+ armour; +1 per health upgrade after level 21
Energy30+1 per level; +10 level-4/4+ armour; +5 level-4+ ring or sword
Mental power80+10 per level; +120 Trigonometry artifact; +10 per mental-power upgrade after level 21
Damage5Martial arts +1 per level; sword +3/5/7/9; ring +1/2/3/4; +1 with level-4/4+ armour
Defence2Hardening +1 per level; armour +2/4/6/8; shield +1/2/3/4
Action points4Agility +1

Since version 22.11, equipment can be incrusted: a gem in the weapon adds +1 damage, in the armour +5 health, in the shield +1 defence and in the ring +5 energy.

The hero's level cap is 21, or 26 with the Emerald tablet. Reaching level L takes (L − 1) × L / 2 × 1000 experience in total.

Monsters

Each monster species has a stat table by tier. The tier comes from the dungeon level: 0–4 across dungeons 1–5 (one tier per dungeon), 1–4 across the forest levels, 5 in the caves and 4 in the tombs. A typical early species goes from 8 health, 3 damage, 1 defence at tier 0 to 26 health, 15 damage, 10 defence at tier 4. Most monsters have 3 action points.

Bosses

Bosses have fixed stats and a mental-power requirement instead of a tier table. Some examples:

BossHealthDamageDefenceAction pointsMental power
1A boss2841415
1C boss3852425
2C boss5063630
3C boss8595430
4C boss124159435
5C boss2302114440
Forest F4 boss2832214445
EA boss1802113425
EB boss2402316430
EC boss3402317440
ED boss2402317430
Tomb guardian (EA–EC)401611310

Familiars

A familiar's potential is rolled once when you catch it: health 36–60, damage 14–22, defence 8–16, and 3, 4 or 5 action points (35/40/25%). It starts at 20% of the way from a minimum (8 health, 3 damage, 1 defence) to its potential and reaches the full potential at familiar level 21. Familiars use the monster crit bonus of +50%.

Turns and action points

  • Turn order is rolled once when a fight starts: a random 0–29 plus 10 × action points (plus a bonus for a few species). Highest goes first, then everyone takes turns in that order. A hero with 4 action points rolls 40–69 and a normal monster 30–59, so the hero usually starts. Since 22.11 a mimic that has just sprung gets +30, so it usually goes first.
  • Joining a fight already under way gives no roll. A unit with 6 or more action points, which includes the mechanical spider, cuts in: half the time it goes straight after whoever is acting, otherwise into a random place in the order. Anything slower joins at the end. The spider can only be thrown during a fight, so it always joins this way.
  • Each turn adds your action points to whatever is left, but you can carry at most 1 over: you get min(left + AP, AP + 1).
  • Action points can go negative. You may start any action while you have more than 0, and the full cost is taken. The debt comes off your next turn. With 4 action points you can melee twice in one turn (4 → 1 → −2), then start the next turn with 2.
ActionAction pointsOther cost
Step12 into or out of a mine cart
Melee3Hero: 1 energy
Throw, grenade, net, mechanical spider4Hero: 1 energy
Develop tactics against a protected enemy4Its mental-power requirement
Smashing blow44 energy
Round kick55 energy
Demoralization34 mental power
Charge of motivation (+10 energy)36 mental power
Push an object5

Energy doesn't regenerate during a run. It comes back only from items such as potions, from drums found in the dungeon, and from Charge of motivation; at 0 energy the hero can't attack.

Bosses and mental power

  • A protected enemy takes 0 damage from everything until you "develop tactics": bump into it once to inspect it (4 action points), then again to spend its mental-power requirement. After that it takes damage normally.
  • Two forest bosses re-shield. Every second turn they need another 2 mental power (plus 4 action points) before you can hurt them again.
  • Experience for a kill is the monster's own value plus its mental-power requirement × 5 (× 4 above 4). It's credited the moment the monster dies.
  • Demoralization hits each enemy within 4 cells with an 80% chance (40% for bosses) and lasts about 7 of the victim's turns. If none are hit, one random target is hit anyway.

Defeat

When the hero's health reaches 0, an Ambrosia in the bag is drunk automatically for +30. Otherwise the run ends with the hero unconscious:

  • each equipped item loses 2 durability instead of the usual 1;
  • the hero rests for 6 hours instead of 2;
  • no 20% experience bonus, and the next dungeon level stays locked;
  • experience from kills during the run is kept.

What happens to the loot is on the loot page.

Sources and confidence

  • Read from the code (version 21.4, rechecked against 22.11): the damage function was read in two decompilations and checked against the bytecode, because one decompiler reversed several conditions. Everything on this page comes from the code. In 22.11 the formula, bonuses, turn rules and costs are unchanged; the additions are marked.
  • Inferred: what a few flags mean in game terms. The ambush ability has no name in the code. The +4 defence state (steps cost 2) is named from its object's picture, a mine cart.
  • Not yet checked in the game. A quick check: a new hero with no gear should hit a 1A monster for 2–6, and take 1–3 back.