added check if enemy exists before accesing droptable to prevent game crash

pull/1/head
Artur David 2026-04-13 22:52:43 +02:00
parent 1dbe6cc239
commit 1b90d6296d
1 changed files with 2 additions and 0 deletions

View File

@ -15,6 +15,8 @@ func on_enemy_died(enemy):
call_deferred("drop_item", enemy) call_deferred("drop_item", enemy)
func drop_item(enemy): func drop_item(enemy):
if not is_instance_valid(enemy):
return
for entry in enemy.drop_table: for entry in enemy.drop_table:
if randf() < entry.chance: if randf() < entry.chance:
var drop = entry.drop.instantiate() var drop = entry.drop.instantiate()