added bullet damage into hit system

This commit is contained in:
Derek
2024-07-16 08:18:36 -05:00
parent 0832aa7808
commit 2b5e63a1ec
9 changed files with 536 additions and 33 deletions

View File

@@ -2,7 +2,7 @@ extends Area3D
@export var damage :=1
signal body_part_hit(dam)
signal body_part_hit(dam,bullet_damage)
# Called when the node enters the scene tree for the first time.
func _ready():
@@ -13,5 +13,5 @@ func _ready():
func _process(delta):
pass
func hit():
emit_signal("body_part_hit", damage)
func hit(bullet_damage):
emit_signal("body_part_hit", damage, bullet_damage)

View File

@@ -62,6 +62,6 @@ func _process(delta):
print("enemy hit")
hit_indicator.play()
enemy_particles.emitting = true
ray.get_collider().hit()
ray.get_collider().hit(bullet_damage)
await get_tree().create_timer(1.0).timeout
queue_free()

View File

@@ -101,6 +101,7 @@ func shoot(player,delta):
instance_bullet.bullet_speed = bullet_speed
instance_bullet.bullet_drop = bullet_drop
instance_bullet.random_spread_amt = random_spread_amt
instance_bullet.bullet_damage = bullet_damage
instance_bullet.instance_bullethole = bullethole.instantiate()
instance_bullet.gun = self
get_tree().get_root().add_child(instance_bullet)

View File

@@ -99,6 +99,7 @@ func shoot(player,delta):
instance_bullet.transform.basis = barrel_raycast.global_transform.basis
instance_bullet.bullet_speed = bullet_speed
instance_bullet.bullet_drop = bullet_drop
instance_bullet.bullet_damage = bullet_damage
instance_bullet.random_spread_amt = random_spread_amt
instance_bullet.instance_bullethole = bullethole.instantiate()
instance_bullet.gun = self
@@ -119,10 +120,7 @@ func reload(player,delta):
anim_player.play("reload")
audio_reload.play()
if anim_player.is_playing() and anim_player.current_animation == "reload":
if level_control.ammo_current[gun_index] == 0:
level_control.ammo_current[gun_index] = 0
else:
level_control.ammo_current[gun_index] = 1
level_control.ammo_current[gun_index] = 0
func spawn_casings():
pass

View File

@@ -40,8 +40,8 @@ func _process(delta):
move_and_slide()
func _on_area_3d_body_part_hit(dam):
health -= dam
func _on_area_3d_body_part_hit(dam,bullet_damage):
health -= dam * bullet_damage
print("health: " + str(health))
if health <= 0: