ammo rework seems to mostly be in order
This commit is contained in:
@@ -9,6 +9,7 @@ var cycle_count
|
||||
@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 fov_zoom_amt = 10
|
||||
@export var ads : bool = false
|
||||
@@ -101,9 +102,9 @@ func _process(delta):
|
||||
|
||||
func reload_finished():
|
||||
#if max ammo in reserve fill all the way
|
||||
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
|
||||
casings_chamber_last = max_ammo
|
||||
for i in casing_array:
|
||||
i.visible = true
|
||||
@@ -112,10 +113,10 @@ func reload_finished():
|
||||
player.reloading = false
|
||||
#if not max ammo in reserve add remaining ammo
|
||||
else:
|
||||
level_control.ammo_current[gun_index] += level_control.ammo_reserve[gun_index]
|
||||
var casings_in_chamber = level_control.ammo_reserve[gun_index]
|
||||
casings_chamber_last = 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)]
|
||||
var casings_in_chamber = player.ammo_reserve[str(ammo_type)]
|
||||
casings_chamber_last = player.ammo_reserve[str(ammo_type)]
|
||||
player.ammo_reserve[str(ammo_type)] -= player.ammo_reserve[str(ammo_type)]
|
||||
|
||||
while casings_in_chamber > 0:
|
||||
casing_array[casings_in_chamber].visible = true
|
||||
@@ -125,9 +126,9 @@ func reload_finished():
|
||||
player.reloading = false
|
||||
|
||||
func shoot(delta):
|
||||
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_fire.pitch_scale = 1 + rng.randf_range(-fire_pitch_scale_amt,fire_pitch_scale_amt)
|
||||
audio_fire.play()
|
||||
anim_player.play("shoot") #actual bullet spawn triggered by animation
|
||||
@@ -162,13 +163,13 @@ func fire(delta):
|
||||
Input.start_joy_vibration(0,.5,.9,.2)
|
||||
|
||||
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:
|
||||
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()
|
||||
for i in bullet_array:
|
||||
i.visible = false
|
||||
if anim_player.is_playing() and anim_player.current_animation == "reload":
|
||||
level_control.ammo_current[gun_index] = 0
|
||||
player.gun_ammo[gun_name] = 0
|
||||
|
||||
func spawn_casings():
|
||||
for i in casing_array:
|
||||
|
||||
Reference in New Issue
Block a user