Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d9eacb104c | ||
|
|
eaa6c4e8d3 |
No files matched your search
@@ -20,5 +20,5 @@ class_name CharacterData
|
||||
@export_range(1, 100, 1) var max_health: int = 5
|
||||
@export var move_speed: float = 400.0
|
||||
@export var jump_velocity: float = -600.0
|
||||
@export_range(0, 100, 1) var basic_attack_damage: int = 1
|
||||
@export_range(0, 100, 1) var air_attack_damage: int = 3
|
||||
@export_range(0, 100, 1) var basic_attack_damage: int = 5
|
||||
@export_range(0, 100, 1) var air_attack_damage: int = 10
|
||||
+44
-36
@@ -130,14 +130,14 @@ const ENEMY_HURTBOX_MASK: int = 1 << 4
|
||||
## Charge gained when an enemy dies.
|
||||
@export_range(0, 100, 1) var special_charge_per_kill: int = 25
|
||||
|
||||
## Minimum damage dealt by the special (scales up with charge).
|
||||
@export_range(0, 100, 1) var special_min_damage: int = 3
|
||||
## Minimum charge required to use special attack.
|
||||
@export_range(0, 100, 1) var special_min_use_charge: int = 25
|
||||
|
||||
## Maximum damage dealt by the special (at full charge, point-blank).
|
||||
@export_range(0, 100, 1) var special_max_damage: int = 8
|
||||
## Maximum damage dealt by the special (at full charge, closest to player).
|
||||
@export_range(0, 100, 1) var special_max_damage: int = 30
|
||||
|
||||
## Radius of the radial special attack in pixels.
|
||||
@export var special_radius: float = 200.0
|
||||
## Radius no longer used for full-screen special; kept for backwards compatibility.
|
||||
@export var special_radius: float = 100000.0
|
||||
|
||||
|
||||
# ============================================================================
|
||||
@@ -434,23 +434,29 @@ func _start_special_attack() -> void:
|
||||
if is_dead:
|
||||
return
|
||||
|
||||
if special_charge < special_max_charge:
|
||||
if special_charge < special_min_use_charge:
|
||||
return
|
||||
|
||||
# Consume the full charge.
|
||||
var charge_used: int = special_charge
|
||||
# Consume all current charge
|
||||
special_charge = 0
|
||||
special_charge_changed.emit(special_charge, special_max_charge)
|
||||
|
||||
_apply_special_attack()
|
||||
_apply_special_attack(charge_used)
|
||||
|
||||
|
||||
func _apply_special_attack() -> void:
|
||||
# The special requires full charge, so charge_ratio is always 1.0 here.
|
||||
# Partial-charge support can be added later if desired.
|
||||
var charge_ratio: float = 1.0
|
||||
func _apply_special_attack(charge_used: int = special_max_charge) -> void:
|
||||
var charge_ratio: float = clamp(float(charge_used) / float(special_max_charge), 0.0, 1.0)
|
||||
|
||||
var hit_targets: Dictionary = {}
|
||||
|
||||
# Get viewport size to scale falloff across the whole screen
|
||||
var viewport: Viewport = get_viewport()
|
||||
var viewport_rect: Rect2 = viewport.get_visible_rect()
|
||||
var max_distance: float = max(viewport_rect.size.x, viewport_rect.size.y) * 0.8
|
||||
if max_distance < 1.0:
|
||||
max_distance = special_radius
|
||||
|
||||
for enemy in get_tree().get_nodes_in_group("enemy"):
|
||||
if not is_instance_valid(enemy):
|
||||
continue
|
||||
@@ -459,14 +465,14 @@ func _apply_special_attack() -> void:
|
||||
continue
|
||||
|
||||
var distance: float = global_position.distance_to(enemy.global_position)
|
||||
if distance > special_radius:
|
||||
continue
|
||||
# Damage falls off with distance: maximum at the player, lower farther away
|
||||
# affects the whole screen (no hard circle cutoff)
|
||||
var distance_factor: float = 1.0 - clamp(distance / max_distance, 0.0, 1.0)
|
||||
# Ensure it still affects even if very far, just minimal
|
||||
if distance_factor < 0.1:
|
||||
distance_factor = 0.1
|
||||
|
||||
# Damage falls off with distance: maximum at the player, zero at the edge.
|
||||
var distance_factor: float = 1.0 - clamp(distance / special_radius, 0.0, 1.0)
|
||||
|
||||
var base_damage: float = lerp(special_min_damage, special_max_damage, charge_ratio)
|
||||
var damage: int = int(base_damage * distance_factor)
|
||||
var damage: int = int(special_max_damage * charge_ratio * distance_factor)
|
||||
if damage < 1:
|
||||
damage = 1
|
||||
|
||||
@@ -636,24 +642,26 @@ func _draw() -> void:
|
||||
2.0
|
||||
)
|
||||
|
||||
# Special: show the radial damage area. Brighter when fully charged.
|
||||
var fill_alpha: float = 0.08
|
||||
var outline_alpha: float = 0.35
|
||||
if special_charge >= special_max_charge:
|
||||
fill_alpha = 0.18
|
||||
outline_alpha = 0.85
|
||||
draw_circle(
|
||||
Vector2.ZERO,
|
||||
special_radius,
|
||||
Color(1.0, 0.6, 0.05, fill_alpha)
|
||||
# Special: show full-screen effect indication. Brighter when fully charged.
|
||||
var fill_alpha: float = 0.05
|
||||
var outline_alpha: float = 0.25
|
||||
if special_charge >= special_min_use_charge:
|
||||
fill_alpha = 0.12
|
||||
outline_alpha = 0.6
|
||||
var viewport_rect: Rect2 = get_viewport().get_visible_rect()
|
||||
var camera: Camera2D = get_viewport().get_camera_2d()
|
||||
var screen_pos: Vector2 = Vector2.ZERO
|
||||
if camera != null:
|
||||
screen_pos = to_local(camera.get_screen_center_position())
|
||||
draw_rect(
|
||||
Rect2(screen_pos - viewport_rect.size * 0.5, viewport_rect.size),
|
||||
Color(1.0, 0.6, 0.05, fill_alpha),
|
||||
true
|
||||
)
|
||||
draw_arc(
|
||||
Vector2.ZERO,
|
||||
special_radius,
|
||||
0.0,
|
||||
TAU,
|
||||
48,
|
||||
draw_rect(
|
||||
Rect2(screen_pos - viewport_rect.size * 0.5, viewport_rect.size),
|
||||
Color(1.0, 0.6, 0.05, outline_alpha),
|
||||
false,
|
||||
2.0
|
||||
)
|
||||
|
||||
|
||||
Reference in new issue
Block a user