added weapon holstering
This commit is contained in:
@@ -22,8 +22,8 @@ float getDepth(vec2 screen_uv, sampler2D depth_texture, mat4 inv_projection_matr
|
|||||||
// Credit: https://godotshaders.com/shader/depth-modulated-pixel-outline-in-screen-space/
|
// Credit: https://godotshaders.com/shader/depth-modulated-pixel-outline-in-screen-space/
|
||||||
float raw_depth = texture(depth_texture, screen_uv)[0];
|
float raw_depth = texture(depth_texture, screen_uv)[0];
|
||||||
vec3 normalized_device_coordinates = vec3(screen_uv * 2.0 - 1.0, raw_depth);
|
vec3 normalized_device_coordinates = vec3(screen_uv * 2.0 - 1.0, raw_depth);
|
||||||
vec4 view_space = inv_projection_matrix * vec4(normalized_device_coordinates, 1.0);
|
vec4 view_space = inv_projection_matrix * vec4(normalized_device_coordinates, 1.0);
|
||||||
view_space.xyz /= view_space.w;
|
view_space.xyz /= view_space.w;
|
||||||
return -view_space.z;
|
return -view_space.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ void vertex(){
|
|||||||
|
|
||||||
void fragment() {
|
void fragment() {
|
||||||
vec2 e = vec2(1./VIEWPORT_SIZE.xy);
|
vec2 e = vec2(1./VIEWPORT_SIZE.xy);
|
||||||
|
|
||||||
// Shadows
|
// Shadows
|
||||||
float depth_diff = 0.0;
|
float depth_diff = 0.0;
|
||||||
float neg_depth_diff = .5;
|
float neg_depth_diff = .5;
|
||||||
@@ -70,7 +70,7 @@ void fragment() {
|
|||||||
depth_diff = smoothstep(0.2, 0.3, depth_diff);
|
depth_diff = smoothstep(0.2, 0.3, depth_diff);
|
||||||
// ALBEDO = vec3(neg_depth_diff);
|
// ALBEDO = vec3(neg_depth_diff);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Highlights
|
// Highlights
|
||||||
float normal_diff = 0.;
|
float normal_diff = 0.;
|
||||||
if (highlights_enabled) {
|
if (highlights_enabled) {
|
||||||
@@ -88,7 +88,7 @@ void fragment() {
|
|||||||
normal_diff = clamp(normal_diff-neg_depth_diff, 0., 1.);
|
normal_diff = clamp(normal_diff-neg_depth_diff, 0., 1.);
|
||||||
// ALBEDO = vec3(normal_diff);
|
// ALBEDO = vec3(normal_diff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
vec3 original_color = texture(SCREEN_TEXTURE, SCREEN_UV).rgb;
|
vec3 original_color = texture(SCREEN_TEXTURE, SCREEN_UV).rgb;
|
||||||
vec3 final_highlight_color = mix(original_color, highlight_color, highlight_strength);
|
vec3 final_highlight_color = mix(original_color, highlight_color, highlight_strength);
|
||||||
|
|||||||
@@ -529,7 +529,7 @@ audio_empty = NodePath("Audio/Empty")
|
|||||||
audio_reload = NodePath("Audio/Reload")
|
audio_reload = NodePath("Audio/Reload")
|
||||||
|
|
||||||
[node name="mac10" parent="." index="0"]
|
[node name="mac10" parent="." index="0"]
|
||||||
transform = Transform3D(-1.08301e-06, -8.05116e-08, -0.3, -0.0225093, 0.299154, 9.74567e-10, 0.299154, 0.0225093, -1.086e-06, -0.00876398, 0.0748287, -0.0557729)
|
transform = Transform3D(-1.08301e-06, -8.05114e-08, -0.3, -0.0225093, 0.299154, 9.74772e-10, 0.299154, 0.0225093, -1.086e-06, -0.00876398, 0.0748287, -0.0557729)
|
||||||
lod_bias = 10.0
|
lod_bias = 10.0
|
||||||
mesh = SubResource("ArrayMesh_pcg38")
|
mesh = SubResource("ArrayMesh_pcg38")
|
||||||
|
|
||||||
|
|||||||
14
hud.tscn
14
hud.tscn
@@ -131,7 +131,7 @@ value = 49.0
|
|||||||
fill_mode = 5
|
fill_mode = 5
|
||||||
texture_progress = ExtResource("4_ooaul")
|
texture_progress = ExtResource("4_ooaul")
|
||||||
|
|
||||||
[node name="MarginContainer" type="MarginContainer" parent="."]
|
[node name="GunInfo" type="MarginContainer" parent="."]
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
anchors_preset = 3
|
anchors_preset = 3
|
||||||
anchor_left = 1.0
|
anchor_left = 1.0
|
||||||
@@ -148,7 +148,7 @@ theme_override_constants/margin_top = 50
|
|||||||
theme_override_constants/margin_right = 50
|
theme_override_constants/margin_right = 50
|
||||||
theme_override_constants/margin_bottom = 50
|
theme_override_constants/margin_bottom = 50
|
||||||
|
|
||||||
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"]
|
[node name="VBoxContainer" type="VBoxContainer" parent="GunInfo"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_horizontal = 8
|
size_flags_horizontal = 8
|
||||||
size_flags_vertical = 8
|
size_flags_vertical = 8
|
||||||
@@ -156,7 +156,7 @@ theme = ExtResource("1_22trs")
|
|||||||
theme_override_constants/separation = 10
|
theme_override_constants/separation = 10
|
||||||
alignment = 2
|
alignment = 2
|
||||||
|
|
||||||
[node name="Gun Name" type="Label" parent="MarginContainer/VBoxContainer"]
|
[node name="Gun Name" type="Label" parent="GunInfo/VBoxContainer"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
theme = ExtResource("1_22trs")
|
theme = ExtResource("1_22trs")
|
||||||
theme_type_variation = &"TextShadow"
|
theme_type_variation = &"TextShadow"
|
||||||
@@ -164,25 +164,25 @@ theme_override_colors/font_shadow_color = Color(0, 0, 0, 1)
|
|||||||
text = "Gun Name"
|
text = "Gun Name"
|
||||||
horizontal_alignment = 2
|
horizontal_alignment = 2
|
||||||
|
|
||||||
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
|
[node name="HBoxContainer" type="HBoxContainer" parent="GunInfo/VBoxContainer"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_vertical = 3
|
size_flags_vertical = 3
|
||||||
theme = ExtResource("1_22trs")
|
theme = ExtResource("1_22trs")
|
||||||
theme_override_constants/separation = 50
|
theme_override_constants/separation = 50
|
||||||
alignment = 2
|
alignment = 2
|
||||||
|
|
||||||
[node name="AmmoCurrent" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer"]
|
[node name="AmmoCurrent" type="Label" parent="GunInfo/VBoxContainer/HBoxContainer"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
theme = ExtResource("1_22trs")
|
theme = ExtResource("1_22trs")
|
||||||
theme_override_colors/font_shadow_color = Color(0, 0, 0, 1)
|
theme_override_colors/font_shadow_color = Color(0, 0, 0, 1)
|
||||||
text = "XXX"
|
text = "XXX"
|
||||||
horizontal_alignment = 2
|
horizontal_alignment = 2
|
||||||
|
|
||||||
[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer"]
|
[node name="Label" type="Label" parent="GunInfo/VBoxContainer/HBoxContainer"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
text = "-"
|
text = "-"
|
||||||
|
|
||||||
[node name="AmmoReserve" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer"]
|
[node name="AmmoReserve" type="Label" parent="GunInfo/VBoxContainer/HBoxContainer"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
theme = ExtResource("1_22trs")
|
theme = ExtResource("1_22trs")
|
||||||
theme_override_colors/font_shadow_color = Color(0, 0, 0, 1)
|
theme_override_colors/font_shadow_color = Color(0, 0, 0, 1)
|
||||||
|
|||||||
@@ -215,6 +215,11 @@ weapon_select={
|
|||||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":10,"pressure":0.0,"pressed":true,"script":null)
|
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":10,"pressure":0.0,"pressed":true,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
holster={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":72,"key_label":0,"unicode":104,"location":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
[layer_names]
|
[layer_names]
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
[ext_resource type="Script" path="res://scripts/LevelManager.gd" id="1_8g3mj"]
|
[ext_resource type="Script" path="res://scripts/LevelManager.gd" id="1_8g3mj"]
|
||||||
[ext_resource type="PackedScene" uid="uid://xerc06hjfnbf" path="res://assets/LevelBlockouts/blockout4.blend" id="1_038d8"]
|
[ext_resource type="PackedScene" uid="uid://xerc06hjfnbf" path="res://assets/LevelBlockouts/blockout4.blend" id="1_038d8"]
|
||||||
[ext_resource type="PackedScene" uid="uid://brl0bsqjl5dg3" path="res://assets/mac_10.tscn" id="2_7eop6"]
|
|
||||||
[ext_resource type="PackedScene" uid="uid://drwae3loscbw7" path="res://assets/player.tscn" id="4_ykmsc"]
|
[ext_resource type="PackedScene" uid="uid://drwae3loscbw7" path="res://assets/player.tscn" id="4_ykmsc"]
|
||||||
[ext_resource type="PackedScene" uid="uid://df34olntmk0wl" path="res://assets/vent_1.tscn" id="5_hc1cs"]
|
[ext_resource type="PackedScene" uid="uid://df34olntmk0wl" path="res://assets/vent_1.tscn" id="5_hc1cs"]
|
||||||
[ext_resource type="PackedScene" uid="uid://20csd6dmwj4y" path="res://assets/jump_platform.tscn" id="6_p3qak"]
|
[ext_resource type="PackedScene" uid="uid://20csd6dmwj4y" path="res://assets/jump_platform.tscn" id="6_p3qak"]
|
||||||
@@ -16,6 +15,7 @@
|
|||||||
[ext_resource type="PackedScene" uid="uid://ci6br7jbolnfd" path="res://assets/couch_1.tscn" id="14_q5ihs"]
|
[ext_resource type="PackedScene" uid="uid://ci6br7jbolnfd" path="res://assets/couch_1.tscn" id="14_q5ihs"]
|
||||||
[ext_resource type="PackedScene" uid="uid://8bi7l3seimd2" path="res://assets/couchtest.tscn" id="15_cf1ia"]
|
[ext_resource type="PackedScene" uid="uid://8bi7l3seimd2" path="res://assets/couchtest.tscn" id="15_cf1ia"]
|
||||||
[ext_resource type="PackedScene" uid="uid://cucqbjb8bcha5" path="res://assets/blunderbuss_pickup.tscn" id="16_nmeud"]
|
[ext_resource type="PackedScene" uid="uid://cucqbjb8bcha5" path="res://assets/blunderbuss_pickup.tscn" id="16_nmeud"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://cnfc8rtk6l1d8" path="res://assets/crate1.tscn" id="17_cjqdn"]
|
||||||
[ext_resource type="Shader" path="res://assets/Shaders/outline.gdshader" id="17_s06ug"]
|
[ext_resource type="Shader" path="res://assets/Shaders/outline.gdshader" id="17_s06ug"]
|
||||||
|
|
||||||
[sub_resource type="Environment" id="Environment_q4t3f"]
|
[sub_resource type="Environment" id="Environment_q4t3f"]
|
||||||
@@ -55,7 +55,6 @@ size = Vector2(2, 2)
|
|||||||
[node name="Blockout4" type="Node3D" node_paths=PackedStringArray("player")]
|
[node name="Blockout4" type="Node3D" node_paths=PackedStringArray("player")]
|
||||||
script = ExtResource("1_8g3mj")
|
script = ExtResource("1_8g3mj")
|
||||||
player = NodePath("Player")
|
player = NodePath("Player")
|
||||||
gun_1 = ExtResource("2_7eop6")
|
|
||||||
|
|
||||||
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
|
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
|
||||||
environment = SubResource("Environment_q4t3f")
|
environment = SubResource("Environment_q4t3f")
|
||||||
@@ -659,3 +658,6 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 27.1174, 0.540232, -34.5854)
|
|||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.271851, 1.43588, -9.80906)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.271851, 1.43588, -9.80906)
|
||||||
extra_cull_margin = 16384.0
|
extra_cull_margin = 16384.0
|
||||||
mesh = SubResource("QuadMesh_nmuj5")
|
mesh = SubResource("QuadMesh_nmuj5")
|
||||||
|
|
||||||
|
[node name="Crate1" parent="." instance=ExtResource("17_cjqdn")]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -6.32071, 1.30517, -8.50818)
|
||||||
|
|||||||
@@ -134,16 +134,17 @@ func gun_spawn(index):
|
|||||||
|
|
||||||
current_gun_index = index
|
current_gun_index = index
|
||||||
|
|
||||||
var instance_gun = held_guns[index].instantiate()
|
if held_guns != []:
|
||||||
instance_gun.global_transform.origin = player.weapon_spawner.position
|
var instance_gun = held_guns[index].instantiate()
|
||||||
player.gun = instance_gun
|
instance_gun.global_transform.origin = player.weapon_spawner.position
|
||||||
player.def_weapon_holder_pos = player.weapon_holder.position
|
player.gun = instance_gun
|
||||||
player.ammo = player.gun.max_ammo
|
player.def_weapon_holder_pos = player.weapon_holder.position
|
||||||
player.ammo_reserve = player.gun.max_ammo * player.gun.start_mags
|
player.ammo = player.gun.max_ammo
|
||||||
#player.gun_fire_pitch_starting = player.gun.audio_fire.pitch_scale
|
player.ammo_reserve = player.gun.max_ammo * player.gun.start_mags
|
||||||
instance_gun.gun_index = index
|
#player.gun_fire_pitch_starting = player.gun.audio_fire.pitch_scale
|
||||||
instance_gun.anim_player.play("swap_in")
|
instance_gun.gun_index = index
|
||||||
player.weapon_holder.add_child(instance_gun)
|
instance_gun.anim_player.play("swap_in")
|
||||||
|
player.weapon_holder.add_child(instance_gun)
|
||||||
|
|
||||||
func enemy_count():
|
func enemy_count():
|
||||||
var sum = 0
|
var sum = 0
|
||||||
|
|||||||
4
scripts/ammo_resource.gd
Normal file
4
scripts/ammo_resource.gd
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
extends Resource
|
||||||
|
class_name ammo_stats
|
||||||
|
|
||||||
|
@export_enum("Light", "Medium", "Heavy", "Shotgun", "Rocket") var ammo_type: int
|
||||||
@@ -19,9 +19,10 @@ var crosshair_target
|
|||||||
@onready var stamina_bar: TextureProgressBar = $StaminaBar
|
@onready var stamina_bar: TextureProgressBar = $StaminaBar
|
||||||
@onready var stamina_bar_2: ProgressBar = $StaminaBar2
|
@onready var stamina_bar_2: ProgressBar = $StaminaBar2
|
||||||
@onready var health_bar: ProgressBar = $HealthBar
|
@onready var health_bar: ProgressBar = $HealthBar
|
||||||
@onready var gun_name: Label = $"MarginContainer/VBoxContainer/Gun Name"
|
@onready var gun_name: Label = $"GunInfo/VBoxContainer/Gun Name"
|
||||||
@onready var ammo_current: Label = $MarginContainer/VBoxContainer/HBoxContainer/AmmoCurrent
|
@onready var ammo_current: Label = $GunInfo/VBoxContainer/HBoxContainer/AmmoCurrent
|
||||||
@onready var ammo_reserve: Label = $MarginContainer/VBoxContainer/HBoxContainer/AmmoReserve
|
@onready var ammo_reserve: Label = $GunInfo/VBoxContainer/HBoxContainer/AmmoReserve
|
||||||
|
@onready var gun_info: MarginContainer = $GunInfo
|
||||||
@onready var money: Label = $Money
|
@onready var money: Label = $Money
|
||||||
@onready var crosshair: TextureRect = $Crosshair
|
@onready var crosshair: TextureRect = $Crosshair
|
||||||
@onready var crosshair_center: TextureRect = $CrosshairCenter
|
@onready var crosshair_center: TextureRect = $CrosshairCenter
|
||||||
@@ -69,6 +70,13 @@ func _process(delta: float) -> void:
|
|||||||
crosshair_center.position = Vector2(viewportWidth/2,viewportHeight/2) + (crosshair_center.scale * crosshair_center.size/-2)
|
crosshair_center.position = Vector2(viewportWidth/2,viewportHeight/2) + (crosshair_center.scale * crosshair_center.size/-2)
|
||||||
stamina_bar.scale = (crosshair.size/CROSSHAIR_SIZE) * Vector2(.185,.185)
|
stamina_bar.scale = (crosshair.size/CROSSHAIR_SIZE) * Vector2(.185,.185)
|
||||||
stamina_bar.position = Vector2(viewportWidth/2,viewportHeight/2) + (stamina_bar.scale * stamina_bar.size/-2)
|
stamina_bar.position = Vector2(viewportWidth/2,viewportHeight/2) + (stamina_bar.scale * stamina_bar.size/-2)
|
||||||
|
#hide crosshair and ammo when no gun
|
||||||
|
if player.gun == null:
|
||||||
|
crosshair.visible = false
|
||||||
|
gun_info.visible = false
|
||||||
|
else:
|
||||||
|
crosshair.visible = true
|
||||||
|
gun_info.visible = true
|
||||||
|
|
||||||
#HEALTH
|
#HEALTH
|
||||||
health_bar.value = level_control.health
|
health_bar.value = level_control.health
|
||||||
@@ -135,11 +143,12 @@ func _process(delta: float) -> void:
|
|||||||
change_color(crosshair,FULL_WHITE,10,delta)
|
change_color(crosshair,FULL_WHITE,10,delta)
|
||||||
|
|
||||||
if player.ads:
|
if player.ads:
|
||||||
if player.gun.ads:
|
if player.gun:
|
||||||
fade_in_out(crosshair,1,false,5,delta)
|
if player.gun.ads:
|
||||||
fade_in_out(current_stam_bar,.001,true,5,delta)
|
fade_in_out(crosshair,1,false,5,delta)
|
||||||
else:
|
fade_in_out(current_stam_bar,.001,true,5,delta)
|
||||||
fade_in_out(crosshair,1,true,5,delta)
|
else:
|
||||||
|
fade_in_out(crosshair,1,true,5,delta)
|
||||||
else:
|
else:
|
||||||
fade_in_out(crosshair,1,true,5,delta)
|
fade_in_out(crosshair,1,true,5,delta)
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,12 @@ var start_sensitivity
|
|||||||
@export var BASE_FOV : float = 80
|
@export var BASE_FOV : float = 80
|
||||||
@export var FOV_CHANGE = 1.5
|
@export var FOV_CHANGE = 1.5
|
||||||
|
|
||||||
|
## GUNS AND AMMO
|
||||||
var gun : Node
|
var gun : Node
|
||||||
|
var holstered_gun_id : int
|
||||||
|
var gun_is_holstered = false
|
||||||
|
|
||||||
|
|
||||||
@onready var dead_player : Resource = load("res://assets/dead_cam.tscn")
|
@onready var dead_player : Resource = load("res://assets/dead_cam.tscn")
|
||||||
@onready var pause_menu: Control = $Head/Recoil/Camera3D/PauseMenu
|
@onready var pause_menu: Control = $Head/Recoil/Camera3D/PauseMenu
|
||||||
@onready var gun_ray = $Head/Recoil/Camera3D/GunRay
|
@onready var gun_ray = $Head/Recoil/Camera3D/GunRay
|
||||||
@@ -371,22 +376,30 @@ func _physics_process(delta):
|
|||||||
gun_folded = false
|
gun_folded = false
|
||||||
|
|
||||||
#Weapon Swap Up
|
#Weapon Swap Up
|
||||||
if Input.is_action_just_pressed("scroll_up") and !gun.anim_player.is_playing():
|
if Input.is_action_just_pressed("scroll_up"):
|
||||||
if held_item == null:
|
if gun != null:
|
||||||
if level_control.held_guns.size() > 1:
|
if !gun.anim_player.is_playing():
|
||||||
gun.anim_player.play("swap_out")
|
if held_item == null:
|
||||||
level_control.gun_spawn(level_control.current_gun_index + 1)
|
if level_control.held_guns.size() > 1:
|
||||||
|
weapon_select(level_control.current_gun_index + 1)
|
||||||
|
else:
|
||||||
|
moveable_holder.rotation.y += deg_to_rad(45)
|
||||||
else:
|
else:
|
||||||
moveable_holder.rotation.y += deg_to_rad(45)
|
if gun_is_holstered:
|
||||||
|
holster_gun(false)
|
||||||
|
|
||||||
#Weapon Swap Down
|
#Weapon Swap Down
|
||||||
if Input.is_action_just_pressed("scroll_down") and !gun.anim_player.is_playing():
|
if Input.is_action_just_pressed("scroll_down"):
|
||||||
if held_item == null:
|
if gun != null:
|
||||||
if level_control.held_guns.size() > 1:
|
if !gun.anim_player.is_playing():
|
||||||
gun.anim_player.play("swap_out")
|
if held_item == null:
|
||||||
level_control.gun_spawn(level_control.current_gun_index - 1)
|
if level_control.held_guns.size() > 1:
|
||||||
|
weapon_select(level_control.current_gun_index - 1)
|
||||||
|
else:
|
||||||
|
moveable_holder.rotation.y -= deg_to_rad(45)
|
||||||
else:
|
else:
|
||||||
moveable_holder.rotation.y -= deg_to_rad(45)
|
if gun_is_holstered:
|
||||||
|
holster_gun(false)
|
||||||
|
|
||||||
for i in range(1,9):
|
for i in range(1,9):
|
||||||
if Input.is_action_just_pressed("numb_" + str(i)):
|
if Input.is_action_just_pressed("numb_" + str(i)):
|
||||||
@@ -394,6 +407,12 @@ func _physics_process(delta):
|
|||||||
if !gun.anim_player.is_playing():
|
if !gun.anim_player.is_playing():
|
||||||
if i-1 != level_control.current_gun_index and i <= level_control.held_guns.size():
|
if i-1 != level_control.current_gun_index and i <= level_control.held_guns.size():
|
||||||
weapon_select((i - 1))
|
weapon_select((i - 1))
|
||||||
|
|
||||||
|
if Input.is_action_just_pressed("holster"):
|
||||||
|
if gun_is_holstered:
|
||||||
|
holster_gun(false)
|
||||||
|
else:
|
||||||
|
holster_gun(true)
|
||||||
|
|
||||||
if Input.is_action_just_pressed("weapon_select"):
|
if Input.is_action_just_pressed("weapon_select"):
|
||||||
weapon_select_menu.open()
|
weapon_select_menu.open()
|
||||||
@@ -476,6 +495,17 @@ func joypad_look(delta):
|
|||||||
head.rotate_x(-yAxis * JOYSTICK_SENSITIVITY * 1)
|
head.rotate_x(-yAxis * JOYSTICK_SENSITIVITY * 1)
|
||||||
head.rotation.x = clamp(head.rotation.x, deg_to_rad(-90), deg_to_rad(85))
|
head.rotation.x = clamp(head.rotation.x, deg_to_rad(-90), deg_to_rad(85))
|
||||||
|
|
||||||
|
func holster_gun(holster):
|
||||||
|
if holster:
|
||||||
|
gun_is_holstered = true
|
||||||
|
if gun != null:
|
||||||
|
holstered_gun_id = level_control.current_gun_index
|
||||||
|
gun.anim_player.play("swap_out")
|
||||||
|
else:
|
||||||
|
gun_is_holstered = false
|
||||||
|
if holstered_gun_id != null:
|
||||||
|
weapon_select(holstered_gun_id)
|
||||||
|
|
||||||
func flashlight_toggle():
|
func flashlight_toggle():
|
||||||
if flashlight_on:
|
if flashlight_on:
|
||||||
flashlight.light_energy = FLASHLIGHT_BRIGHTNESS
|
flashlight.light_energy = FLASHLIGHT_BRIGHTNESS
|
||||||
@@ -554,8 +584,9 @@ func weapon_sway(delta):
|
|||||||
weapon_holder.rotation.x = lerp(weapon_holder.rotation.x, (mouse_input.y + joy_input.y) * weapon_sway_amount, 5 * delta)
|
weapon_holder.rotation.x = lerp(weapon_holder.rotation.x, (mouse_input.y + joy_input.y) * weapon_sway_amount, 5 * delta)
|
||||||
weapon_holder.rotation.y = lerp(weapon_holder.rotation.y, (mouse_input.x + joy_input.x) * weapon_sway_amount, 5 * delta)
|
weapon_holder.rotation.y = lerp(weapon_holder.rotation.y, (mouse_input.x + joy_input.x) * weapon_sway_amount, 5 * delta)
|
||||||
else:
|
else:
|
||||||
if gun.ads == true:
|
if gun:
|
||||||
weapon_holder.rotation = Vector3.ZERO
|
if gun.ads == true:
|
||||||
|
weapon_holder.rotation = Vector3.ZERO
|
||||||
|
|
||||||
func weapon_bob(vel : float, delta):
|
func weapon_bob(vel : float, delta):
|
||||||
if weapon_holder:
|
if weapon_holder:
|
||||||
@@ -570,8 +601,10 @@ func weapon_bob(vel : float, delta):
|
|||||||
weapon_holder.position.x = lerp(weapon_holder.position.x, def_weapon_holder_pos.x, .1 * delta)
|
weapon_holder.position.x = lerp(weapon_holder.position.x, def_weapon_holder_pos.x, .1 * delta)
|
||||||
|
|
||||||
func weapon_select(gun_id):
|
func weapon_select(gun_id):
|
||||||
gun.anim_player.play("swap_out")
|
if gun != null:
|
||||||
level_control.gun_spawn(gun_id)
|
gun.anim_player.play("swap_out")
|
||||||
|
if gun_id != null:
|
||||||
|
level_control.gun_spawn(gun_id)
|
||||||
|
|
||||||
func enemy_hit():
|
func enemy_hit():
|
||||||
var hitmarker_spawn = hitmarker.instantiate()
|
var hitmarker_spawn = hitmarker.instantiate()
|
||||||
@@ -594,6 +627,7 @@ func toggle_hud(hud_on):
|
|||||||
hud.visible = hud_on
|
hud.visible = hud_on
|
||||||
|
|
||||||
func grab_moveable(body):
|
func grab_moveable(body):
|
||||||
|
holster_gun(true)
|
||||||
held_item = body
|
held_item = body
|
||||||
#cache rigidbody settings
|
#cache rigidbody settings
|
||||||
held_item_linear_damp_cache = body.linear_damp
|
held_item_linear_damp_cache = body.linear_damp
|
||||||
@@ -626,6 +660,7 @@ func hold_item(_delta):
|
|||||||
release_moveable()
|
release_moveable()
|
||||||
|
|
||||||
func release_moveable():
|
func release_moveable():
|
||||||
|
holster_gun(false)
|
||||||
if held_item != null:
|
if held_item != null:
|
||||||
held_item.gravity_scale = held_item_gravity_cache
|
held_item.gravity_scale = held_item_gravity_cache
|
||||||
held_item.linear_damp = held_item_linear_damp_cache
|
held_item.linear_damp = held_item_linear_damp_cache
|
||||||
|
|||||||
Reference in New Issue
Block a user