damage slow down

This commit is contained in:
Rendo 2025-12-11 22:07:53 +05:00
commit 96f92757b5
9 changed files with 47 additions and 18 deletions

View file

@ -333,16 +333,21 @@ func shoot(id:int , limb_damage: int, torso_damage: int,head_damage: int, distan
var hit_player: Player = collision["collider"]
var shape_object: CollisionShape3D = hit_player.shape_owner_get_owner(collision["shape"])
var reduction: float = 0
var damage: int = 0
match shape_object.get_groups()[0]:
"Head":
damage = head_damage
"Limb":
damage = limb_damage
_:
damage = torso_damage
if damage_reduction_curve != null:
var distance_to_hit = (player_camera.global_position - collision["position"]).length()/distance
reduction = damage_reduction_curve.sample(distance_to_hit)
match shape_object.get_groups()[0]:
"Head":
hit_player.take_damage(head_damage*reduction)
"Limb":
hit_player.take_damage(limb_damage*reduction)
_:
hit_player.take_damage(torso_damage*reduction)
hit_player.take_damage(int(float(damage) * reduction))