made fruits drop less when there are too many on screen
parent
e7e0e2ce9f
commit
7fe0990949
|
|
@ -34,8 +34,15 @@ func on_enemy_died(enemy):
|
|||
func drop_item(enemy):
|
||||
if not is_instance_valid(enemy):
|
||||
return
|
||||
var fruit_count = get_children().filter(func(c): return c is DropsBase).size()
|
||||
for entry in enemy.drop_table:
|
||||
if randf() < entry.chance:
|
||||
var effective_chance = entry.chance
|
||||
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
|
||||
if randf() < effective_chance:
|
||||
var drop = entry.drop.instantiate()
|
||||
drop.global_position = enemy.global_position
|
||||
add_child(drop)
|
||||
|
|
|
|||
Loading…
Reference in New Issue