Closes the two open issues and lands the pending unreleased batch: - #90: `Sprite { atlas: 1 }` routes esys_sprite through atlas_draw_ex (scale/flip/tint), so cell / cell_span / strip ids of any size draw through the engine sprite-render system. examples/library/sprite_atlas is the pixel-readback regression. - #91: `become` from an @On(Event) listener / global handler / plain function no longer segfaults the compiler; it emits @L_scene_leave() (a dispatch on the live scene id) so the leaving scene's on-exit runs. UI_* handles are readable from any code (widget table built on first use). examples/library/scene_menus covers it. - fix: a windowed `ludicc -o` build that reaches the audio runtime only through the atlas/Assets preload import now links audio.ll + AVFoundation (the audio backend link was gated on a game-level Audio.* call, so any windowed game declaring Sprite failed to link). - the hand-written "Unreleased" CHANGELOG section is converted to changesets under changes/ so `x release` generates it. - plus the batch: engine-driven retained UI + UiClicked event, Overlay phase, TileSkin tilemap-render system, Key.* constants, Font/Ui/File namespaces, Sprite.strip, prefabs, managers, countdown fields, enum-typed machines, layer @Queries, ludic.prefs / ludic.dungeon packages, Ai.seek pathing, Solids.solid2, cursor confine (mode 3) fix, shooter centre-aim fix, reserved-word function diagnostic. Verified: x test (124/124), x test-tools, check-impl, check-vocabulary, check-docs, docs-gen + docs-check, bootstrap-cfree (seed is a fixpoint). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
e9c2c51bc3
commit
ad548840c7
139 changed files with 58981 additions and 43671 deletions
|
|
@ -21,6 +21,9 @@ event cancellable DamageAboutToApply { target: int = 0, src: int = 0, amount: in
|
|||
event Damaged { target: int = 0, src: int = 0, amount: int = 0 }
|
||||
event Died { e: int = 0, src: int = 0 }
|
||||
event Healed { e: int = 0, amount: int = 0 }
|
||||
event Crit { target: int = 0, src: int = 0 } # the attacker's crit_pct fired
|
||||
|
||||
var combat_reflecting: bool = false # thorns never reflect thorns
|
||||
|
||||
# the mutable channel for lever 6: listeners rewrite the pending damage here.
|
||||
var combat_pending: int = 0
|
||||
|
|
@ -47,7 +50,11 @@ var combat_pending: int = 0
|
|||
let fhp = World.field_id(P, "hp")
|
||||
if fhp < 0 { return 0 }
|
||||
|
||||
combat_pending = combat_mitigate(target, amount)
|
||||
# the attacker's build: damage_pct, then a crit_pct chance to double
|
||||
var raw = amount * stats_field(src, "damage_pct", 100) / 100
|
||||
let crit = stats_field(src, "crit_pct", 0)
|
||||
if (crit > 0) and Random.chance(percent: crit) { raw = raw * 2; emit Crit(target: target, src: src) }
|
||||
combat_pending = combat_mitigate(target, raw)
|
||||
if emit DamageAboutToApply(target: target, src: src, amount: combat_pending) != 0 { return 0 }
|
||||
var dmg = combat_pending
|
||||
if dmg < 0 { dmg = 0 }
|
||||
|
|
@ -57,6 +64,17 @@ var combat_pending: int = 0
|
|||
World.set(target, P, fhp, hp)
|
||||
emit Damaged(target: target, src: src, amount: dmg)
|
||||
if hp <= 0 { emit Died(e: target, src: src) }
|
||||
# the attacker's leech, and the defender's thorns (never reflected back again)
|
||||
if dmg > 0 {
|
||||
let leech = stats_field(src, "leech_pct", 0)
|
||||
if (leech > 0) and Random.chance(percent: leech) { combat_heal(src, stats_field(src, "leech_hp", 1)) }
|
||||
let thorns = stats_field(target, "thorns", 0)
|
||||
if (thorns > 0) and (src != target) and (not combat_reflecting) and (World.has(src, P) != 0) {
|
||||
combat_reflecting = true
|
||||
combat_damage(src, target, thorns)
|
||||
combat_reflecting = false
|
||||
}
|
||||
}
|
||||
return dmg
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,11 +10,58 @@
|
|||
# Stat codes (the `stat` argument everywhere below):
|
||||
# 0 = max_hp 1 = atk 2 = def 3 = spd 4 = max_mp
|
||||
|
||||
enum StatKind { MaxHp, Attack, Defense, Speed, MaxMp, DamagePct, CritPct, LeechPct, Thorns, FireRatePct } # Stats.* stat codes
|
||||
enum ModifyOp { Flat, Percent } # Stats.modify op
|
||||
# The build stats Combat.damage applies by itself: the attacker's damage_pct and
|
||||
# crit_pct (a crit doubles), its leech_pct chance to heal leech_hp on a hit, the
|
||||
# defender's thorns dealt back, and fire_rate_pct the weapon system reads.
|
||||
property Stats {
|
||||
hp: int = 0, max_hp: int = 0,
|
||||
mp: int = 0, max_mp: int = 0,
|
||||
atk: int = 0, def: int = 0, spd: int = 0,
|
||||
level: int = 1, xp: int = 0
|
||||
level: int = 1, xp: int = 0,
|
||||
damage_pct: int = 100, crit_pct: int = 0, leech_pct: int = 0, leech_hp: int = 1, thorns: int = 0, fire_rate_pct: int = 100
|
||||
}
|
||||
|
||||
# a Stats field of an entity by name, or `fallback` when absent
|
||||
function stats_field(e: int, name: pointer, fallback: int) -> int {
|
||||
let P = World.prop_id("Stats")
|
||||
if (P < 0) or (World.has(e, P) == 0) { return fallback }
|
||||
let f = World.field_id(P, name)
|
||||
if f < 0 { return fallback }
|
||||
return World.get(e, P, f)
|
||||
}
|
||||
# the Stats field a stat code names
|
||||
function stats_field_name(stat: int) -> pointer {
|
||||
match stat {
|
||||
StatKind.MaxHp => { return "max_hp" }
|
||||
StatKind.Attack => { return "atk" }
|
||||
StatKind.Defense => { return "def" }
|
||||
StatKind.Speed => { return "spd" }
|
||||
StatKind.MaxMp => { return "max_mp" }
|
||||
StatKind.DamagePct => { return "damage_pct" }
|
||||
StatKind.CritPct => { return "crit_pct" }
|
||||
StatKind.LeechPct => { return "leech_pct" }
|
||||
StatKind.Thorns => { return "thorns" }
|
||||
_ => { return "fire_rate_pct" }
|
||||
}
|
||||
}
|
||||
# Stats.add(e, stat, amount): change a base stat in place (a permanent upgrade)
|
||||
@Namespace(Stats) function stats_add(e: int, stat: int, amount: int) -> void {
|
||||
let P = World.prop_id("Stats")
|
||||
if (P < 0) or (World.has(e, P) == 0) { return }
|
||||
let f = World.field_id(P, stats_field_name(stat))
|
||||
if f >= 0 { World.set(e, P, f, World.get(e, P, f) + amount) }
|
||||
}
|
||||
# Stats.scale_hp(e, percent): hp and max_hp scaled (a floor's difficulty)
|
||||
@Namespace(Stats) function stats_scale_hp(e: int, percent: int) -> void {
|
||||
let P = World.prop_id("Stats")
|
||||
if (P < 0) or (World.has(e, P) == 0) { return }
|
||||
let fhp = World.field_id(P, "hp")
|
||||
let fmax = World.field_id(P, "max_hp")
|
||||
let hp = World.get(e, P, fhp) * percent / 100
|
||||
World.set(e, P, fhp, hp)
|
||||
World.set(e, P, fmax, hp)
|
||||
}
|
||||
|
||||
# a single timed modifier, carried on its own entity so the stack is dynamic.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue