renamed variable and added safety check

main
Artur David 2026-06-02 08:39:01 +02:00
parent 7fe0990949
commit f3c7146367
1 changed files with 3 additions and 2 deletions

View File

@ -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