saumwacht-godot/scripts/combat/attack_component.gd
Martin Stickelbroeck c2b447610c Baseline: Saumwacht 0.15.0 (Phase 20A) vor dem Umbau zu Champions of Luneraria
Unveränderter Ausgangsstand inklusive Masterprompt und Konzeptbildern
unter assets/. .godot/ und docs/screenshots/ bleiben laut .gitignore
unversioniert; letztere sind unter ../backups gesichert.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-27 20:00:36 +02:00

27 lines
982 B
GDScript

extends RefCounted
## Only primary attacks advance the hit counter. Extra damage never recurses.
var progress: float = 0.0
var hit_count: int = 0
func step(unit, combatants: Array, delta: float) -> void:
if not is_instance_valid(unit.target) or not unit.target.alive:
progress = 0.0
return
if unit.distance_to_unit(unit.target) > float(unit.data.attack_range) + 0.035:
progress = 0.0
return
progress += delta * unit.attack_speed_factor()
while progress >= 1.0 - 0.000001 and unit.alive and unit.target.alive:
progress = maxf(0.0, progress - 1.0)
hit_count += 1
var target = unit.target
var damage = float(unit.data.damage) * (1.0 + unit.damage_bonus())
if hit_count % 4 == 0:
if str(unit.data.ability) == "g05":
damage *= 1.5
elif str(unit.data.ability) == "g06":
damage *= 1.75
target.receive_damage(damage, int(unit.data.attack_type))
unit.play_attack(target.position)
unit.ability_component.on_hit(unit, target, combatants, hit_count)