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. - 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.
- 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
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 - advance_
entity - 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). - 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. - 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: emit a run action moving
entitytoto(no-op if speed is 0 or the move covers no distance). - 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). - 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. - 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. - 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 - 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 - 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) instead of the old linearev/10000. Consumes exactly onerngdraw iff the target has positive evasion rating — matching the oldstat_throw’s “draw only when stat > 0” so draw-count is preserved. - 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.