diff --git a/scripts/Statemachine/EntityBase.gd b/scripts/Statemachine/EntityBase.gd index 0a84532..1dc4784 100644 --- a/scripts/Statemachine/EntityBase.gd +++ b/scripts/Statemachine/EntityBase.gd @@ -362,7 +362,7 @@ func useItem(items: Dictionary): return state func getItem(items: Dictionary): for item in items: - inventory[item] += items[item] + inventory[item] = clamp(inventory[item] + items[item], 0, inventoryMax[item]) func getTrackingAnchor() -> Vector2: return hurtbox.get_node("hitbox").global_position diff --git a/scripts/Statemachine/ItemDropped.gd b/scripts/Statemachine/ItemDropped.gd index 4f980d2..5640e03 100644 --- a/scripts/Statemachine/ItemDropped.gd +++ b/scripts/Statemachine/ItemDropped.gd @@ -35,8 +35,9 @@ func _physics_process(_delta): if targetPlayer.sprinting: apply_central_force((position - targetPlayer.texture.global_position).normalized() * targetPlayer.velocity.length() * 10) else: - targetPlayer.collectItem(item, stackCount) - collect() + if targetPlayer.inventoryMax[item] > targetPlayer.inventory[item]: + targetPlayer.collectItem(item, stackCount) + collect() func collect(): collecting = true