added crouch slide, disabled fov zoom on slow down for now

This commit is contained in:
derek
2024-12-09 12:56:04 -06:00
parent 6c16607956
commit a1518945d4
16 changed files with 152 additions and 43 deletions

Binary file not shown.

View File

@@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://crxxo7xpjoet4"
path="res://.godot/imported/crouch1.wav-c7ffdde760e7d3da9923b7b9d2ac5469.sample"
[deps]
source_file="res://assets/Audio/Player Character SFX/crouch1.wav"
dest_files=["res://.godot/imported/crouch1.wav-c7ffdde760e7d3da9923b7b9d2ac5469.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0

Binary file not shown.

View File

@@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://duku6mr3vl5fy"
path="res://.godot/imported/crouch2.wav-014a0d9270b8f6a57cdfe09915305387.sample"
[deps]
source_file="res://assets/Audio/Player Character SFX/crouch2.wav"
dest_files=["res://.godot/imported/crouch2.wav-014a0d9270b8f6a57cdfe09915305387.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://cvacd1bkjb2qy"
path="res://.godot/imported/cloth-rustle-jacket-SBA-300071212.wav-cc9070523e2a82ef92db250e9013c392.sample"
[deps]
source_file="res://assets/Audio/cloth-rustle-jacket-SBA-300071212.wav"
dest_files=["res://.godot/imported/cloth-rustle-jacket-SBA-300071212.wav-cc9070523e2a82ef92db250e9013c392.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0

View File

@@ -489,7 +489,7 @@ _data = {
[node name="mac10" node_paths=PackedStringArray("r_hand_location", "l_hand_location", "flare_light", "anim_player", "barrel_raycast", "casing_ejector", "mag_ejector", "audio_fire", "audio_empty", "audio_reload") instance=ExtResource("1_nb4p5")] [node name="mac10" node_paths=PackedStringArray("r_hand_location", "l_hand_location", "flare_light", "anim_player", "barrel_raycast", "casing_ejector", "mag_ejector", "audio_fire", "audio_empty", "audio_reload") instance=ExtResource("1_nb4p5")]
script = ExtResource("2_tskiy") script = ExtResource("2_tskiy")
gun_name = "Mac 10" gun_name = "Mac 10"
fov_zoom_amt = 0.995 fov_zoom_amt = 0.998
recoil_amount = Vector3(0.02, 0.05, 0.05) recoil_amount = Vector3(0.02, 0.05, 0.05)
max_ammo = 20 max_ammo = 20
bullet_damage = 2 bullet_damage = 2

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=31 format=3 uid="uid://drwae3loscbw7"] [gd_scene load_steps=30 format=3 uid="uid://drwae3loscbw7"]
[ext_resource type="Script" path="res://scripts/player.gd" id="1_x7wms"] [ext_resource type="Script" path="res://scripts/player.gd" id="1_x7wms"]
[ext_resource type="Script" path="res://scripts/recoil.gd" id="3_405jc"] [ext_resource type="Script" path="res://scripts/recoil.gd" id="3_405jc"]
@@ -15,11 +15,10 @@
[ext_resource type="Shader" path="res://assets/crtTest.gdshader" id="14_v5svg"] [ext_resource type="Shader" path="res://assets/crtTest.gdshader" id="14_v5svg"]
[ext_resource type="AudioStream" uid="uid://c1e6vr2hndho7" path="res://assets/Audio/Weapons/Misc (Ammo Boxes, Holsters, Etc)/Kydex Unholster 002.wav" id="17_1fyjm"] [ext_resource type="AudioStream" uid="uid://c1e6vr2hndho7" path="res://assets/Audio/Weapons/Misc (Ammo Boxes, Holsters, Etc)/Kydex Unholster 002.wav" id="17_1fyjm"]
[ext_resource type="AudioStream" uid="uid://dqj4cx05f25jj" path="res://assets/Audio/punch-body-hard-SBA-300156881.wav" id="19_6jglu"] [ext_resource type="AudioStream" uid="uid://dqj4cx05f25jj" path="res://assets/Audio/punch-body-hard-SBA-300156881.wav" id="19_6jglu"]
[ext_resource type="AudioStream" uid="uid://duku6mr3vl5fy" path="res://assets/Audio/Player Character SFX/crouch2.wav" id="19_pi7h7"]
[ext_resource type="AudioStream" uid="uid://n3e7s3xucsi1" path="res://assets/Audio/Foley Inventory and Interactions/Foley Inventory and Interactions/Drop Item/Drop Jewelery B.wav" id="20_rvr83"] [ext_resource type="AudioStream" uid="uid://n3e7s3xucsi1" path="res://assets/Audio/Foley Inventory and Interactions/Foley Inventory and Interactions/Drop Item/Drop Jewelery B.wav" id="20_rvr83"]
[ext_resource type="AudioStream" uid="uid://ig4e5tgbh87m" path="res://assets/Audio/Player Character SFX/footsteps-tennis-shoes-walk-1.wav" id="21_fsjho"] [ext_resource type="AudioStream" uid="uid://ig4e5tgbh87m" path="res://assets/Audio/Player Character SFX/footsteps-tennis-shoes-walk-1.wav" id="21_fsjho"]
[ext_resource type="AudioStream" uid="uid://c7bwilypn74lc" path="res://assets/Audio/Foley Sports/Hockey/Ball Hit Leg.wav" id="22_c88rq"] [ext_resource type="AudioStream" uid="uid://c7bwilypn74lc" path="res://assets/Audio/Foley Sports/Hockey/Ball Hit Leg.wav" id="22_c88rq"]
[ext_resource type="AudioStream" uid="uid://cpargxdhuh8dg" path="res://assets/Audio/Foley Inventory and Interactions/Foley Inventory and Interactions/Drop Item/Drop Cloth D.wav" id="23_u78r2"]
[ext_resource type="AudioStream" uid="uid://krod4c6cb6xd" path="res://assets/Audio/Foley Inventory and Interactions/Foley Inventory and Interactions/Drop Item/Drop Cloth C.wav" id="24_2p12q"]
[sub_resource type="CanvasItemMaterial" id="CanvasItemMaterial_l5ga0"] [sub_resource type="CanvasItemMaterial" id="CanvasItemMaterial_l5ga0"]
blend_mode = 1 blend_mode = 1
@@ -76,9 +75,8 @@ stream_0/stream = ExtResource("22_c88rq")
[sub_resource type="AudioStreamRandomizer" id="AudioStreamRandomizer_xswn0"] [sub_resource type="AudioStreamRandomizer" id="AudioStreamRandomizer_xswn0"]
random_pitch = 2.0 random_pitch = 2.0
streams_count = 2 streams_count = 1
stream_0/stream = ExtResource("23_u78r2") stream_0/stream = ExtResource("19_pi7h7")
stream_1/stream = ExtResource("24_2p12q")
[node name="Player" type="CharacterBody3D" node_paths=PackedStringArray("weapon_holder") groups=["persist", "player"]] [node name="Player" type="CharacterBody3D" node_paths=PackedStringArray("weapon_holder") groups=["persist", "player"]]
transform = Transform3D(1, 0.000164476, 0.000583754, -0.000165075, 0.999999, 0.00104027, -0.000583585, -0.00104036, 0.999999, 0, 1.11359, 0) transform = Transform3D(1, 0.000164476, 0.000583754, -0.000165075, 0.999999, 0.00104027, -0.000583585, -0.00104036, 0.999999, 0, 1.11359, 0)

View File

@@ -1067,6 +1067,7 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.0718293, 0)
script = ExtResource("2_7rsti") script = ExtResource("2_7rsti")
gun_name = ".44 Galore" gun_name = ".44 Galore"
fire_mode = 1 fire_mode = 1
fov_zoom_amt = 0.99
recoil_amount = Vector3(0.25, 0.1, 0.1) recoil_amount = Vector3(0.25, 0.1, 0.1)
max_ammo = 6 max_ammo = 6
bullet_damage = 5 bullet_damage = 5

View File

@@ -620,6 +620,7 @@ _data = {
script = ExtResource("1_w46uw") script = ExtResource("1_w46uw")
gun_name = "Blunderbuss" gun_name = "Blunderbuss"
fire_mode = 1 fire_mode = 1
fov_zoom_amt = 0.998
recoil_amount = Vector3(0.5, 0.2, 0.2) recoil_amount = Vector3(0.5, 0.2, 0.2)
spread = Vector3(90, 90, 1) spread = Vector3(90, 90, 1)
kick_amount = 10.0 kick_amount = 10.0

View File

@@ -173,4 +173,4 @@ layout_mode = 2
theme = ExtResource("2_eqnx7") theme = ExtResource("2_eqnx7")
theme_override_colors/font_shadow_color = Color(0, 0, 0, 1) theme_override_colors/font_shadow_color = Color(0, 0, 0, 1)
text = "XX - XX" text = "XX - XX"
horizontal_alignment = 1 horizontal_alignment = 2

View File

@@ -305,6 +305,7 @@ shadow_mesh = SubResource("ArrayMesh_7g1e1")
[node name="AssetChecker" type="Node3D" node_paths=PackedStringArray("player")] [node name="AssetChecker" type="Node3D" node_paths=PackedStringArray("player")]
script = ExtResource("1_saj4q") script = ExtResource("1_saj4q")
load_save = false
player = NodePath("Player") player = NodePath("Player")
gun_1 = ExtResource("2_ntm2q") gun_1 = ExtResource("2_ntm2q")
gun_2 = ExtResource("12_d3sh8") gun_2 = ExtResource("12_d3sh8")

View File

@@ -5,6 +5,8 @@ extends Control
var current_stam_bar var current_stam_bar
var stam_bar_visible : bool = false var stam_bar_visible : bool = false
var interact_visible : bool = false var interact_visible : bool = false
var health_bar_start_pos
var money_count : int = 0
@onready var level_control = get_tree().current_scene @onready var level_control = get_tree().current_scene
@onready var player = level_control.player @onready var player = level_control.player
@@ -19,14 +21,18 @@ var interact_visible : bool = false
const FULL_WHITE = Color(1, 1, 1, 1) const FULL_WHITE = Color(1, 1, 1, 1)
const TRANSPARENT = Color(1, 1, 1, 0) const TRANSPARENT = Color(1, 1, 1, 0)
const RED_COLOR = Color(1, 0, 0) const RED_COLOR = Color(1, 0, 0)
const ORANGE_COLOR = Color(0.822, 0.318, 0.086)
const GREEN_COLOR = Color(0, 0.608, 0.172) const GREEN_COLOR = Color(0, 0.608, 0.172)
const STAM_BAR_MAX_OPACITY = .7 const STAM_BAR_MAX_OPACITY = 1.0
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready() -> void: func _ready() -> void:
SignalBus.player_hit.connect(player_hit)
health_bar.max_value = level_control.start_health health_bar.max_value = level_control.start_health
health_bar_start_pos = health_bar.position
if radial_stamina: if radial_stamina:
current_stam_bar = stamina_bar current_stam_bar = stamina_bar
stamina_bar_2.visible = false stamina_bar_2.visible = false
@@ -42,24 +48,38 @@ func _process(delta: float) -> void:
health_bar.value = level_control.health health_bar.value = level_control.health
if level_control.health <= 2: if level_control.health <= 2:
change_color(health_bar,RED_COLOR,10,delta) change_color(health_bar,RED_COLOR,10,delta)
health_bar.position += wiggle_element() health_bar.position = health_bar_start_pos + shake_element(15)
elif level_control.health < ((level_control.start_health / 2) + 1):
change_color(health_bar,ORANGE_COLOR,10,delta)
else: else:
change_color(health_bar,FULL_WHITE,10,delta) change_color(health_bar,FULL_WHITE,10,delta)
#MONEY #MONEY
money.text = "$" + str(level_control.money) if money_count < level_control.money:
money_count += 1
change_color(money,GREEN_COLOR,10,delta)
elif money_count > level_control.money:
change_color(money,RED_COLOR,10,delta)
money_count -= 1
else:
change_color(money,FULL_WHITE,10,delta)
money.text = "$" + str(money_count)
if player.remaining_stamina/player.MAX_STAMINA >= .99: if player.remaining_stamina/player.MAX_STAMINA >= .99:
stam_bar_visible = false stam_bar_visible = false
else: else:
stam_bar_visible = true stam_bar_visible = true
current_stam_bar.value = player.remaining_stamina current_stam_bar.value = player.remaining_stamina
ammo.text = str(level_control.ammo_current[level_control.current_gun_index]) +" - " + str(level_control.ammo_reserve[level_control.current_gun_index]) ammo.text = str(level_control.ammo_current[level_control.current_gun_index]) +" | " + str(level_control.ammo_reserve[level_control.current_gun_index])
if player.gun != null: if player.gun != null:
gun_name.text = player.gun.gun_name gun_name.text = player.gun.gun_name
else: else:
gun_name.visible = false gun_name.visible = false
lerp_color(ammo,RED_COLOR,FULL_WHITE,level_control.ammo_current[level_control.current_gun_index],player.gun.max_ammo,.5)
if player.remaining_stamina < 25: if player.remaining_stamina < 25:
change_color(current_stam_bar,RED_COLOR,10,delta) change_color(current_stam_bar,RED_COLOR,10,delta)
change_color(crosshair,RED_COLOR,10,delta) change_color(crosshair,RED_COLOR,10,delta)
@@ -81,20 +101,39 @@ func _process(delta: float) -> void:
else: else:
change_color(crosshair,FULL_WHITE,10,delta) change_color(crosshair,FULL_WHITE,10,delta)
## FADE ELEMENTS IN AND OUT if player.ads:
fade_in_out(current_stam_bar,STAM_BAR_MAX_OPACITY,stam_bar_visible,delta) if player.gun.ads:
fade_in_out(crosshair,1,false,5,delta)
else:
fade_in_out(crosshair,1,true,5,delta)
else:
fade_in_out(crosshair,1,true,5,delta)
func wiggle_element(): ## FADE ELEMENTS IN AND OUT
var rand_x = randf_range(-5,5) fade_in_out(current_stam_bar,STAM_BAR_MAX_OPACITY,stam_bar_visible,5,delta)
var rand_y = randf_range(-5,5)
func shake_element(amount):
var rand_x = randf_range(-amount,amount)
var rand_y = randf_range(-amount,amount)
return Vector2(rand_x,rand_y) return Vector2(rand_x,rand_y)
func lerp_color(element,colorA,colorB,cur_value,max_value,active_percent):
var value : float = float(cur_value)/float(max_value)
if value <= active_percent:
element.modulate = lerp(colorA,colorB,value)
else:
element.modulate = colorB
func change_color(element,color,speed,delta): func change_color(element,color,speed,delta):
element.modulate = lerp(element.modulate, Color(color.r,color.g,color.b,element.modulate.a), (delta * speed)/Engine.time_scale) element.modulate = lerp(element.modulate, Color(color.r,color.g,color.b,element.modulate.a), (delta * speed)/Engine.time_scale)
func fade_in_out(element,MAX_OPACITY,visible,delta): func fade_in_out(element,MAX_OPACITY,visible,speed,delta):
var element_color = element.modulate var element_color = element.modulate
if visible: if visible:
element.modulate = lerp(element_color, Color(element_color.r,element_color.g,element_color.b,MAX_OPACITY),(delta * 10)/Engine.time_scale) element.modulate = lerp(element_color, Color(element_color.r,element_color.g,element_color.b,MAX_OPACITY),(delta * speed)/Engine.time_scale)
else: else:
element.modulate = lerp(element_color, Color(element_color.r,element_color.g,element_color.b,0),(delta * 10)/Engine.time_scale) element.modulate = lerp(element_color, Color(element_color.r,element_color.g,element_color.b,0),(delta * speed)/Engine.time_scale)
func player_hit():
pass
#self.position += wiggle_element(25)

View File

@@ -47,7 +47,7 @@ var start_sensitivity
@export_subgroup("Head Bob & Gun Sway") @export_subgroup("Head Bob & Gun Sway")
@export var t_bob = 1.0 @export var t_bob = 1.0
@export var weapon_holder : Node3D @export var weapon_holder : Node3D
@export var weapon_sway_amount : float = .14 @export var weapon_sway_amount : float = .09
@export var weapon_rotation_amount : float = .07 @export var weapon_rotation_amount : float = .07
@export_subgroup("FOV") @export_subgroup("FOV")
@export var BASE_FOV : float = 80 @export var BASE_FOV : float = 80
@@ -206,6 +206,15 @@ func _physics_process(delta):
velocity.y += JUMP_VELOCITY velocity.y += JUMP_VELOCITY
double_jump = false double_jump = false
# Get the input direction and handle the movement/deceleration.
var input_dir = Input.get_vector("move_left", "move_right", "move_up", "move_down")
var direction = (self.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
# Handle Sprint
if Input.is_action_just_pressed("sprint") and !is_on_floor():
if air_dash > 0:
velocity.x += direction.x * DASH_SPEED
velocity.z += direction.z * DASH_SPEED
air_dash -= 1
if Input.is_action_just_pressed("crouch"): if Input.is_action_just_pressed("crouch"):
if crouched: if crouched:
@@ -220,18 +229,9 @@ func _physics_process(delta):
crouched = !crouched crouched = !crouched
recoil.add_recoil(Vector3(.2,0,0),5,10) recoil.add_recoil(Vector3(.2,0,0),5,10)
crouch_audio.play() crouch_audio.play()
velocity.y -= 15
if is_on_floor():
# Get the input direction and handle the movement/deceleration. velocity += direction * 20
var input_dir = Input.get_vector("move_left", "move_right", "move_up", "move_down")
var direction = (self.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
# Handle Sprint
if Input.is_action_just_pressed("sprint") and !is_on_floor():
if air_dash > 0:
velocity.x += direction.x * DASH_SPEED
velocity.z += direction.z * DASH_SPEED
air_dash -= 1
print("AIR DASH " +str(air_dash))
#walking #walking
if is_on_floor() and !is_climbing: if is_on_floor() and !is_climbing:
@@ -293,22 +293,19 @@ func _physics_process(delta):
if Input.is_action_pressed("slow_down") and remaining_stamina > 0 : if Input.is_action_pressed("slow_down") and remaining_stamina > 0 :
ads = true ads = true
if !gamespeed_controlled: if !gamespeed_controlled:
Engine.time_scale = lerp(Engine.time_scale, SLOWSPEED, delta * 20) Engine.time_scale = lerp(Engine.time_scale, SLOWSPEED, (delta * 50) / Engine.time_scale)
#gun.random_spread_amt = 0 #gun.random_spread_amt = 0
AudioServer.set_bus_effect_enabled(0,0,true) AudioServer.set_bus_effect_enabled(0,0,true)
camera.fov = lerp(camera.fov, camera.fov * gun.fov_zoom_amt, delta * 100)
if sensitivity_shift == true: if sensitivity_shift == true:
SENSITIVITY = lerp(SENSITIVITY, SENSITIVITY * .998, delta * 100) SENSITIVITY = lerp(SENSITIVITY, SENSITIVITY * .998, (delta * 100) / Engine.time_scale)
if remaining_stamina > 0: if remaining_stamina > 0:
remaining_stamina = clamp(remaining_stamina - ((delta * STAMINA_DRAIN)/Engine.time_scale),0,MAX_STAMINA) remaining_stamina = clamp(remaining_stamina - ((delta * STAMINA_DRAIN) / Engine.time_scale),0,MAX_STAMINA)
else: else:
ads = false ads = false
if !gamespeed_controlled: if !gamespeed_controlled:
Engine.time_scale = lerp(Engine.time_scale, 1.0, delta * 50) Engine.time_scale = lerp(Engine.time_scale, 1.0, (delta * 50)/Engine.time_scale)
#gun.random_spread_amt = gun.random_spread_start #gun.random_spread_amt = gun.random_spread_start
AudioServer.set_bus_effect_enabled(0,0,false) AudioServer.set_bus_effect_enabled(0,0,false)
if sensitivity_shift == true:
camera.fov = lerp(camera.fov, BASE_FOV, delta * .5)
SENSITIVITY = start_sensitivity SENSITIVITY = start_sensitivity
if remaining_stamina < MAX_STAMINA and !Input.is_action_pressed("slow_down"): if remaining_stamina < MAX_STAMINA and !Input.is_action_pressed("slow_down"):
remaining_stamina = clamp(remaining_stamina + (delta * STAMINA_DRAIN/Engine.time_scale), 0, MAX_STAMINA) remaining_stamina = clamp(remaining_stamina + (delta * STAMINA_DRAIN/Engine.time_scale), 0, MAX_STAMINA)
@@ -448,11 +445,9 @@ func aim_down_sights(delta):
if gun: if gun:
if gun.ads == true: if gun.ads == true:
if ads: if ads:
crosshair.visible = false
camera.fov -= .1 camera.fov -= .1
gun.position = lerp(gun.position,ADS_POS,delta * 10 / Engine.time_scale) gun.position = lerp(gun.position,ADS_POS,delta * 10 / Engine.time_scale)
else: else:
crosshair.visible = true
gun.position = lerp(gun.position, weapon_start_pos,delta * 2) gun.position = lerp(gun.position, weapon_start_pos,delta * 2)
func _headbob(time) -> Vector3: func _headbob(time) -> Vector3:
@@ -583,6 +578,7 @@ func release_moveable():
moveable_holder.rotation = Vector3(0,0,0) moveable_holder.rotation = Vector3(0,0,0)
func hit(damage, fired_by, target_type): func hit(damage, fired_by, target_type):
SignalBus.emit_signal("player_hit")
level_control.health -= damage level_control.health -= damage
level_control.last_hit = fired_by level_control.last_hit = fired_by
level_control.target_type = target_type level_control.target_type = target_type

View File

@@ -7,3 +7,4 @@ signal enemy_killed()
signal king_killed() signal king_killed()
signal enemy_count_changed() signal enemy_count_changed()
signal game_loaded() signal game_loaded()
signal player_hit()