Skip to content

Combat System

soulflyman edited this page Nov 30, 2026 · 8 revisions

Combat System

Targeting is a two-step select-then-confirm, and there is no hit/miss roll

Combat is not a simple bump-attack. First observed via live play (Beaten Dying Moon emulator) and then traced in the disassembly and confirmed dynamically with scripted breakpoint hooks on combat2.state, the actual sequence is:

  1. Walk up to stand adjacent to one or more monsters.
  2. Press the direction toward the monster you want to target — this doesn't move you (you're already adjacent) or attack yet, it selects that monster. The selection is shown as blinking corner markers on the monster's tile - the actual sprite behind this (VRAM OBJ tiles $2c/$2e, one corner graphic reused 4x via sprite flip, alternating between the two tile IDs for the blink) is isolated in the Sprite Glossary "UI overlay / cursor sprites". If multiple monsters are adjacent, pressing a different direction re-selects a different one.
  3. Press A to actually execute the attack on the currently-selected target.

So targeting takes a direction press and a separate A press — simply walking into a monster's tile does not attack by itself. Every attack executed this way lands; there is no accuracy/miss chance anywhere in the game. This was confirmed on both sides of combat:

The code behind it

Two nested state machines, both dispatched through RST_00 jump tables (the "second jump trampoline", see below):

  • $c125 is the main state (24-entry table at $3360 in bank_000.asm). State 6 = "adjacent target selection active" (Call_000_3bae); state 12 = "execute attack/pickup" (Jump_001_5a59_ConfirmAttackOrPickup, bank 1).
  • Inside state 6, Call_000_3bc6 reads the newly-pressed button ($c512) and jumps to Call_000_3c4f_TrySelectDirection (a direction), Jump_000_3c7f_ConfirmAttack (A), or Jump_000_3c85_CancelTargeting (B).
  • Call_000_3c4f_TrySelectDirection checks, for the pressed direction, whether a monster (Call_001_57db/Call_000_2f28, a monster-slot scan) or a ground item (Call_000_35ef) is actually there — only then is that direction accepted as the new target (jr_000_3c72, sets $c126=1). This is the exact "pressing a direction selects the monster" behavior, with a real adjacency check — not just a cosmetic move.
  • Jump_000_3c7f_ConfirmAttack (A pressed) just sets $c126=3; the outer dispatch in Call_000_3bae (a second RST_00 table at $3bbe, indexed by $c126) resolves that to Jump_000_3c38_ConfirmAttack, which sets $c125=12 — the real attack state.
  • Jump_001_5a59_ConfirmAttackOrPickup (state 12) branches on $c524: bit 7 set means the target is a ground item (jumps into the pickup code, Jump_001_4f3d); otherwise $c524 is the monster participant ID (<2 = nothing valid selected, >=2 = monster slot + 2). For a real attack, $c523 is forced to $01 (player is the attacker) and Call_001_5c00 runs the shared damage formula.

Verified dynamically: a hook on $5a59 fired exactly on the A press with $c523=1, $c524=2 (monster slot 0), immediately followed by Call_001_5c47/Call_001_5c75, with the monster's HP struct field (offset $06) dropping by the expected damage in the same step. Still open: how the game transitions into $c125=6 in the first place (presumably automatic on detecting an adjacent monster/item after a movement step — not yet traced).

Partial answer (live gearboy-mcp session): observed $c125 flip straight to 6 as the direct result of a movement attempt whose destination cell was monster-occupied - the move didn't commit (player stayed put) but target-selection opened immediately in the same input, already aiming at that monster. So the trigger isn't a separate post-move adjacency scan; it looks like the same occupancy check that blocks the move (see Dungeon Mechanics "Movement collision, partially traced") also opens targeting when the blocking occupant is a monster, in one step. Not yet confirmed from the disassembly, but consistent with every observation so far.

A monster gets a free attack if a menu is opened while adjacent to it. Confirmed live: opening the Camp/item-use menu while standing next to a live monster (HP 7/10 going in) cost 3 HP by the time the menu closed, with no attack animation or combat state visible - the adjacent monster's turn still resolves while the player is menu-bound. Don't assume menus are a free, consequence-free pause if something is standing next to you.

  • Monster → player damage is a deterministic per-monster-type table lookup (Call_001_518a-style lookups), not a random roll.
  • Player → monster damage (Call_001_5c47/Call_001_5c75, bank 1) is the same kind of deterministic table/arithmetic lookup, confirmed by watching the monster's HP field drop by a varying-but-formulaic amount on every single attempt across two independent live fights (never a "nothing happened, it dodged" turn).

The damage formula

Effective attack/defense values used in combat are computed on the fly:

  • Effective attack = wPlayerAttack + two equipment bonus bytes (clamped to 99 in BCD)
  • Effective defense = wPlayerDefense + two equipment bonus bytes (clamped to 99 in BCD)

