55 lines
1.7 KiB
GDScript
55 lines
1.7 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_total_damage: int
|
|
@export var head_total_damage: int
|
|
@export var limb_total_damage: int
|
|
@export_range(0,179,0.01,"radians_as_degrees") var arc: float
|
|
@export_range(1,20,1,"or_greater") var max_pellets: int = 1
|
|
@export_range(1,20,1,"or_greater") var min_pellets: int = 1
|
|
@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 == with_morphems("shoot"):
|
|
transition.emit("Idle")
|
|
|
|
func _use_begin() -> 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.animation_player.stop()
|
|
machine.animation_player.play(with_morphems("shoot"))
|
|
|
|
if is_multiplayer_authority():
|
|
var pellets: int = randi_range(min_pellets,max_pellets)
|
|
Session.shoot_pellets(int(machine.player.name),pellets,limb_total_damage,torso_total_damage,head_total_damage,shoot_distance,arc,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 machine.animation_prefix + ((animation+"_empty") if emptyable and machine.ammo == 0 else animation)
|