finally built the crosshair of my dreams
This commit is contained in:
@@ -103,37 +103,38 @@ func reload_finished():
|
||||
|
||||
|
||||
func shoot():
|
||||
if weapon_info.weapon_type == 0:
|
||||
if GameGlobals.gun_ammo[weapon_info.gun_name] > 0 and cycle_count > 0:
|
||||
if GameGlobals.gun_ammo.has(weapon_info.gun_name):
|
||||
if weapon_info.weapon_type == 0:
|
||||
if GameGlobals.gun_ammo[weapon_info.gun_name] > 0 and cycle_count > 0:
|
||||
if !anim_player.is_playing():
|
||||
GameGlobals.gun_ammo[weapon_info.gun_name] -= 1
|
||||
if weapon_info.fire_mode != 0:
|
||||
cycle_count -= 1
|
||||
#audio and anims
|
||||
anim_player.play("shoot")
|
||||
|
||||
elif !anim_player.is_playing() and cycle_count != 0:
|
||||
anim_player.play("empty")
|
||||
audio_empty.play()
|
||||
|
||||
elif weapon_info.weapon_type == 1:
|
||||
if !anim_player.is_playing():
|
||||
GameGlobals.gun_ammo[weapon_info.gun_name] -= 1
|
||||
if weapon_info.fire_mode != 0:
|
||||
cycle_count -= 1
|
||||
#audio and anims
|
||||
anim_player.play("shoot")
|
||||
vibration()
|
||||
player.recoil.add_recoil(Vector3(0,weapon_info.recoil_amount.y,weapon_info.recoil_amount.z),10,10)
|
||||
player.recoil.add_gun_recoil(weapon_info.recoil_amount.x)
|
||||
SignalBus.emit_signal("shot_fired")
|
||||
|
||||
elif weapon_info.weapon_type == 2:
|
||||
if !anim_player.is_playing():
|
||||
if tracker == null and Input.is_action_just_pressed("shoot"):
|
||||
check_track = true
|
||||
weapon_info.tracker_check_mesh.visible = true
|
||||
weapon_info.tracker_check_mesh.anim_player.play("check")
|
||||
if tracker != null and !check_track:
|
||||
anim_player.play("shoot")
|
||||
|
||||
elif !anim_player.is_playing() and cycle_count != 0:
|
||||
anim_player.play("empty")
|
||||
audio_empty.play()
|
||||
|
||||
elif weapon_info.weapon_type == 1:
|
||||
if !anim_player.is_playing():
|
||||
#audio and anims
|
||||
anim_player.play("shoot")
|
||||
vibration()
|
||||
player.recoil.add_recoil(Vector3(0,weapon_info.recoil_amount.y,weapon_info.recoil_amount.z),10,10)
|
||||
player.recoil.add_gun_recoil(weapon_info.recoil_amount.x)
|
||||
SignalBus.emit_signal("shot_fired")
|
||||
|
||||
elif weapon_info.weapon_type == 2:
|
||||
if !anim_player.is_playing():
|
||||
if tracker == null and Input.is_action_just_pressed("shoot"):
|
||||
check_track = true
|
||||
weapon_info.tracker_check_mesh.visible = true
|
||||
weapon_info.tracker_check_mesh.anim_player.play("check")
|
||||
if tracker != null and !check_track:
|
||||
anim_player.play("shoot")
|
||||
|
||||
func reload():
|
||||
match weapon_info.weapon_type:
|
||||
0:
|
||||
@@ -276,6 +277,12 @@ func bullet_fire():
|
||||
SignalBus.emit_signal("shot_fired")
|
||||
|
||||
|
||||
func can_fire():
|
||||
if anim_player.is_playing() and anim_player.current_animation == "reload":
|
||||
return false
|
||||
else:
|
||||
return true
|
||||
|
||||
func hitscan_fire():
|
||||
# Fire hitscan
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user