renamed variable and added safety check
parent
7fe0990949
commit
f3c7146367
|
|
@ -8,6 +8,7 @@ signal leveled_up
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
|
assert(fruit_drop_threshold <= fruit_drop_ceiling)
|
||||||
bar.max_value = player.max_xp
|
bar.max_value = player.max_xp
|
||||||
pass # Replace with function body.
|
pass # Replace with function body.
|
||||||
|
|
||||||
|
|
@ -40,8 +41,8 @@ func drop_item(enemy):
|
||||||
if fruit_count >= fruit_drop_ceiling:
|
if fruit_count >= fruit_drop_ceiling:
|
||||||
continue
|
continue
|
||||||
elif fruit_count > fruit_drop_threshold:
|
elif fruit_count > fruit_drop_threshold:
|
||||||
var scale = 1.0 - float(fruit_count - fruit_drop_threshold) / float(fruit_drop_ceiling - fruit_drop_threshold)
|
var chance_scale = 1.0 - float(fruit_count - fruit_drop_threshold) / float(fruit_drop_ceiling - fruit_drop_threshold)
|
||||||
effective_chance *= scale
|
effective_chance *= chance_scale
|
||||||
if randf() < effective_chance:
|
if randf() < effective_chance:
|
||||||
var drop = entry.drop.instantiate()
|
var drop = entry.drop.instantiate()
|
||||||
drop.global_position = enemy.global_position
|
drop.global_position = enemy.global_position
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue