objetos raros, objetos decorativos rompibles
This commit is contained in:
1 parent
827e16cf50
commit
66f4d8b33b
55 files changed
+4793
-163
No files matched your search
+52
-24
@@ -13,9 +13,10 @@ signal pickup_collected(data: PickupData)
|
||||
|
||||
|
||||
# Capas de fisica: 1 escenario, 2 cuerpo del jugador, 3 cuerpo enemigo,
|
||||
# 4 zona vulnerable del jugador y 5 zona vulnerable del 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 ENEMY_HURTBOX_MASK: int = 1 << 4
|
||||
const BREAKABLE_HURTBOX_MASK: int = 1 << 5
|
||||
const COMBAT_FX = preload("res://effects/combat_fx.gd")
|
||||
|
||||
|
||||
@@ -206,6 +207,11 @@ const COMBAT_FX = preload("res://effects/combat_fx.gd")
|
||||
# ESTADO DE LA PARTIDA
|
||||
# ============================================================================
|
||||
|
||||
# Copia de los bonos confirmados al iniciar el intento. No se toca CharacterData.
|
||||
var _permanent_special_damage_bonus: float = 0.0
|
||||
var _permanent_basic_damage_bonus: float = 0.0
|
||||
var _permanent_max_health_bonus: int = 0
|
||||
|
||||
var current_health: int = 1
|
||||
var facing_direction: float = 1.0
|
||||
|
||||
@@ -265,7 +271,12 @@ func _ready() -> void:
|
||||
push_error("Player needs a CharacterData resource.")
|
||||
return
|
||||
|
||||
current_health = character_data.max_health
|
||||
var progress: PlayerProgressStore = get_node_or_null("/root/PlayerProgress") as PlayerProgressStore
|
||||
if progress != null:
|
||||
_permanent_special_damage_bonus = progress.get_total_bonus(&"special_damage_bonus")
|
||||
_permanent_basic_damage_bonus = progress.get_total_bonus(&"basic_damage_bonus")
|
||||
_permanent_max_health_bonus = roundi(progress.get_total_bonus(&"max_health_bonus"))
|
||||
current_health = get_max_health()
|
||||
if character_data.sprite_frames != null:
|
||||
animated_sprite.sprite_frames = character_data.sprite_frames
|
||||
|
||||
@@ -274,7 +285,7 @@ func _ready() -> void:
|
||||
_setup_attack_hitboxes()
|
||||
_update_facing()
|
||||
_update_animation()
|
||||
health_changed.emit(current_health, character_data.max_health)
|
||||
health_changed.emit(current_health, get_max_health())
|
||||
special_charge_changed.emit(special_charge, special_max_charge)
|
||||
# Conecta los enemigos que ya pertenecen al grupo al iniciar el nivel.
|
||||
# Un futuro sistema de aparicion dinamica debera conectar tambien sus nuevas instancias.
|
||||
@@ -494,7 +505,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, roundi(character_data.basic_attack_damage * (1.0 + _damage_boost_multiplier)), punch_hit_targets)
|
||||
_damage_target(area, get_basic_attack_damage(), punch_hit_targets)
|
||||
|
||||
|
||||
# ============================================================================
|
||||
@@ -545,7 +556,7 @@ func _ground_pound_impact() -> void:
|
||||
var query := PhysicsShapeQueryParameters2D.new()
|
||||
query.shape = ground_pound_collision.shape
|
||||
query.transform = ground_pound_collision.global_transform
|
||||
query.collision_mask = ENEMY_HURTBOX_MASK
|
||||
query.collision_mask = ENEMY_HURTBOX_MASK | BREAKABLE_HURTBOX_MASK
|
||||
query.collide_with_areas = true
|
||||
query.collide_with_bodies = false
|
||||
for hit: Dictionary in get_world_2d().direct_space_state.intersect_shape(query, 64):
|
||||
@@ -601,40 +612,57 @@ func _update_special_attack(delta: float) -> void:
|
||||
_special_damage_dealt.clear()
|
||||
|
||||
|
||||
## Mantiene un presupuesto de dano por enemigo para no multiplicarlo por el numero de pulsos.
|
||||
## 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 pulse_count: int = maxi(special_pulse_count, 1)
|
||||
|
||||
for node: Node in get_tree().get_nodes_in_group("enemy"):
|
||||
var enemy := node as Node2D
|
||||
if enemy == null or not enemy.has_method("take_damage") or bool(enemy.get("is_dead")):
|
||||
var targets: Array[Node] = get_tree().get_nodes_in_group("enemy")
|
||||
targets.append_array(get_tree().get_nodes_in_group("breakable"))
|
||||
for node: Node in targets:
|
||||
var target := node as Node2D
|
||||
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(enemy.global_position)
|
||||
var distance: float = global_position.distance_to(target.global_position)
|
||||
if special_radius > 0.0 and distance > special_radius:
|
||||
continue
|
||||
# Solo afecta a enemigos visibles; no debe golpear a distancia al otro extremo del mapa.
|
||||
if not viewport_rect.grow(28.0).has_point(enemy.get_global_transform_with_canvas().origin):
|
||||
# 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):
|
||||
continue
|
||||
|
||||
var enemy_id: int = enemy.get_instance_id()
|
||||
if not _special_damage_budgets.has(enemy_id):
|
||||
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))
|
||||
_special_damage_budgets[enemy_id] = maxi(1, int(special_max_damage * charge_ratio * distance_factor))
|
||||
_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[enemy_id])
|
||||
var total_damage: int = int(_special_damage_budgets[target_id])
|
||||
var cumulative_damage: int = ceili(float(total_damage) * float(pulse_index + 1) / float(pulse_count))
|
||||
var damage: int = cumulative_damage - int(_special_damage_dealt.get(enemy_id, 0))
|
||||
var damage: int = cumulative_damage - int(_special_damage_dealt.get(target_id, 0))
|
||||
if damage <= 0:
|
||||
continue
|
||||
_special_damage_dealt[enemy_id] = cumulative_damage
|
||||
_special_damage_dealt[target_id] = cumulative_damage
|
||||
_applying_special_damage = true
|
||||
enemy.call("take_damage", damage, global_position)
|
||||
target.call("take_damage", damage, global_position)
|
||||
_applying_special_damage = false
|
||||
|
||||
|
||||
## Atributos efectivos del intento; los raros pendientes no intervienen en estos valores.
|
||||
func get_max_health() -> int:
|
||||
return maxi(character_data.max_health + _permanent_max_health_bonus, 1) if character_data != null else 1
|
||||
|
||||
|
||||
func get_basic_attack_damage() -> int:
|
||||
if character_data == null:
|
||||
return 0
|
||||
return roundi(character_data.basic_attack_damage * (1.0 + _permanent_basic_damage_bonus) * (1.0 + _damage_boost_multiplier))
|
||||
|
||||
|
||||
func get_special_damage_multiplier() -> float:
|
||||
return 1.0 + _permanent_special_damage_bonus
|
||||
|
||||
|
||||
## Devuelve true solo si se aplica el efecto. False conserva el objeto para otra oportunidad.
|
||||
func collect_pickup(data: PickupData) -> bool:
|
||||
if is_dead or data == null or character_data == null:
|
||||
@@ -642,11 +670,11 @@ func collect_pickup(data: PickupData) -> bool:
|
||||
|
||||
match data.effect_type:
|
||||
"heal":
|
||||
var heal_amount: int = mini(int(data.value), character_data.max_health - current_health)
|
||||
var heal_amount: int = mini(int(data.value), get_max_health() - current_health)
|
||||
if heal_amount <= 0:
|
||||
return false
|
||||
current_health += heal_amount
|
||||
health_changed.emit(current_health, character_data.max_health)
|
||||
health_changed.emit(current_health, get_max_health())
|
||||
_spawn_floating_text("+" + str(heal_amount), Color(0.2, 1.0, 0.3))
|
||||
"speed_boost":
|
||||
if data.value <= 0.0 or data.duration <= 0.0:
|
||||
@@ -794,7 +822,7 @@ func take_damage(amount: int, source_position: Vector2, knockback_multiplier: fl
|
||||
COMBAT_FX.spawn(get_parent(), global_position, &"hit", knockback_direction)
|
||||
feedback_camera.call("impact", 1.5 * clampf(push_scale, 0.8, 1.6), 0.18)
|
||||
|
||||
health_changed.emit(current_health, character_data.max_health)
|
||||
health_changed.emit(current_health, get_max_health())
|
||||
|
||||
if current_health == 0:
|
||||
_die()
|
||||
@@ -894,7 +922,7 @@ func _setup_attack_hitboxes() -> void:
|
||||
punch_shape.size = punch_hitbox_size
|
||||
punch_collision.shape = punch_shape
|
||||
punch_hitbox.collision_layer = 0
|
||||
punch_hitbox.collision_mask = ENEMY_HURTBOX_MASK
|
||||
punch_hitbox.collision_mask = ENEMY_HURTBOX_MASK | BREAKABLE_HURTBOX_MASK
|
||||
punch_hitbox.monitoring = true
|
||||
|
||||
var pound_shape: CircleShape2D = CircleShape2D.new()
|
||||
@@ -902,7 +930,7 @@ func _setup_attack_hitboxes() -> void:
|
||||
ground_pound_collision.shape = pound_shape
|
||||
ground_pound_hitbox.position = ground_pound_offset
|
||||
ground_pound_hitbox.collision_layer = 0
|
||||
ground_pound_hitbox.collision_mask = ENEMY_HURTBOX_MASK
|
||||
ground_pound_hitbox.collision_mask = ENEMY_HURTBOX_MASK | BREAKABLE_HURTBOX_MASK
|
||||
ground_pound_hitbox.monitoring = true
|
||||
|
||||
|
||||
|
||||
+2
-2
@@ -29,14 +29,14 @@ shape = SubResource("PlayerShape")
|
||||
|
||||
[node name="PunchHitbox" type="Area2D" parent="." unique_id=184501519]
|
||||
collision_layer = 0
|
||||
collision_mask = 16
|
||||
collision_mask = 48
|
||||
monitorable = false
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="PunchHitbox" unique_id=126348432]
|
||||
|
||||
[node name="GroundPoundHitbox" type="Area2D" parent="." unique_id=1822904824]
|
||||
collision_layer = 0
|
||||
collision_mask = 16
|
||||
collision_mask = 48
|
||||
monitorable = false
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="GroundPoundHitbox" unique_id=2120510285]
|
||||
|
||||
Reference in new issue
Block a user