fixed cycle count on weapon script

This commit is contained in:
Derek
2025-03-11 22:25:51 -05:00
parent 64ec7b12b6
commit a6ee53ed3e
6 changed files with 18 additions and 20 deletions

View File

@@ -1,6 +1,5 @@
extends Node3D
const DEAD_CAM_FOV = 50.0
@export var MOVE_SPEED = 30

View File

@@ -358,7 +358,7 @@ func _physics_process(delta):
SENSITIVITY = start_sensitivity
if remaining_stamina < level_control.gamemode.max_stamina and !Input.is_action_pressed("slow_down"):
if level_control.gamemode.stamina_regen == true:
remaining_stamina = clamp(remaining_stamina + (delta * level_control.gamemode.stamina_drain/Engine.time_scale), 0, level_control.gamemode.max_stamina)
remaining_stamina = clamp(remaining_stamina + (delta * level_control.gamemode.stamina_gain/Engine.time_scale), 0, level_control.gamemode.max_stamina)
# Reloading
@@ -381,10 +381,6 @@ func _physics_process(delta):
if Input.is_action_pressed("shoot"):
if gun != null:
gun.shoot()
if Input.is_action_just_released("shoot"):
if gun != null:
gun.cycle_count = gun.cycle_count_start
# Gun folding out of the way
if gun_ray.is_colliding():
@@ -619,9 +615,9 @@ func grab_moveable(body):
body.gravity_scale = 0
moveable_holder.add_child(body)
body.global_position = moveable_holder.global_position
for i in body.get_children():
if i.get_class() == "CollisionShape3D":
i.collision_layer = true
#for i in body.get_children():
#if i.get_class() == "CollisionShape3D":
#i.collision_layer = true
held_item = body
func hold_item(_delta):
@@ -633,9 +629,9 @@ func hold_item(_delta):
func release_moveable():
held_item.gravity_scale = held_item_cache["gravity_scale"]
for i in held_item.get_children():
if i.get_class() == "CollisionShape3D":
i.disabled = false
#for i in held_item.get_children():
#if i.get_class() == "CollisionShape3D":
#i.disabled = false
get_tree().current_scene.add_child(held_item)
held_item = null

View File

@@ -59,7 +59,10 @@ func _process(_delta):
var rot_amount = revolver_chamber_rot_amt * _delta * 10
chamber.rotate_object_local(Vector3(0,-1,0),deg_to_rad(rot_amount))
revolver_chamber_rot_amt -= rot_amount
if Input.is_action_just_released("shoot"):
cycle_count = cycle_count_start
if weapon_info.weapon_type == 2:
if tracker != null:
weapon_info.tracker_asset.tracker_indicator_material.emission = TRACKER_ASSIGNED_COLOR
@@ -101,6 +104,8 @@ func shoot():
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")
@@ -267,8 +272,6 @@ func bullet_fire():
player.recoil.add_gun_recoil(weapon_info.recoil_amount.x)
SignalBus.emit_signal("shot_fired")
if weapon_info.fire_mode != 0:
cycle_count -= 1
func hitscan_fire():
# Fire hitscan