mejoras en jugabilidad
This commit is contained in:
1 parent
d983bc2e69
commit
ec7e35ddf6
40 files changed
+856
-538
No files matched your search
+29
-31
@@ -15,6 +15,7 @@ signal pickup_collected(data: PickupData)
|
||||
# Capas de fisica: 1 escenario, 2 cuerpo del jugador, 3 cuerpo enemigo,
|
||||
# 4 zona vulnerable del jugador, 5 del enemigo y 6 de objetos rompibles.
|
||||
# Los bits de las mascaras empiezan en cero; no confundir bit con numero de capa.
|
||||
const WORLD_MASK: int = 1 << 0
|
||||
const ENEMY_HURTBOX_MASK: int = 1 << 4
|
||||
const BREAKABLE_HURTBOX_MASK: int = 1 << 5
|
||||
const COMBAT_FX = preload("res://effects/combat_fx.gd")
|
||||
@@ -111,7 +112,7 @@ const COMBAT_FX = preload("res://effects/combat_fx.gd")
|
||||
## Ventana danina del punetazo en segundos.
|
||||
@export var punch_active_duration: float = 0.11
|
||||
## Espera minima entre inicios de punetazo.
|
||||
@export var punch_cooldown: float = 0.34
|
||||
@export_range(0.28, 2.0, 0.01) var punch_cooldown: float = 0.60
|
||||
## El area cubre tambien el cuerpo para golpear enemigos superpuestos.
|
||||
## Se conserva el extremo frontal a 42 px; el area adicional se extiende hacia dentro.
|
||||
@export var punch_hitbox_size: Vector2 = Vector2(56.0, 22.0)
|
||||
@@ -125,6 +126,9 @@ const COMBAT_FX = preload("res://effects/combat_fx.gd")
|
||||
|
||||
@export_category("Ground Pound")
|
||||
|
||||
## Tiempo entre golpes aereos; comienza al lanzarse, incluso si se interrumpe.
|
||||
@export_range(0.0, 20.0, 0.1) var ground_pound_cooldown: float = 7.0
|
||||
|
||||
## Velocidad descendente minima al iniciar el golpe aereo.
|
||||
@export var ground_pound_start_speed: float = 450.0
|
||||
|
||||
@@ -169,9 +173,9 @@ const COMBAT_FX = preload("res://effects/combat_fx.gd")
|
||||
## Dano maximo a plena carga y a la menor distancia del jugador.
|
||||
@export_range(0, 100, 1) var special_max_damage: int = 30
|
||||
|
||||
## Radio adicional al filtro de pantalla. Un valor grande conserva el alcance visible original.
|
||||
## Los niveles 00 y 01 fijan 290 px para comparar el combate con el mismo alcance.
|
||||
@export var special_radius: float = 100000.0
|
||||
## Radio fisico en unidades de mundo, independiente del zoom y tamano de pantalla.
|
||||
## No se permite superar los 290 px para evitar golpes a traves de niveles enteros.
|
||||
@export_range(1.0, 290.0, 1.0) var special_radius: float = 290.0
|
||||
|
||||
## Duracion del solo: preparacion, pulsos y recuperacion. El dano total se reparte entre los pulsos.
|
||||
@export_range(0.6, 6.0, 0.1) var special_duration: float = 2.4
|
||||
@@ -223,6 +227,7 @@ var invulnerability_timer: float = 0.0
|
||||
var punch_timer: float = 0.0
|
||||
var attack_cooldown_timer: float = 0.0
|
||||
|
||||
var ground_pound_cooldown_timer: float = 0.0
|
||||
var ground_pound_active: bool = false
|
||||
var ground_pound_debug_timer: float = 0.0
|
||||
var is_dead: bool = false
|
||||
@@ -514,7 +519,7 @@ func _update_punch_damage() -> void:
|
||||
COMBAT_FX.spawn(get_parent(), punch_hitbox.global_position, &"swing", facing_direction)
|
||||
|
||||
for area in punch_hitbox.get_overlapping_areas():
|
||||
_damage_target(area, get_basic_attack_damage(), punch_hit_targets)
|
||||
_damage_target(area, get_basic_attack_damage(), punch_hit_targets, true)
|
||||
|
||||
|
||||
# ============================================================================
|
||||
@@ -523,9 +528,10 @@ func _update_punch_damage() -> void:
|
||||
|
||||
## Cancela el ascenso y prepara el ataque de caida.
|
||||
func _start_ground_pound() -> void:
|
||||
if is_dead or _special_active or ground_pound_active:
|
||||
if is_dead or _special_active or ground_pound_active or ground_pound_cooldown_timer > 0.0:
|
||||
return
|
||||
|
||||
ground_pound_cooldown_timer = ground_pound_cooldown
|
||||
punch_timer = 0.0
|
||||
ground_pound_active = true
|
||||
attack_cooldown_timer = punch_cooldown
|
||||
@@ -619,7 +625,7 @@ func _update_special_attack(delta: float) -> void:
|
||||
if character_data.special_effect == "bass_pulse":
|
||||
animated_sprite.play(&"special")
|
||||
animated_sprite.set_frame_and_progress(0, 0.0)
|
||||
var effect_radius: float = minf(special_radius, 300.0) if special_radius > 0.0 else 300.0
|
||||
var effect_radius: float = clampf(special_radius, 1.0, 290.0)
|
||||
COMBAT_FX.spawn(get_parent(), global_position,
|
||||
StringName(character_data.special_effect), facing_direction, effect_radius)
|
||||
# Un movimiento de camara por pulso; los platos y ondas nunca aplican dano adicional.
|
||||
@@ -636,8 +642,7 @@ func _update_special_attack(delta: float) -> void:
|
||||
## Mantiene un presupuesto de dano por objetivo para no multiplicarlo por el numero de pulsos.
|
||||
func _apply_special_attack(charge_used: int, pulse_index: int = 0) -> void:
|
||||
var charge_ratio: float = clampf(float(charge_used) / float(maxi(special_max_charge, 1)), 0.0, 1.0)
|
||||
var viewport_rect: Rect2 = get_viewport().get_visible_rect()
|
||||
var max_distance: float = maxf(maxf(viewport_rect.size.x, viewport_rect.size.y) * 0.8, 1.0)
|
||||
var radius: float = clampf(special_radius, 1.0, 290.0)
|
||||
var pulse_count: int = maxi(special_pulse_count, 1)
|
||||
|
||||
var targets: Array[Node] = get_tree().get_nodes_in_group("enemy")
|
||||
@@ -647,15 +652,12 @@ func _apply_special_attack(charge_used: int, pulse_index: int = 0) -> void:
|
||||
if target == null or not target.has_method("take_damage") or (target.is_in_group("enemy") and bool(target.get("is_dead"))):
|
||||
continue
|
||||
var distance: float = global_position.distance_to(target.global_position)
|
||||
if special_radius > 0.0 and distance > special_radius:
|
||||
continue
|
||||
# Solo afecta a enemigos y objetos rompibles visibles; no debe golpear a distancia al otro extremo del mapa.
|
||||
if not viewport_rect.grow(28.0).has_point(target.get_global_transform_with_canvas().origin):
|
||||
if distance > radius:
|
||||
continue
|
||||
|
||||
var target_id: int = target.get_instance_id()
|
||||
if not _special_damage_budgets.has(target_id):
|
||||
var distance_factor: float = maxf(0.1, 1.0 - clampf(distance / max_distance, 0.0, 1.0))
|
||||
var distance_factor: float = maxf(0.1, 1.0 - clampf(distance / radius, 0.0, 1.0))
|
||||
_special_damage_budgets[target_id] = maxi(1, int(special_max_damage * get_special_damage_multiplier() * charge_ratio * distance_factor))
|
||||
# Fija el presupuesto al primer contacto: el retroceso posterior no cambia el dano total.
|
||||
var total_damage: int = int(_special_damage_budgets[target_id])
|
||||
@@ -788,7 +790,7 @@ func _on_enemy_died(_enemy: Node) -> void:
|
||||
# ============================================================================
|
||||
|
||||
## Resuelve la entidad de una zona vulnerable y evita impactos duplicados del mismo ataque.
|
||||
func _damage_target(collider: Node, damage: int, hit_targets: Dictionary) -> void:
|
||||
func _damage_target(collider: Node, damage: int, hit_targets: Dictionary, check_world: bool = false) -> void:
|
||||
var target: Node = collider
|
||||
|
||||
# Las zonas vulnerables son areas hijas; el metodo de dano pertenece a la entidad que las contiene.
|
||||
@@ -801,6 +803,13 @@ func _damage_target(collider: Node, damage: int, hit_targets: Dictionary) -> voi
|
||||
var target_id: int = target.get_instance_id()
|
||||
if hit_targets.has(target_id):
|
||||
return
|
||||
# El punetazo no puede atravesar paredes; un Ground Pound conserva su onda de area.
|
||||
if check_world and target is Node2D:
|
||||
var query := PhysicsRayQueryParameters2D.create(
|
||||
global_position, (target as Node2D).global_position, WORLD_MASK, [get_rid()]
|
||||
)
|
||||
if not get_world_2d().direct_space_state.intersect_ray(query).is_empty():
|
||||
return
|
||||
|
||||
hit_targets[target_id] = true
|
||||
target.take_damage(damage, global_position)
|
||||
@@ -870,6 +879,7 @@ func _update_timers(delta: float) -> void:
|
||||
_pound_landing_timer = maxf(0.0, _pound_landing_timer - delta)
|
||||
punch_timer = max(punch_timer - delta, 0.0)
|
||||
attack_cooldown_timer = max(attack_cooldown_timer - delta, 0.0)
|
||||
ground_pound_cooldown_timer = maxf(0.0, ground_pound_cooldown_timer - delta)
|
||||
ground_pound_debug_timer = max(ground_pound_debug_timer - delta, 0.0)
|
||||
invulnerability_timer = max(invulnerability_timer - delta, 0.0)
|
||||
if _speed_boost_timer > 0.0:
|
||||
@@ -1022,22 +1032,10 @@ func _draw() -> void:
|
||||
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_rect(
|
||||
Rect2(screen_pos - viewport_rect.size * 0.5, viewport_rect.size),
|
||||
Color(1.0, 0.6, 0.05, outline_alpha),
|
||||
false,
|
||||
2.0
|
||||
)
|
||||
var radius: float = clampf(special_radius, 1.0, 290.0)
|
||||
draw_circle(Vector2.ZERO, radius, Color(1.0, 0.6, 0.05, fill_alpha))
|
||||
draw_arc(Vector2.ZERO, radius, 0.0, TAU, 64,
|
||||
Color(1.0, 0.6, 0.05, outline_alpha), 2.0)
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user