ammo rework seems to mostly be in order
This commit is contained in:
@@ -4,6 +4,7 @@ extends Node3D
|
||||
@export_group("Gun Feel")
|
||||
@export var gun_name : String
|
||||
@export var gun_icon : Texture2D
|
||||
@export_enum("Light", "Medium", "Heavy", "Shotgun", "Rocket") var ammo_type: int
|
||||
@export_enum("Auto", "Single", "Burst") var fire_mode: int
|
||||
@export var hitscan_enabled : bool = false
|
||||
@export var ads : bool = false
|
||||
@@ -92,12 +93,12 @@ func _process(_delta):
|
||||
|
||||
|
||||
func reload_finished():
|
||||
if level_control.ammo_reserve[gun_index] >= max_ammo:
|
||||
level_control.ammo_current[gun_index] += max_ammo
|
||||
level_control.ammo_reserve[gun_index] -= max_ammo
|
||||
if player.ammo_reserve[str(ammo_type)] >= max_ammo:
|
||||
player.gun_ammo[gun_name] += max_ammo
|
||||
player.ammo_reserve[str(ammo_type)] -= max_ammo
|
||||
else:
|
||||
level_control.ammo_current[gun_index] += level_control.ammo_reserve[gun_index]
|
||||
level_control.ammo_reserve[gun_index] -= level_control.ammo_reserve[gun_index]
|
||||
player.gun_ammo[gun_name] += player.ammo_reserve[str(ammo_type)]
|
||||
player.ammo_reserve[str(ammo_type)] -= player.ammo_reserve[str(ammo_type)]
|
||||
|
||||
func shoot(delta):
|
||||
if !anim_player.is_playing():
|
||||
@@ -110,9 +111,9 @@ func shoot(delta):
|
||||
|
||||
|
||||
func fire():
|
||||
if level_control.ammo_current[gun_index] > 0 and cycle_count > 0:
|
||||
if player.gun_ammo[gun_name] > 0 and cycle_count > 0:
|
||||
if !anim_player.is_playing():
|
||||
level_control.ammo_current[gun_index] -= 1
|
||||
player.gun_ammo[gun_name] -= 1
|
||||
#audio and anims
|
||||
audio_fire.pitch_scale = 1 + rng.randf_range(-fire_pitch_scale_amt,fire_pitch_scale_amt)
|
||||
audio_fire.play()
|
||||
@@ -160,7 +161,7 @@ func remove_tracker():
|
||||
tracker = null
|
||||
|
||||
func check_ammo():
|
||||
if level_control.ammo_current[gun_index] == 0 and level_control.ammo_reserve[gun_index] > 0:
|
||||
if player.gun_ammo[gun_name] == 0 and player.ammo_reserve[str(ammo_type)] > 0:
|
||||
anim_player.play("reload")
|
||||
audio_reload.play()
|
||||
|
||||
@@ -168,15 +169,15 @@ func reload():
|
||||
if tracker != null:
|
||||
anim_player.play("remove_tracker")
|
||||
else:
|
||||
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:
|
||||
if player.gun_ammo[gun_name] < max_ammo and player.gun.anim_player.get_current_animation() != "reload" and player.ammo_reserve[str(ammo_type)] > 0:
|
||||
anim_player.play("reload")
|
||||
audio_reload.play()
|
||||
remove_tracker()
|
||||
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
|
||||
if player.gun_ammo[gun_name] == 0:
|
||||
player.gun_ammo[gun_name] = 0
|
||||
else:
|
||||
level_control.ammo_current[gun_index] = 1
|
||||
player.gun_ammo[gun_name] = 1
|
||||
|
||||
func spawn_mag():
|
||||
var instance_mag = mag.instantiate()
|
||||
|
||||
Reference in New Issue
Block a user