made tracker gun

This commit is contained in:
Derek
2024-11-24 16:27:48 -06:00
parent 05b8c0d760
commit 0312da48b8
21 changed files with 1008 additions and 242 deletions

View File

@@ -34,9 +34,12 @@ var cycle_count
@export var audio_empty : Node
@export var audio_reload : Node
@onready var smoke: GPUParticles3D = $BlunderbusHandle/Blunderbus/Smoke
@onready var player = get_tree().current_scene.player
@onready var level_control = get_tree().current_scene
@onready var ammo_current
@onready var smoke_timer: Timer = $SmokeTimer
var rng = RandomNumberGenerator.new()
var gun_index
#var ammo_current
@@ -44,6 +47,7 @@ var ammo_reserve
# Called when the node enters the scene tree for the first time.
func _ready():
#smoke.emitting = false
start_position = self.position
start_rotation = self.rotation
random_spread_start = random_spread_amt
@@ -80,27 +84,25 @@ func reload_finished():
func shoot(delta):
if level_control.ammo_current[gun_index] > 0 and cycle_count > 0:
if !anim_player.is_playing():
level_control.ammo_current[gun_index] -= 1
#RECOIL --- fix later to happen over a period of time
#(ADD PLAYER KICK HERE. RELATIVE TO GUN POSITION)
audio_fire.pitch_scale = 1 + rng.randf_range(-fire_pitch_scale_amt,fire_pitch_scale_amt)
audio_fire.play()
anim_player.play("shoot")
pellet_spawn()
player.recoil.add_recoil(Vector3(0,recoil_amount.y,recoil_amount.z),10,10)
player.recoil.add_gun_recoil(recoil_amount.x)
player.velocity += player.bullet_ray.global_basis * Vector3(0,0, kick_amount)
if fire_mode != 0:
cycle_count -= 1
elif !anim_player.is_playing() and cycle_count != 0:
anim_player.play("empty")
audio_empty.play()
func fire():
level_control.ammo_current[gun_index] -= 1
audio_fire.pitch_scale = 1 + rng.randf_range(-fire_pitch_scale_amt,fire_pitch_scale_amt)
audio_fire.play()
pellet_spawn()
player.recoil.add_recoil(Vector3(0,recoil_amount.y,recoil_amount.z),10,10)
player.recoil.add_gun_recoil(recoil_amount.x)
player.velocity += player.bullet_ray.global_basis * Vector3(0,0, kick_amount)
if fire_mode != 0:
cycle_count -= 1
func reload():
if level_control.ammo_current[gun_index] < max_ammo and player.gun.anim_player.get_current_animation() != "reload" and level_control.ammo_reserve[gun_index] > 0:
#player.reloading = true
@@ -134,5 +136,13 @@ func pellet_spawn():
get_tree().get_root().add_child(instance_bullet)
pellets_remaining -= 1
func barrel_smoke(emitting_state):
smoke.emitting = emitting_state
smoke_timer.start()
func swapped_out():
queue_free()
func _on_smoke_timer_timeout() -> void:
barrel_smoke(false)