Merge pull request 'Cambios en la potencia y area de los ataques' (#11) from feature/ia_automated_test into main
Android Debug APK / build (push) Successful in 52s
Android Debug APK / build (push) Successful in 52s
Reviewed-on: #11
This commit was merged in pull request #11.
This commit is contained in:
commit
d9eacb104c
2 files changed
+46
-38
No files matched your search
@@ -20,5 +20,5 @@ class_name CharacterData
|
|||||||
@export_range(1, 100, 1) var max_health: int = 5
|
@export_range(1, 100, 1) var max_health: int = 5
|
||||||
@export var move_speed: float = 400.0
|
@export var move_speed: float = 400.0
|
||||||
@export var jump_velocity: float = -600.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 basic_attack_damage: int = 5
|
||||||
@export_range(0, 100, 1) var air_attack_damage: int = 3
|
@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.
|
## Charge gained when an enemy dies.
|
||||||
@export_range(0, 100, 1) var special_charge_per_kill: int = 25
|
@export_range(0, 100, 1) var special_charge_per_kill: int = 25
|
||||||
|
|
||||||
## Minimum damage dealt by the special (scales up with charge).
|
## Minimum charge required to use special attack.
|
||||||
@export_range(0, 100, 1) var special_min_damage: int = 3
|
@export_range(0, 100, 1) var special_min_use_charge: int = 25
|
||||||
|
|
||||||
## Maximum damage dealt by the special (at full charge, point-blank).
|
## Maximum damage dealt by the special (at full charge, closest to player).
|
||||||
@export_range(0, 100, 1) var special_max_damage: int = 8
|
@export_range(0, 100, 1) var special_max_damage: int = 30
|
||||||
|
|
||||||
## Radius of the radial special attack in pixels.
|
## Radius no longer used for full-screen special; kept for backwards compatibility.
|
||||||
@export var special_radius: float = 200.0
|
@export var special_radius: float = 100000.0
|
||||||
|
|
||||||
|
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
@@ -434,23 +434,29 @@ func _start_special_attack() -> void:
|
|||||||
if is_dead:
|
if is_dead:
|
||||||
return
|
return
|
||||||
|
|
||||||
if special_charge < special_max_charge:
|
if special_charge < special_min_use_charge:
|
||||||
return
|
return
|
||||||
|
|
||||||
# Consume the full charge.
|
var charge_used: int = special_charge
|
||||||
|
# Consume all current charge
|
||||||
special_charge = 0
|
special_charge = 0
|
||||||
special_charge_changed.emit(special_charge, special_max_charge)
|
special_charge_changed.emit(special_charge, special_max_charge)
|
||||||
|
|
||||||
_apply_special_attack()
|
_apply_special_attack(charge_used)
|
||||||
|
|
||||||
|
|
||||||
func _apply_special_attack() -> void:
|
func _apply_special_attack(charge_used: int = special_max_charge) -> void:
|
||||||
# The special requires full charge, so charge_ratio is always 1.0 here.
|
var charge_ratio: float = clamp(float(charge_used) / float(special_max_charge), 0.0, 1.0)
|
||||||
# Partial-charge support can be added later if desired.
|
|
||||||
var charge_ratio: float = 1.0
|
|
||||||
|
|
||||||
var hit_targets: Dictionary = {}
|
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"):
|
for enemy in get_tree().get_nodes_in_group("enemy"):
|
||||||
if not is_instance_valid(enemy):
|
if not is_instance_valid(enemy):
|
||||||
continue
|
continue
|
||||||
@@ -459,14 +465,14 @@ func _apply_special_attack() -> void:
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
var distance: float = global_position.distance_to(enemy.global_position)
|
var distance: float = global_position.distance_to(enemy.global_position)
|
||||||
if distance > special_radius:
|
# Damage falls off with distance: maximum at the player, lower farther away
|
||||||
continue
|
# 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 damage: int = int(special_max_damage * charge_ratio * distance_factor)
|
||||||
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)
|
|
||||||
if damage < 1:
|
if damage < 1:
|
||||||
damage = 1
|
damage = 1
|
||||||
|
|
||||||
@@ -636,24 +642,26 @@ func _draw() -> void:
|
|||||||
2.0
|
2.0
|
||||||
)
|
)
|
||||||
|
|
||||||
# Special: show the radial damage area. Brighter when fully charged.
|
# Special: show full-screen effect indication. Brighter when fully charged.
|
||||||
var fill_alpha: float = 0.08
|
var fill_alpha: float = 0.05
|
||||||
var outline_alpha: float = 0.35
|
var outline_alpha: float = 0.25
|
||||||
if special_charge >= special_max_charge:
|
if special_charge >= special_min_use_charge:
|
||||||
fill_alpha = 0.18
|
fill_alpha = 0.12
|
||||||
outline_alpha = 0.85
|
outline_alpha = 0.6
|
||||||
draw_circle(
|
var viewport_rect: Rect2 = get_viewport().get_visible_rect()
|
||||||
Vector2.ZERO,
|
var camera: Camera2D = get_viewport().get_camera_2d()
|
||||||
special_radius,
|
var screen_pos: Vector2 = Vector2.ZERO
|
||||||
Color(1.0, 0.6, 0.05, fill_alpha)
|
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(
|
draw_rect(
|
||||||
Vector2.ZERO,
|
Rect2(screen_pos - viewport_rect.size * 0.5, viewport_rect.size),
|
||||||
special_radius,
|
|
||||||
0.0,
|
|
||||||
TAU,
|
|
||||||
48,
|
|
||||||
Color(1.0, 0.6, 0.05, outline_alpha),
|
Color(1.0, 0.6, 0.05, outline_alpha),
|
||||||
|
false,
|
||||||
2.0
|
2.0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user