From 4f32f718c69fc03dc978ea594ccbc84c5b0ebb99 Mon Sep 17 00:00:00 2001 From: Luna Brovchuk Date: Mon, 2 Oct 2023 20:31:18 +0200 Subject: [PATCH] Fix Ricochet --- src/models/bullet/bullet.gd | 2 +- src/models/enemies/bat/bat.gd | 2 +- src/models/enemies/rat/rat.gd | 2 +- src/models/player/player.gd | 13 ++++++++----- src/scenes/game/spell_recharge_bar.gd | 2 +- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/models/bullet/bullet.gd b/src/models/bullet/bullet.gd index a54fada..24b5ff6 100644 --- a/src/models/bullet/bullet.gd +++ b/src/models/bullet/bullet.gd @@ -42,7 +42,7 @@ func area_entered(area): parent.deal_damage(damage) parent.freeze_modifier = freeze_modifier parent.poison_damage = poison_damage - if ricochet_count >= bounced: + if bounced >= ricochet_count: call_deferred("free") choose_target() bounced += 1 diff --git a/src/models/enemies/bat/bat.gd b/src/models/enemies/bat/bat.gd index c4c58c5..4b6fa1d 100644 --- a/src/models/enemies/bat/bat.gd +++ b/src/models/enemies/bat/bat.gd @@ -11,7 +11,7 @@ var shot = false var sonic_wave func _ready(): - hp = 15 + hp = 7 func _physics_process(delta): if not shooting: diff --git a/src/models/enemies/rat/rat.gd b/src/models/enemies/rat/rat.gd index 4999dc7..9fc949b 100644 --- a/src/models/enemies/rat/rat.gd +++ b/src/models/enemies/rat/rat.gd @@ -6,7 +6,7 @@ var speed = 24 func _ready(): randomize() global_position = [Vector2(33, 50), Vector2(287, 70)][randi()%2] - hp = 15 + hp = 7 func _physics_process(delta): global_position = global_position.move_toward(player.global_position + Vector2(8, 8), speed * delta * speed_multiplier) diff --git a/src/models/player/player.gd b/src/models/player/player.gd index c6e282b..b94a4e1 100644 --- a/src/models/player/player.gd +++ b/src/models/player/player.gd @@ -101,16 +101,19 @@ func _shoot(): bullet.freeze_modifier = freeze_modifier bullet.poison_damage = poison_damage bullet.speed_modifier = speed_modifier + bullet.ricochet_count = ricochet_count get_parent().add_child(bullet) bullet.global_position.x = self.global_position.x + 8 bullet.global_position.y = self.global_position.y + 8 - bullet = fireball_preload.instance() - bullet.target = target - get_parent().add_child(bullet) - bullet.global_position.x = self.global_position.x + 8 - bullet.global_position.y = self.global_position.y + 8 + for i in range(fireball_amount): + var fireball = fireball_preload.instance() + fireball.target = target + get_parent().add_child(fireball) + fireball.global_position.x = self.global_position.x + 8 + randomize() + fireball.global_position.y = self.global_position.y + 8 + randi()%8 - 4 func _draw(): if target != null and is_instance_valid(target) and not target.dead: diff --git a/src/scenes/game/spell_recharge_bar.gd b/src/scenes/game/spell_recharge_bar.gd index 70107b7..df1d139 100644 --- a/src/scenes/game/spell_recharge_bar.gd +++ b/src/scenes/game/spell_recharge_bar.gd @@ -4,4 +4,4 @@ onready var player = get_tree().get_root().get_node("Game/View/Player") var max_size = 80 func _process(delta): - $ColorRect.rect_size.x = max_size * (player.recharge_timer / player.get_recharge()) + $ColorRect.rect_size.x = max_size * (clamp(player.recharge_timer, 0, player.get_recharge()) / player.get_recharge())