Files
isaac-port/notes/systems/rules_player.md
T
2026-10-26 11:28:39 -04:00

9.9 KiB

Rules research: player (health/damage, movement, tears, stat formulas)

Flash = isaac-classic's engine + base data (resources/data/*.json); Rep+ = this exe. Times: Rep+'s game runs 30 ticks a second, but Entity_Player::Update runs twice a tick (Game::interpolate_update 0x6fd3f0 calls the player's Update with EntityFlag 0x4000 on the odd render frames, every other entity only gets Interpolate). So every player counter decremented in Update (_damageCooldown +0x13bc, _controlsCooldown) and the movement step is 60 Hz: divide by 2 for the engine's 30 Hz ticks. Confirmed by Holy Mantle's 60 (0x3c) = repentance_plus hit_block immunity_duration 30.

Damage amount (Entity_Player::TakeDamage 0x7729d0, asm 0x773c2f..0x773dfc)

  • halves = int(amount + 0.5) ([EBP-0x140], kept raw for the cooldown below).
  • Unless DAMAGE_NO_MODIFIERS (0x2000000): not in Greed mode (Game::IsGreedMode 0x6f8120 jumps past) and (Level stage (0x40c3a0, ICF-named EntityPtr::Ref) >= 7 or Game::GetVictoryLap >= 1 or Level::IsAscent 0x74f090): halves = max(halves, 2). Stage 7 = Womb I / Utero / Scarred Womb / Corpse I: same as player.json late_chapter_start 7 / late_chapter_minimum 1. Differences: Greed has no minimum at all; the Ascent always has it.
  • Then: Wafer 0x6c (or its effect), Cancer trinket 0xe mult > 2, source EntityRef flag 4, or Dogma 0x279 outside hard mode: halves > 1 -> max(1, int(halves * 0.5 + 0.5)) (items). Null effect 0x1d: max(halves, 2). Health type 3 (coin, Keeper): halves = 2. Timed sets 0x2f / 0x30: max 2 / max 24.
  • No hard-mode change to any player damage (the only IsHardMode test is Dogma's). Game+0x26614 > 1 (FUN_00429550, scale_for_hard_difficulty 0x7dd380, damage_cooldown_scale 0x7db330) is the deathmatch mode, not hard mode.
  • Sources: NPC contact = its _collisionDamage (entities2.xml collisionDamage, 1 = half heart; matches Flash contact_damage for nearly all shared enemies), Entity_Projectile::HandleCollision 0x65b670 = projectile _collisionDamage (default 1 = half: entities.json projectiles damage 0.5, same).

Hazards

  • Spikes (GridEntity_Spikes::Update 0x71e9b0 -> GridEntity::hurt_surroundings 0x70b170 -> hurt_func 0x709fb0): player damage 2 halves (1 heart, = rooms.json spike_damage 1), radius 11 + entity size, NPC damage 8, flags DAMAGE_SPIKES 0x80; in the sacrifice room (type 13) flags 0x10000080 (+ NO_PENALTIES) and grid collision class ignored (flyers hit). Callus (trinket 0xe) / 0x23b immune. Sacrifice payouts are in hurt_func (not this note).
  • Curse room door (GridEntity_Door::Update 0x70c5c0): TakeDamage(1 half, 0x10010000 = CURSED_DOOR | NO_PENALTIES) to a player in the door box who is on the ground (grid class 5), or anyone while inside the curse room (type 10). = doors curse_damage 0.5; the stage minimum still applies (no NO_MODIFIERS).
  • Grid fire (GridEntity_Fire::Update 0x67e0f0): hurt_surroundings(38, 38, NPC 16, player 1 half, DAMAGE_FIRE 2) = fire_damage 0.5. Fireplace entities (type 33, all variants) collisionDamage 1 = half.
  • Enemy creep (Entity_Effect::Update shared creep case, dogma_effects.md): TakeDamage(1 half, DAMAGE_ACID 0x10) to ground players. Flash: rooms.json hazards creep_damage 1 (a full heart) and entities.json creep contact_damage 1.
  • NO_PENALTIES (and RED_HEARTS 0x20) hits skip isPenalized (TakeDamage: (flags & 0x10000020) == 0): no room damage count, no Level/Room red-heart-damage flag (devil chance), no SetLastLevelWithDamage.

Heart order (TakeDamage ~decompile lines 2205-2460)

Matches the engine's player_hurt already: red first only for DAMAGE_RED_HEARTS 0x20 or Crow Heart (0x6b) when red >= damage; else the soul halves after the last bone heart (min(damage, those): no spill), black hearts popped as their odd (left) half goes (IsBlackHeart 0x759220 tests odd half index) -> RemoveBlackHeart 0x7591e0 + UseActiveItem(0x23 Necronomicon) + sound 0x50; eternal heart takes 1 half when red < 1, bone < 1 and the hit empties the souls; else the last bone heart breaks (unless it holds red: then damage = min(damage, red in it)); else red (rotten hearts whole first, eternal -1 half). Golden hearts break as filled hearts drop (BreakGoldenHearts).

Damage cooldown (invulnerability)

  • After a counted hit (asm 0x778626..0x778669): _damageCooldown = damage_cooldown_scale(min(rawHalves, 2) * 60) at 60 Hz = 30 ticks for a half heart, 60 for a heart or more (raw: before the stage minimum, so a Womb half-heart hit raised to a heart still gives 30). Flash: struck hearts (after the minimum) x immunity_per_heart 60, uncapped (a 2-heart hit 120 ticks).
  • Blind Rage (trinket 0x51): x 2 x multiplier. Holy Mantle block (0x139 effect): 60 (30 ticks). Hallowed ground / Jelly Belly / blocked hits: SetMinDamageCooldown(8) (4 ticks) or 60.
  • Room entry: nothing resets it (TriggerNewRoom_TemporaryEffects 0x7a8350 and RoomTransition::ChangeRoom 0x830950 don't touch it except a crawlspace exit's max(cooldown, 35)): the remaining cooldown carries into the next room. Flash: more than blink_end_duration 6 ticks left -> 50 fresh ticks (room_entry_immunity_duration), else none.
  • Blink (Entity_Player::Render 0x78ca00): not drawn while cooldown % 6 < 3 (60 Hz): a 3-tick period, hidden half of it, to the last tick, and not while an extra animation plays. Flash: hidden 2 of every 3 ticks while more than 6 left.
  • No controls cooldown at room entry (only Teleport 3 updates, pills 120/240); Flash ignores input for room_entry_duration 20 ticks (Rep+'s transition freezes the game instead; unverified equivalence).

Movement (Entity_Player::update_body_animations 0x779b40, 60 Hz; NPCAI_Pathfinder::SimulatePlayerMovement 0x7e8010

is its 30 Hz form: v/2, two steps, x2)

Per update: joystick clamped to length 1; in = joy * (0.75 + 0.25 speed); with input, proj = in (v . in) (in is NOT unit: |in|^2 enters) and v = proj + (v - proj) sqrt(0.8); a = (max(0, -0.2 (v . in)) / speed + 3) * 0.4; v += in * 0.5 * a; v *= sqrt(0.775) (slippery: lerps to 0.96 retention, 0.5 reverse, 0.25 accel; Tainted Lost/suplex 0.45..0.96); then Entity::Update 0x6ae820: v *= friction (player 1), pos += v. Gravity cells: no y input, vy += 0.225 instead of the y retention.

Flash (player_movement.cpp, player.json movement): one step a tick, in = keys * (0.75 + 0.25 speed), diagonal x0.7071; one axis held: other axis *= 0.5 (turn_retention), boost = |other| * 0.03 + max(0, -(in . v)) * 0.2; v += in * (3 + boost / speed) * 0.8; v *= 0.7 + 0.075 speed.

Simulated (px a 30 Hz tick, holding right from rest): speed 0.5 Rep 6.54 / Flash 5.90; speed 1 Rep 8.83 / Flash 8.27 (both 90% in 10 ticks; retention 0.775 a tick in both at speed 1); speed 1.5 12.51 / 11.70; speed 2 19.59 / 17.00. Stop distance at speed 2: Rep 72 / Flash 96 (Rep's retention does not grow with speed; the |in|^2 projection does).

Shot launch (Weapon_Tears::Fire 0xa0a720, Entity_Player::GetTearMovementInheritance 0x7aaea0,

GetMultiShotPositionVelocity 0x782160, FireTear 0x790af0)

  • base = aim * 10 + inherit; inherit = _lastVelocity * 0.6 * 2 (the 60 Hz velocity doubled = 0.6 of a tick's motion), minus its component along the aim when that component is negative (moving away from the shot adds nothing backwards). Marked / tears offset with 0x145/0x2d9: none. Each tear: velocity = rotated base * shotspeed. No raise to a minimum speed (Flash: tears/speed 10, slower aims raised to 10) and no per-axis velocity jitter (Flash velocity_jitter 0.01). Ipecac x(0.9 + 0.2 r).
  • Eye offset: firePos += eye * perp(base) * (0.3 + 0.2 r) (= Flash eye_offset 0.3 + 0.2 random).
  • Fall: fallingSpeed = r * 0.2 - _tearfallspeed (0..+0.2; Flash fall_jitter 0.2 is centred, -0.1..+0.1).
  • Launch height: always _tearheight (EvaluateItems: -23.75 base, items move it, capped at -5) with the starting fall solved by FUN_0067da40 (h, range px, shotspeed*10, fallaccel): n = range / (10 shotspeed), k = max(9.4912 (1 - 0.9^n), 0.01), fall0 = ((-5 - h) - (10 accel + 1)(n - k)) / k; _tearfallspeed = -fall0 (fall retention 0.9, gravity 0.1 + accel, ground -5, the 9.49 = 0.9^0.5 / 0.1 half-tick). The engine's is_range_in_tiles instead varies the height with no fall of its own.
  • Multishot (Inner Eye etc.) is angular fans (GetMultiShotParams 0x781b90): items' business.

Tear knockback (Entity_Tear::HandleCollision 0x673660)

Pooter (14) / attack fly (18) hit by a tear without the piercing/spectral group flags (DAT_00c34b50 | DAT_00c34910): fly velocity += tear velocity * 0.5 (Flash: fly_retention 0.5, damping by fly_speed_scale/base). The general push of other enemies is the entity collision pass (mass, the tear's _mass x GetTearHitParams' mass factor and _knockbackMultiplier +0x460): unverified, not found in Entity_NPC::TakeDamage 0x6d60a0 or Entity::TakeDamage 0x6ace60.

Stat formulas (Entity_Player::EvaluateItems 0x763570; final clamps asm 0x7704b7..0x770554)

  • Fire delay: 16 - 6 sqrt(max(0, 1.3x + 1)) - 6 min(x, 0), at least 5; fire rate 30 / (delay + 1); then flat rate ups and multipliers; final delay >= -0.75. = Flash's curve (base 10 + 6 (1 - sqrt(1 + 1.3x)) - 6 min(x,0), floor 5).
  • Damage: 3.5 sqrt(max(0, 1.2x + 1)) (times character), final max(damage, 0.5). Flash: max(0, ...).
  • Speed: 1 + all ups and downs (characters included), final clamp [0.1, 2.0] (one achievement bonus added after). Flash: base + min(maximum_speed_bonus 1, ups) + speed_after_cap + room bonus, no floor.
  • Shot speed: final max(0.6, ...), no maximum (Flash clamps to 0.6..1.42).
  • Range: final max(40 px, ...) (= engine's one-tile floor); tear height capped at -5.
  • No hard-mode damage compression (Flash's stat_formulas hard_damage / hard_delay_*).
  • Heart limit (GetHeartLimit 0x7cae60): 24 halves (12 hearts) whatever the difficulty (Maggy's Birthright +12). Flash: normal_health_cap 12, hard_health_cap 16.

Player body

entities2.xml Player: collisionRadius 10, mass 5, friction 1 (= entities.json player 10 / 5). Tear radius 7 (Flash 8), mass 8 (same). Contact separation with enemies: not read (unverified).