From f3c71463675f1a4ef35f709f7025238d6cfba992 Mon Sep 17 00:00:00 2001 From: Artur David Date: Tue, 2 Jun 2026 08:39:01 +0200 Subject: [PATCH] renamed variable and added safety check --- scripts/drop_manager.gd | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/drop_manager.gd b/scripts/drop_manager.gd index ed28efa..ac70425 100644 --- a/scripts/drop_manager.gd +++ b/scripts/drop_manager.gd @@ -8,6 +8,7 @@ signal leveled_up # Called when the node enters the scene tree for the first time. func _ready() -> void: + assert(fruit_drop_threshold <= fruit_drop_ceiling) bar.max_value = player.max_xp pass # Replace with function body. @@ -40,8 +41,8 @@ func drop_item(enemy): if fruit_count >= fruit_drop_ceiling: continue elif fruit_count > fruit_drop_threshold: - var scale = 1.0 - float(fruit_count - fruit_drop_threshold) / float(fruit_drop_ceiling - fruit_drop_threshold) - effective_chance *= scale + var chance_scale = 1.0 - float(fruit_count - fruit_drop_threshold) / float(fruit_drop_ceiling - fruit_drop_threshold) + effective_chance *= chance_scale if randf() < effective_chance: var drop = entry.drop.instantiate() drop.global_position = enemy.global_position