Expand description
Native Rust fight logic.
These are the pure-Rust fight primitives (attack, try_cast,
spawn_wave, …) used by the native combat ports in
crate::behaviors. Results are emitted through the FightSink
abstraction and effect reactions through the EffectCb abstraction; the
shipped reactions live in crate::mechanics::effect_cb::OverlordEffectCb.
Structs§
- Attack
Params - Typed form of the
attackparams. - Between
Wave Behavior - Per-fight behavior selected for a normal wave transition. Dungeon overrides are independent: omitting either field preserves that standard behavior.
- Native
Sink - Sink that collects fight results as typed values for native callers. Mirrors
start_behaviors fillcasts. - Noop
Effect Cb - Effect callback that does nothing — for callers that don’t want effect reactions dispatched.
- Origin
Sink - Sink decorator that stamps the provenance of everything a producer emits, and refuses whatever it cannot stamp.
- Spell
Heal Params - Typed form of the
spell_healparams. - Wave
Entity Power - Wave
Fight Data - Typed form of the
fight_dataprepare-fight blob fed tospawn_wave. - Wave
Spawn
Enums§
- Once
Slot - The independent one-shot budgets a single dispatch can claim.
Constants§
- BATTLEFIELD_
HEIGHT - BOSS_
OUTGOING_ EQUIVALENCE_ PPM_ ATTR - Parts-per-million multiplier preserving A2-BAL-001’s measured, previously
shipped boss outgoing budget after the hidden automatic stun was removed.
Read only by
attackafter the full hit payload is composed. - COUNTERATTACK_
PROJECTILE - DERIVED_
DAMAGE_ KEY - Damage-payload key marking a hit as a DERIVED copy of a cast (support-stone Split / Chain / Pierce / Repeat / Pulse) rather than an original Core hit. Anything that reacts to combat events (laws, resonance, mastery, triggers) must skip a payload carrying this key.
- FORMATION_
ADVANCE_ CELLS - Between-wave formation dash distance in logical cells. Advancing fights assign waves 2+ against the player’s landing column (current + this).
- GUARD_
CHARGES_ ATTR - Entity attributes behind the two defensive supports.
guard_chargescounts pending Fortify charges,guard_reductionis the reduction of the next hit in ×10000 units (3000 = −30%). Shelter needs no attribute of its own: it is a plain timedreceived_damage.mod. - GUARD_
REDUCTION_ ATTR - MELEE_
COL_ OFFSET - RANGED_
COL_ OFFSET
Traits§
- Effect
Cb - Invokes an effect’s
on_apply/on_changereaction. - Fight
Sink - Where a fight method emits its results.
Functions§
- add_
entity_ attr - Native:
ctx.add_entity_attr(entity, attr, value)— push anIncrAttribute - add_
entity_ stat_ mod - Native:
ctx.add_entity_stat_mod(entity, stat, value)— push anIncrAttributeon"{stat}.mod"byvalue. Mirrors the engine’sadd_entity_stat_mod(which lowers toadd_entity_attr(entity, "{stat}.mod", value)); used by the native effect-callback dispatcher to replicate the - apply_
entity_ effect - Native: apply
effect_codetotargetforduration_seconds(converted to ticks). Effecton_applyreactions are dispatched througheffects. - apply_
entity_ over_ time_ effect - Native: apply a damage-/heal-over-time effect (
kind="dot"/"hot"), splittingamountover 5 ticks. No effect callbacks, no RNG. - attack
- Native: perform an attack from
casterontarget. Returns the floored damage dealt (None=> the no-damage paths: evasion, or nopowergiven). RNG is consumed in the exact original order: evasion, counterattack_chance, deceit (+randint(0,2)if it lands), crit_chance, thendamage_entity’s block roll. - between_
wave_ behavior - Resolves per-dungeon wave behavior without adding state to
ActiveFight. Campaign fights and dungeons without overrides keep the shipped 500 ms spawn pause and formation advance. - cast
- Native: queue
castsattack actions forcasteragainstvalid_targets. Consumesmulticast_chancefromrng, then (per cast after the first, when there are multiple targets) arandintfor target selection._abilityis unused, matching the original signature. - change_
entity_ effect_ duration - Native: add
durationticks ofeffect_codetotarget(capped at the effect’smax_duration_ticks), emittingEntityApplyEffecton first application and dispatching the effect’son_applyreaction. - damage_
entity - Native: apply
raw_dmgtoentity(armor, shield, block roll, received damage multiplier). Returns the floored post-mitigation damage value;Noneonly for the no-damage early-outs (godmode/ a missingreceived_damagebase value — a content-extraction regression), which short-circuit before the block roll. When a shield fully absorbs the hit the function still returnsSome(floored_damage)(and emits the shield decrement) — this value drivesattack’s return / lifesteal, so it must not beNoneor the caller would discard the shield event. Consumes oneblockstat_throwfromrngwhen it is reached. - entity_
run - Native: move
entitytoward the enemy line in a single multi-cell run (oneStartMoveinstead of one per cell — every per-cell seam quantizes to the 100ms game tick and gives the client a chance to stutter). - entropy_
throw - Entropy-based proc check (PoE-style). Instead of an independent roll per check, each (entity, stat) keeps an accumulator seeded 0..9999 from the fight RNG on first use; every check adds the chance (permyriad) and the proc fires exactly when the accumulator crosses 10000. The expected proc RATE is identical to independent rolls; streaks — lucky and unlucky — are eliminated, which is the variance compensation that makes proc stats (crit/dodge/multicast/ block/counter) safe to value at full expected-value price in the honest scalar (research: PoE entropy, verified 3-0).
- entropy_
throw_ p - Entropy variant for a probability that is already a fraction (0..1) rather than a permyriad stat — the dodge DR curve’s output.
- formation_
step_ duration_ ticks - Duration of an ally formation run over
cellslogical cells (the promotion step, the between-wave dash fallback) at the standard ally pace. - gated_
release_ row - Row for a death-gated mob at RELEASE time: the least-occupied row of its
own column, counting living enemies standing on it, running to it, or
parked pending arrival at the same park column (exit-cooldown waiters and
same-tick earlier releases — their park
yIS their landing row). Ties prefer the mob’s authored row, then the middle — so the freed space is taken instead of stacking onto survivors. - get_
entity_ stat ctx.get_entity_stat(entity, "armor")— applies attribute base value (from content_raw), additivebonus, and multiplicativemod(+10000 == +1.0).- heal_
entity - Native: heal
entity, capping at its missing HP. Returns the applied heal (Noneif no heal was applied).by_entity_idandsourceare the breakdown attribution — who healed, and with what. - init_
fight - Native: emit the per-entity init events for a fight (regen effect, low-chapter
effect, party power adjustment, dungeon/boss talent attack mods). No RNG, no
effect callbacks.
fightsupplies player/party ids + the entity roster +party_adjusted_power; reads talent levels / chapter fromstate. - later_
wave_ entrance_ floor_ ticks - Entrance floor shared by the live slot scheduler and the balance mini-sim. Stationary dungeons have no artificial formation wait.
- on_cast
- Native: the ability
on_casthook. Rollsbravery; on success applies a random buff (protection/empower). Consumesbraverythen (if it lands) arandint(0,2)fromrng. Effecton_applyreactions dispatch viaeffects. - over_
time_ tick_ source - The source an over-time tick of
kindcarries: the ability recorded by the last applier, orfallbackwhen none was. - remove_
entity_ effect - Native: remove all stacks of
effect_codefromtarget, dispatching the effect’son_changereaction with(new_stacks=0, old_stacks=current). - screen_
shake - Native: emit a
screen_shakevisual event. - set_
entity_ attr - Native:
ctx.set_entity_attr(entity, attr, value)— push anIncrAttributethat moves the attr TOvalue(delta =round(value - current)). Emitted - slot_
promotion_ needed - Slot-model promotion predicate (docs/combat-grid-migration-plan.md §2.2):
the ally formation steps one column forward when the near (melee) column
holds no living enemy while the far column does. An enemy’s effective
column is where it stands or is running to (
move_target); units still parked beyond the far column (waiting out their exit cooldown behind the screen edge) do not count — stepping toward them would drag the hero to the spawn edge. Recursion needs no special code: after a step the old far column IS the near column, and the next death/landing re-checks. - spawn_
wave - Native: the
prepare_fightinterpreter. Computes normalised enemy stats from the chapter power curve + the typed wave blob, then emits spawn events for the current wave. RNG is consumed once per spawned enemy (the spawn-entity uuid), in iteration order — identical to the original.fightsuppliescurrent_wave+ the liveentities(for the multi-wave x-offset). - spell_
heal - Native: heal
targetfromcaster’s attack stat. Returns the applied heal (Nonewhen no heal). Consumescrit_chancefromrng(unlessis_critis forced), thenheal_entity’s path (no RNG). - stat_
throw - stat_
throw_ scaled stat_throwwith the success probability multiplied byscale— the sigmoid-steepening experiments dial down binary per-hit RNG (crit) without touching entity stats.scale = 1.0is byte-identical to the unscaled throw (same single RNG draw for any positive stat).- touch_
enemy - Native: returns whether
targetis touched (i.e. did NOT evade). Balance v2: dodge probability follows the DR curveev/(ev+K_DODGE)(asymptote < 100%, no 100%-dodge cliff). Attribute-balance track: the dodge OUTCOME is resolved through the entropy accumulator, not an independent roll — a 20% dodge evades exactly every 5th incoming touch, never streaks (the variance compensation that makes evasion safe to grant as a live stat). - try_
cast - Native: attempt to cast
ability_idfromcaster. Picks valid targets and delegates tocast; if there are none and the caster is notstatic, advances toward the enemy.castsis the natural cast count (default 1). Consumes RNG only viacast/advance_entity. - wave_
data_ from_ config - Convert the typed config mirror (
prepare_fight_waves) into the runtimeWaveFightDataconsumed byspawn_wave. This is the native data source for the prepare_fight interpreter.