Chelimbalo/weapons/gun/semi_shoot_state.gd
2025-12-21 02:22:41 +05:00

50 lines
1.4 KiB
GDScript

extends WeaponState
@export var vertical_curve: Curve
@export var horizontal_curve: Curve
@export var damage_reduction_curve: Curve
@export var emptyable: bool
@export var torso_damage: int
@export var head_damage: int
@export var limb_damage: int
@export var shoot_distance: float = 100
@export var fire_timer: Timer
var bullets_shot: int = 0
func _enter() -> void:
fire()
machine.animation_player.animation_finished.connect(on_animation_finished)
func _exit() -> void:
bullets_shot = 0
machine.animation_player.animation_finished.disconnect(on_animation_finished)
func on_animation_finished(animation):
if animation == machine.animation_prefix + with_morphems("shoot"):
transition.emit("Idle")
func _use_begin(timestamp: float) -> void:
if fire_timer.time_left > 0:
return
fire()
func fire() -> void:
if machine.ammo == 0 or fire_timer.time_left > 0:
return
machine.ammo -= 1
bullets_shot += 1
machine.play(with_morphems("shoot"))
if is_multiplayer_authority():
Session.shoot(int(machine.player.name),limb_damage,torso_damage,head_damage,shoot_distance,damage_reduction_curve)
machine.player.get_node("ShootAudio").multiplayer_play()
fire_timer.start()
machine.player_camera.recoil(horizontal_curve.sample(bullets_shot),vertical_curve.sample(bullets_shot))
func with_morphems(animation):
return ((animation+"_empty") if emptyable and machine.ammo == 0 else animation)