The equipment bonus bytes come from equipped swords/shields — see Item System for the exact bonus table.

Damage itself is integer arithmetic on attack vs. defense, scaled by a direction/facing-derived factor ($c539 and $1f), with a minimum damage of 1 if attack × 2 ≤ defense. Observed damage values across two test fights: 2, 2, 3, 4, 1, 2 — confirming this is a real formula, not the fixed "always exactly 2" that an earlier, smaller sample had suggested.

Fire ($03) is a separate, much higher-damage source outside this formula - confirmed live at 12 damage in one hit (vs. the 1-4 range above), one-shotting a 6 HP Tarantula. See Item System $03 for the full targeting mechanism (own free-moving cursor, not the adjacent-select combat uses).

Melee damage can also spike much higher than the earlier 1-4 sample suggested once equipment is in play: with a Sword +1 equipped (effective attack 5, see Item System $18), one plain melee hit dealt 7 damage, one-shotting a fresh 7 HP Minotaur (gearboy-mcp session). Consistent with the formula being genuinely attack-vs-defense-sensitive rather than a small fixed range - the +1 from the sword was enough to roughly double the damage ceiling seen so far against this particular monster's defense.

A monster adjacent during a $c100-level transient state (not just the item-menu case above) can land a lethal free hit. Confirmed live: after a quest was already fully complete (3/3), a Crab adjacent to the player during a $c100=2 transient (entered via a wall-bump clear, see Dungeon Mechanics "$c125=0") dropped HP from 2 straight to 0, triggering a normal Game Over - the HP-reaches-0 trigger itself is the already-documented one in Player Death and Game Over, nothing new there, but it confirms these adjacency-based free hits are a real death risk, not just chip damage, at low HP.

There is no dedicated RNG function

Cave Noire doesn't have a classic random number generator (no LFSR, no rDIV read anywhere relevant). Instead, it reuses a harmless side effect of the game loop as a "good enough" randomness source:

  1. RST_00 is a second jump-table trampoline (like RST_28, which does hl += a, but RST_00 is a jump-table instead): the index comes from a, and the 2-bytes-per-entry table lives directly in the byte stream right after the rst RST_00 opcode — which is why it looks like garbage code to a naive disassembler until you realize it's data.
  2. Every monster struct (16 bytes, base $c5c0 + 16×slot) has a 2-3 bit state/direction field at offset $0f. This field is used (masked with and $03/and $07, then rst RST_00) as an index into a 4-entry jump table pointing at the four cardinal movement functions.
  3. The actual "randomness": this field gets incremented every time it is not that monster's turn in the per-turn dispatch loop. Since the game loop steps through multiple monster types per turn, this counter increments at a cadence the player can't predict — its low bits behave like a dice roll even though it's just a dumb running counter.

This also answers the "hit chance" question definitively: there isn't one. Whether a monster can attack at all is purely positional (aligned with the player on row/column, adjacent), and this pseudo-random counter only determines whether/where it moves instead.

Poison status, confirmed live

Not previously documented at all beyond the cure item's name. Confirmed live (gearboy-mcp session, Tarantula fight): after taking melee damage from a Tarantula, the character sheet's condition line (たいちょう, normally OK) read たいちょう「どく」("condition: Poison") instead. While poisoned, HP ticked down by 1 per turn even with no monster adjacent and no further combat - confirmed across two separate idle turns (5→4→ [interrupted by an item use, see below] and losing HP again on the very next plain turn after that). Dokukeshi ($02) cures it immediately - the condition line read OK again the turn after using it, and HP stopped draining. Not yet confirmed which monster classes can inflict it (only tested against Tarantula, class 3) or whether the drain amount/duration varies.

The Lucky stat

wPlayerLucky ($c123) does not affect hit chance or combat accuracy at all. All of its uses are in the item-effect dispatcher:

  1. Healing: new HP = min(current HP + Lucky, max HP) for one potion-like item effect. Reconfirmed live (gearboy-mcp session): wPlayerLucky=4, used Kaifuku ($01) at 3 HP, result exactly 7 HP (3+4, below the 10 HP max so the clamp didn't engage).
  2. A second item type: heals by Lucky + 1.
  3. Random event timer ($c515): for most item effects, $c515 is set from the LCG pseudo-random source ($c011/$c012, state = state×9 + $0929 mod $11d7), with the range of the result scaled by Lucky / 2 — e.g. a trap fuse duration or buff duration.
  4. Status screen: Lucky is also just displayed as a stat number, no computation there.

So: higher Lucky means better healing items and wider random-duration ranges for certain item effects — not a better chance to hit or be hit.

Clone this wiki locally