class_name CombatFX extends Node2D ## Decorative world-space effects for player and enemies. ## No collisions, timers or damage are changed by this file. ## Colors are shared with the new illustrated-metal art direction: ## dark outlines, warm metallic highlights, controlled saturated accents. const OUTLINE = Color(0.07, 0.08, 0.13) const PALE_GOLD = Color(1.0, 0.90, 0.63) const DUST_BROWN = Color(0.55, 0.46, 0.39) const ELECTRIC_BLUE = Color(0.28, 0.65, 0.96) const ELECTRIC_WHITE = Color(0.85, 0.97, 1.0) const VOCAL_GOLD = Color(1.0, 0.72, 0.18) const BASS_PURPLE = Color(0.58, 0.36, 0.87) var kind: StringName = &"hit" var direction: float = 1.0 var radius: float = 54.0 var _age: float = 0.0 var _lifetime: float = 0.28 ## Creates a transient effect at a fixed world position (not parented to an actor). static func spawn(parent: Node, origin: Vector2, effect_kind: StringName, effect_direction: float = 1.0, effect_radius: float = 54.0) -> void: if not is_instance_valid(parent): return var effect: CombatFX = CombatFX.new() effect.kind = effect_kind effect.direction = effect_direction effect.radius = effect_radius parent.add_child(effect) effect.global_position = origin func _ready() -> void: z_index = 12 # The sprites are illustrated at high resolution; procedural FX should not # introduce blocky sawtooth edges at the game's 2x camera zoom. texture_filter = CanvasItem.TEXTURE_FILTER_LINEAR match kind: &"ground_pound", &"electric_pound", &"vocal_dome", &"bass_cracks": _lifetime = 0.60 &"solo", &"vocal_wave", &"drum_cymbals", &"bass_pulse": _lifetime = 0.62 &"death", &"break": _lifetime = 0.48 &"dust": _lifetime = 0.32 func _process(delta: float) -> void: _age += delta if _age >= _lifetime: queue_free() return queue_redraw() func _draw() -> void: var progress: float = clampf(_age / _lifetime, 0.0, 1.0) var fade: float = (1.0 - progress) * (1.0 - progress * 0.18) match kind: &"electric_pound": _draw_electric_pound(progress, fade) &"vocal_dome": _draw_vocal_dome(progress, fade) &"bass_cracks": _draw_bass_cracks(progress, fade) &"vocal_wave": _draw_vocal_wave(progress, fade) &"drum_cymbals": _draw_drum_cymbals(progress, fade) &"bass_pulse": _draw_bass_pulse(progress, fade) &"ground_pound": _draw_ground_pound(progress, fade) &"solo": _draw_solo(progress, fade) &"dust": _draw_debris(progress, 7, DUST_BROWN, 23.0, fade * 0.7) &"break": _draw_debris(progress, 14, Color(0.67, 0.42, 0.27), 52.0, fade) _draw_debris(progress, 6, Color(0.67, 0.67, 0.69), 34.0, fade) &"death": _draw_death(progress, fade) &"swing": _draw_swing(progress, fade) _: _draw_hit(progress, fade) func _alpha(color: Color, opacity: float) -> Color: return Color(color.r, color.g, color.b, clampf(opacity, 0.0, 1.0)) func _stroke(points: PackedVector2Array, outer: Color, inner: Color, outer_width: float, inner_width: float, fade: float) -> void: if points.size() < 2: return draw_polyline(points, _alpha(outer, fade), outer_width, true) draw_polyline(points, _alpha(inner, fade), inner_width, true) ## An elliptical perspective ring with an ink border and a light upper lip. func _draw_ring(ring_radius: float, height_ratio: float, color: Color, width: float, fade: float = 1.0) -> void: var rim := PackedVector2Array() var highlight := PackedVector2Array() for index: int in range(49): var angle: float = TAU * float(index) / 48.0 var point := Vector2(cos(angle) * ring_radius, sin(angle) * ring_radius * height_ratio) rim.append(point) if index >= 24 and index <= 48: highlight.append(point + Vector2(0.0, -0.8)) _stroke(rim, OUTLINE, color, width + 2.5, width, fade) if highlight.size() > 2: draw_polyline(highlight, _alpha(PALE_GOLD, fade * 0.36), 0.8, true) ## Stable, non-random debris. Different silhouettes/velocities avoid a square cloud. func _draw_debris(progress: float, count: int, color: Color, spread: float, fade: float) -> void: for index: int in range(count): var side: float = -1.0 if index % 2 == 0 else 1.0 var speed: float = 0.34 + float(index % 5) * 0.145 var height: float = 11.0 + float(index % 4) * 7.0 var x: float = side * spread * progress * speed var y: float = -height * sin(progress * PI) - 1.5 var size: float = 1.9 + float(index % 3) * 0.75 var point := Vector2(x, y) var fragment := PackedVector2Array([ point + Vector2(-size, 0.0), point + Vector2(size * 0.20, -size * 1.3), point + Vector2(size, size * 0.35), point + Vector2(-size * 0.25, size * 0.85)]) draw_colored_polygon(fragment, _alpha(color, fade)) fragment.append(fragment[0]) draw_polyline(fragment, _alpha(OUTLINE, fade * 0.72), 1.0, true) func _draw_sparks(progress: float, color: Color, count: int, spread: float, fade: float) -> void: for index: int in range(count): var angle: float = TAU * (float(index) + 0.18 * float(index % 3)) / float(count) var axis := Vector2(cos(angle), sin(angle)) var distance: float = spread * progress * (0.68 + float(index % 4) * 0.11) var point: Vector2 = axis * distance + Vector2(direction * 4.0 * progress, 0.0) var tail: Vector2 = point - axis * (3.0 + 7.0 * (1.0 - progress)) _stroke(PackedVector2Array([tail, point]), OUTLINE, color, 3.3, 1.7, fade) if index % 3 == 0: draw_circle(point, 1.1, _alpha(PALE_GOLD, fade)) ## Curved eighth note: deliberately not a blocky 5x4 sprite. func _draw_note(point: Vector2, color: Color, fade: float) -> void: draw_set_transform(point, -0.18, Vector2.ONE) draw_circle(Vector2(-2.0, 3.0), 3.1, _alpha(OUTLINE, fade)) draw_circle(Vector2(-1.9, 2.9), 2.1, _alpha(color, fade)) _stroke(PackedVector2Array([Vector2(0.1, 2.0), Vector2(0.1, -10.0), Vector2(5.7, -8.0), Vector2(7.2, -4.1)]), OUTLINE, color, 2.4, 1.1, fade) draw_set_transform(Vector2.ZERO, 0.0, Vector2.ONE) func _draw_hit(progress: float, fade: float) -> void: var scale: float = 0.45 + progress * 0.9 var center := Vector2(direction * 5.0 * progress, 0.0) var burst := PackedVector2Array() for index: int in range(16): var angle: float = TAU * float(index) / 16.0 var length: float = (12.0 if index % 2 == 0 else 4.7) * scale burst.append(center + Vector2(cos(angle), sin(angle)) * length) draw_colored_polygon(burst, _alpha(Color(0.98, 0.60, 0.24), fade * 0.9)) burst.append(burst[0]) draw_polyline(burst, _alpha(OUTLINE, fade), 2.2, true) draw_circle(center, 3.9 * scale, _alpha(PALE_GOLD, fade)) _draw_sparks(progress, PALE_GOLD, 9, 27.0, fade) func _draw_death(progress: float, fade: float) -> void: _draw_sparks(progress, Color(1.0, 0.43, 0.30), 12, 37.0, fade) _draw_debris(progress, 8, Color(0.48, 0.26, 0.33), 39.0, fade) _draw_ring(lerpf(4.0, 25.0, progress), 0.82, Color(1.0, 0.72, 0.43), 2.4, fade) func _draw_swing(progress: float, fade: float) -> void: var outer := PackedVector2Array() var inner := PackedVector2Array() for index: int in range(16): var angle: float = lerpf(-1.05, 1.02, float(index) / 15.0) + progress * 0.42 outer.append(Vector2(cos(angle) * 22.0 * direction, sin(angle) * 21.0)) inner.append(Vector2(cos(angle) * 15.0 * direction, sin(angle) * 15.0)) _stroke(outer, OUTLINE, PALE_GOLD, 5.0, 2.9, fade) draw_polyline(inner, _alpha(Color(1.0, 0.50, 0.26), fade * 0.8), 1.6, true) func _draw_ground_pound(progress: float, fade: float) -> void: var reach: float = lerpf(8.0, radius, sqrt(progress)) _draw_ring(reach, 0.25, Color(1.0, 0.61, 0.28), 3.1, fade) _draw_ring(reach * 0.74, 0.30, PALE_GOLD, 1.7, fade * 0.7) _draw_debris(progress, 16, Color(0.75, 0.59, 0.45), radius, fade) for side: float in [-1.0, 1.0]: var fissure := PackedVector2Array([ Vector2(3.0 * side, 1.0), Vector2(13.0 * side, 3.0), Vector2(23.0 * side, -1.0), Vector2(36.0 * side, 2.0), Vector2(46.0 * side, 0.0)]) _stroke(fissure, OUTLINE, Color(0.92, 0.62, 0.39), 4.2, 1.4, fade * 0.9) func _draw_solo(progress: float, fade: float) -> void: var reach: float = lerpf(12.0, radius, progress) _draw_ring(reach, 0.68, Color(0.37, 0.80, 1.0), 3.0, fade) _draw_ring(reach * 0.80, 0.68, Color(0.80, 0.49, 0.94), 1.7, fade * 0.8) for index: int in range(9): var angle: float = TAU * float(index) / 9.0 - progress * 0.22 var point := Vector2(cos(angle), sin(angle) * 0.7) * reach _draw_note(point, Color(0.89, 0.83, 1.0), fade) if progress < 0.48: _draw_sparks(progress / 0.48, ELECTRIC_WHITE, 12, 35.0, fade) ## Diego: lightning branches and a hot contact halo, all purely decorative. func _draw_electric_pound(progress: float, fade: float) -> void: var reach: float = lerpf(10.0, radius, sqrt(progress)) _draw_ring(reach, 0.27, ELECTRIC_BLUE, 3.2, fade) _draw_ring(reach * 0.82, 0.31, ELECTRIC_WHITE, 1.1, fade * 0.6) for index: int in range(9): var angle: float = PI + PI * float(index) / 8.0 var axis := Vector2(cos(angle), sin(angle) * 0.72) var normal := Vector2(-axis.y, axis.x) var bolt := PackedVector2Array([Vector2.ZERO]) for step: int in range(1, 7): var fraction: float = float(step) / 6.0 var jitter: float = (-1.0 if (step + index) % 2 == 0 else 1.0) * (3.7 + step * 0.25) bolt.append(axis * reach * fraction + normal * jitter) _stroke(bolt, OUTLINE, ELECTRIC_BLUE, 6.2, 3.3, fade * 0.9) draw_polyline(bolt, _alpha(ELECTRIC_WHITE, fade), 1.25, true) var fork := PackedVector2Array([bolt[3], bolt[4] + normal * 8.0, bolt[5] + normal * 14.0]) _stroke(fork, OUTLINE, ELECTRIC_WHITE, 3.0, 1.2, fade * 0.85) _draw_sparks(progress, ELECTRIC_WHITE, 11, radius * 0.45, fade * 0.8) ## Hector: layered transparent sound dome, not an additional damage area. func _draw_vocal_dome(progress: float, fade: float) -> void: var reach: float = lerpf(5.0, radius, sqrt(progress)) var dome := PackedVector2Array() for index: int in range(49): var angle: float = PI + PI * float(index) / 48.0 dome.append(Vector2(cos(angle) * reach, sin(angle) * reach * 0.85)) draw_colored_polygon(dome, _alpha(VOCAL_GOLD, fade * 0.14)) _stroke(dome, OUTLINE, Color(1.0, 0.85, 0.34), 5.4, 2.7, fade) for ratio: float in [0.42, 0.73]: var seam := PackedVector2Array() for index: int in range(25): var angle: float = PI + PI * float(index) / 24.0 seam.append(Vector2(cos(angle) * reach * ratio, sin(angle) * reach * ratio * 0.85)) draw_polyline(seam, _alpha(PALE_GOLD, fade * 0.24), 1.1, true) _draw_ring(reach, 0.16, VOCAL_GOLD, 2.3, fade) ## Fer: inked floor fissures and violet resonant dust; no TileMap writes. func _draw_bass_cracks(progress: float, fade: float) -> void: var growth: float = minf(progress * 4.0, 1.0) for side: float in [-1.0, 1.0]: for branch: int in range(3): var crack := PackedVector2Array([Vector2.ZERO]) for step: int in range(1, 7): var x: float = side * radius * float(step) / 6.0 * growth var y: float = float(branch - 1) * float(step) * 1.8 y += 3.4 if (branch + step) % 2 == 0 else -3.4 crack.append(Vector2(x, y)) _stroke(crack, OUTLINE, BASS_PURPLE, 6.0, 1.8, fade) var fork := PackedVector2Array([crack[3], crack[4] + Vector2(side * 3.0, -6.0), crack[4] + Vector2(side * 9.0, -12.0)]) _stroke(fork, OUTLINE, Color(0.85, 0.72, 1.0), 3.0, 1.1, fade) _draw_debris(progress, 12, Color(0.61, 0.54, 0.67), radius * 0.7, fade) _draw_ring(lerpf(4.0, radius * 0.7, progress), 0.18, Color(0.68, 0.48, 0.94), 1.8, fade * 0.65) ## Hector: successive broad, hand-inked sound wavefronts. func _draw_vocal_wave(progress: float, fade: float) -> void: var reach: float = lerpf(9.0, radius, progress) for index: int in range(3): var ratio: float = 1.0 - float(index) * 0.18 _draw_ring(reach * ratio, 0.82, Color(1.0, 0.86 - float(index) * 0.07, 0.29), 3.0, fade * (0.92 - float(index) * 0.18)) for index: int in range(15): var angle: float = TAU * float(index) / 15.0 var axis := Vector2(cos(angle), sin(angle) * 0.82) var start: Vector2 = axis * reach * 0.87 var tip: Vector2 = axis * (reach + 5.0 + float(index % 3) * 2.4) _stroke(PackedVector2Array([start, tip]), OUTLINE, PALE_GOLD, 3.7, 1.5, fade * 0.67) ## Ivan: rimmed cymbals with highlights and movement trails. No projectiles. func _draw_drum_cymbals(progress: float, fade: float) -> void: for index: int in range(10): var angle: float = TAU * float(index) / 10.0 var travel: float = lerpf(14.0, radius, progress) var point := Vector2(cos(angle), sin(angle) * 0.78) * travel var wobble: float = 0.32 + absf(sin(progress * TAU * 1.8 + angle)) * 0.26 draw_set_transform(point, angle + progress * 4.0, Vector2(1.0, wobble)) var outer := PackedVector2Array() for step: int in range(33): var theta: float = TAU * float(step) / 32.0 outer.append(Vector2(cos(theta) * 12.0, sin(theta) * 12.0)) draw_colored_polygon(outer, _alpha(Color(0.91, 0.63, 0.22), fade)) draw_polyline(outer, _alpha(OUTLINE, fade), 2.4, true) _draw_ring(9.0, 1.0, Color(1.0, 0.85, 0.44), 1.4, fade) draw_circle(Vector2.ZERO, 3.5, _alpha(Color(0.40, 0.27, 0.12), fade)) draw_circle(Vector2(-0.7, -0.7), 1.5, _alpha(PALE_GOLD, fade)) draw_line(Vector2(-6.0, -5.5), Vector2(1.0, -8.0), _alpha(PALE_GOLD, fade * 0.9), 1.4, true) draw_set_transform(Vector2.ZERO, 0.0, Vector2.ONE) if index % 2 == 0: var trail := PackedVector2Array([ point - Vector2(cos(angle), sin(angle) * 0.78) * 8.0, point - Vector2(cos(angle), sin(angle) * 0.78) * 17.0]) draw_polyline(trail, _alpha(Color(1.0, 0.84, 0.48), fade * 0.48), 1.6, true) ## Fer: thick low-frequency pulses with visible harmonic strings. func _draw_bass_pulse(progress: float, fade: float) -> void: var reach: float = lerpf(8.0, radius, progress) _draw_ring(reach, 0.63, BASS_PURPLE, 5.4, fade * 0.82) _draw_ring(reach * 0.84, 0.65, Color(0.92, 0.77, 1.0), 2.1, fade * 0.9) for index: int in range(6): var angle: float = TAU * float(index) / 6.0 var axis := Vector2(cos(angle), sin(angle) * 0.63) var point: Vector2 = axis * reach _draw_note(point, Color(0.86, 0.73, 1.0), fade) var line := PackedVector2Array() for step: int in range(8): var r: float = reach * (0.50 + float(step) * 0.060) var offset: float = sin(float(step) * PI * 0.6 + progress * TAU * 2.0) * 2.2 line.append(axis * r + Vector2(-axis.y, axis.x) * offset) draw_polyline(line, _alpha(Color(0.78, 0.54, 1.0), fade * 0.65), 1.6, true)