Merge branch 'weapon_manager'
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=20 format=3 uid="uid://brl0bsqjl5dg3"]
|
||||
[gd_scene load_steps=22 format=3 uid="uid://brl0bsqjl5dg3"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://c33b6ldlxxfro" path="res://assets/Models/mac10.blend" id="1_nb4p5"]
|
||||
[ext_resource type="Script" path="res://scripts/gun.gd" id="2_6i1l4"]
|
||||
@@ -310,17 +310,90 @@ tracks/5/keys = {
|
||||
[sub_resource type="Animation" id="Animation_tikvk"]
|
||||
resource_name = "sprint"
|
||||
|
||||
[sub_resource type="Animation" id="Animation_i5303"]
|
||||
resource_name = "swap_out"
|
||||
step = 0.01
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("mac10:position")
|
||||
tracks/0/interp = 2
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.25, 1),
|
||||
"transitions": PackedFloat32Array(1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector3(0, 0, 0), Vector3(-0.270935, -0.0610588, 0), Vector3(1.24557, 1.01031, 2.22439)]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("mac10:rotation")
|
||||
tracks/1/interp = 2
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0, 0.25, 1),
|
||||
"transitions": PackedFloat32Array(1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector3(0, -1.5708, 0), Vector3(-0.0758979, -1.23084, 0.21119), Vector3(-0.0713455, -1.36426, -2.36786)]
|
||||
}
|
||||
tracks/2/type = "method"
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/path = NodePath(".")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/keys = {
|
||||
"times": PackedFloat32Array(1),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"values": [{
|
||||
"args": [],
|
||||
"method": &"swapped_out"
|
||||
}]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_0sp0s"]
|
||||
resource_name = "swap_in"
|
||||
step = 0.01
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("mac10:position")
|
||||
tracks/0/interp = 2
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.6, 1),
|
||||
"transitions": PackedFloat32Array(1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector3(1.24557, 1.01031, 2.22439), Vector3(-0.270935, -0.0610588, 0), Vector3(0, 0, 0)]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("mac10:rotation")
|
||||
tracks/1/interp = 2
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0, 0.6, 1),
|
||||
"transitions": PackedFloat32Array(1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector3(-0.0713455, -1.36426, -2.36786), Vector3(-0.0758979, -1.23084, 0.21119), Vector3(0, -1.5708, 0)]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_vkrtt"]
|
||||
_data = {
|
||||
"empty": SubResource("Animation_u008m"),
|
||||
"inspect": SubResource("Animation_cifop"),
|
||||
"reload": SubResource("Animation_svhrs"),
|
||||
"shoot": SubResource("Animation_bsc1a"),
|
||||
"sprint": SubResource("Animation_tikvk")
|
||||
"sprint": SubResource("Animation_tikvk"),
|
||||
"swap_in": SubResource("Animation_0sp0s"),
|
||||
"swap_out": SubResource("Animation_i5303")
|
||||
}
|
||||
|
||||
[node name="mac10" node_paths=PackedStringArray("flare_light", "anim_player", "barrel_raycast", "casing_ejector", "mag_ejector", "audio_fire", "audio_empty", "audio_reload") instance=ExtResource("1_nb4p5")]
|
||||
script = ExtResource("2_6i1l4")
|
||||
gun_name = "Mac 10"
|
||||
max_ammo = 30
|
||||
random_spread_amt = 1.5
|
||||
fire_pitch_scale_amt = 0.1
|
||||
@@ -338,7 +411,7 @@ audio_empty = NodePath("Audio/Empty")
|
||||
audio_reload = NodePath("Audio/Reload")
|
||||
|
||||
[node name="mac10" parent="." index="0"]
|
||||
transform = Transform3D(-1.92883e-06, 0, -0.532829, 0, 0.532828, 0, 0.532828, 0, -1.92884e-06, 0, 0, 0)
|
||||
transform = Transform3D(0.00110078, 0.000233951, -0.532828, 0.00152579, 0.532826, 0.000237103, 0.532825, -0.00152628, 0.00110011, -0.00253865, -0.0010342, -0.00140877)
|
||||
|
||||
[node name="SpotLight3D" type="SpotLight3D" parent="mac10" index="0"]
|
||||
transform = Transform3D(-6.79394e-06, 0, 1.87678, 0, 1.87678, 0, -1.87677, 0, -6.79392e-06, -1.63231, 0, 5.90892e-06)
|
||||
@@ -377,7 +450,7 @@ transform = Transform3D(-0.00171201, 5.61171e-05, 1.87678, 0.567942, 1.78878, 0.
|
||||
target_position = Vector3(1, 0, 0)
|
||||
|
||||
[node name="Trigger" parent="mac10" index="7"]
|
||||
transform = Transform3D(0.962182, -0.272406, 6.11661e-07, 0.272406, 0.962182, -1.62236e-06, -1.4659e-07, 1.72762e-06, 1, -0.13807, -0.230628, 0.00528617)
|
||||
transform = Transform3D(0.978226, 0.207541, 0, -0.207541, 0.978226, 0, 0, 0, 1, -0.13807, -0.230628, 0.00528617)
|
||||
|
||||
[node name="GunAnims" type="AnimationPlayer" parent="." index="1"]
|
||||
libraries = {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=17 format=3 uid="uid://dslxb3psx30vp"]
|
||||
[gd_scene load_steps=19 format=3 uid="uid://dslxb3psx30vp"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://svrb3n31mkag" path="res://assets/Models/gun.blend" id="1_frekg"]
|
||||
[ext_resource type="Script" path="res://scripts/gun.gd" id="2_63tea"]
|
||||
@@ -195,18 +195,89 @@ tracks/2/keys = {
|
||||
[sub_resource type="Animation" id="Animation_tikvk"]
|
||||
resource_name = "sprint"
|
||||
|
||||
[sub_resource type="Animation" id="Animation_lleyf"]
|
||||
resource_name = "swap_out"
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("gun:position")
|
||||
tracks/0/interp = 2
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.4, 1),
|
||||
"transitions": PackedFloat32Array(1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector3(0, -0.000397999, 0), Vector3(-0.274662, -0.000397999, 0.0729132), Vector3(1.44543, 1.00681, 2.10684)]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("gun:rotation")
|
||||
tracks/1/interp = 2
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0, 0.4, 1),
|
||||
"transitions": PackedFloat32Array(1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector3(0, -1.5708, 0), Vector3(-0.289219, -1.03888, -0.16629), Vector3(-0.221353, -1.10575, -2.02639)]
|
||||
}
|
||||
tracks/2/type = "method"
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/path = NodePath(".")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/keys = {
|
||||
"times": PackedFloat32Array(1),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"values": [{
|
||||
"args": [],
|
||||
"method": &"swapped_out"
|
||||
}]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_7422e"]
|
||||
resource_name = "swap_in"
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("gun:position")
|
||||
tracks/0/interp = 2
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.7, 1),
|
||||
"transitions": PackedFloat32Array(1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector3(1.44543, 1.00681, 2.10684), Vector3(-0.274662, -0.000397999, 0.0729132), Vector3(0, -0.000397999, 0)]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("gun:rotation")
|
||||
tracks/1/interp = 2
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0, 0.7, 1),
|
||||
"transitions": PackedFloat32Array(1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector3(-0.221353, -1.10575, -2.02639), Vector3(-0.289219, -1.03888, -0.16629), Vector3(0, -1.5708, 0)]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_vkrtt"]
|
||||
_data = {
|
||||
"empty": SubResource("Animation_u008m"),
|
||||
"inspect": SubResource("Animation_cifop"),
|
||||
"reload": SubResource("Animation_svhrs"),
|
||||
"shoot": SubResource("Animation_bsc1a"),
|
||||
"sprint": SubResource("Animation_tikvk")
|
||||
"sprint": SubResource("Animation_tikvk"),
|
||||
"swap_in": SubResource("Animation_7422e"),
|
||||
"swap_out": SubResource("Animation_lleyf")
|
||||
}
|
||||
|
||||
[node name="Pistol" node_paths=PackedStringArray("flare_light", "anim_player", "barrel_raycast", "casing_ejector", "mag_ejector", "audio_fire", "audio_empty", "audio_reload") instance=ExtResource("1_frekg")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.0145504, -0.0460228)
|
||||
script = ExtResource("2_63tea")
|
||||
gun_name = "Dumb Pistol"
|
||||
fire_mode = 2
|
||||
flare_light = NodePath("SpotLight3D")
|
||||
bullet = ExtResource("3_4pvsf")
|
||||
|
||||
@@ -26,8 +26,8 @@ shadow_color = Color(0, 0, 0, 1)
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_nfpjw"]
|
||||
size = Vector3(3, 3, 3)
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_gnkxs"]
|
||||
size = Vector3(10, 5.48804, 10)
|
||||
[sub_resource type="SphereShape3D" id="SphereShape3D_xfie3"]
|
||||
radius = 6.0
|
||||
|
||||
[node name="Player" type="CharacterBody3D" node_paths=PackedStringArray("weapon_holder") groups=["player"]]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.11359, 0)
|
||||
@@ -84,7 +84,6 @@ padding_amount = 0.025
|
||||
[node name="GunRay" type="RayCast3D" parent="Head/Camera3D" groups=["gun_ray"]]
|
||||
transform = Transform3D(0.977933, 0, -0.208919, 0, 1, 7.45058e-09, 0.208919, 0, 0.977933, 0, -0.197421, -0.129669)
|
||||
target_position = Vector3(0, 0, -1.5)
|
||||
collision_mask = 3
|
||||
|
||||
[node name="AudioListener3D" type="AudioListener3D" parent="Head/Camera3D"]
|
||||
transform = Transform3D(1, 0, 0, 0, 0.992332, 0.123601, 0, -0.123601, 0.992332, 0, -0.921646, -0.000722691)
|
||||
@@ -121,8 +120,8 @@ collision_layer = 0
|
||||
collision_mask = 4
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="pick_up_magnet"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.713223, -3.23375)
|
||||
shape = SubResource("BoxShape3D_gnkxs")
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.89866, 0, 0)
|
||||
shape = SubResource("SphereShape3D_xfie3")
|
||||
|
||||
[node name="Audio" type="Node" parent="."]
|
||||
|
||||
|
||||
634
scenes/tesE29C.tmp
Normal file
634
scenes/tesE29C.tmp
Normal file
File diff suppressed because one or more lines are too long
@@ -2,10 +2,10 @@
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/WeaponManager.gd" id="1_orhgl"]
|
||||
[ext_resource type="Texture2D" uid="uid://dqs06ic3vjtwk" path="res://assets/Models/asphalt1.albedo.jpg" id="1_w4rag"]
|
||||
[ext_resource type="PackedScene" uid="uid://brl0bsqjl5dg3" path="res://assets/mac_10.tscn" id="2_6rjit"]
|
||||
[ext_resource type="PackedScene" uid="uid://drwae3loscbw7" path="res://assets/player.tscn" id="2_f87c2"]
|
||||
[ext_resource type="PackedScene" uid="uid://brl0bsqjl5dg3" path="res://assets/mac_10.tscn" id="2_q7f7y"]
|
||||
[ext_resource type="PackedScene" uid="uid://d1j6ktsmxfq6e" path="res://assets/spider.tscn" id="3_cvvjo"]
|
||||
[ext_resource type="PackedScene" uid="uid://dslxb3psx30vp" path="res://assets/pistol1.tscn" id="3_k8htc"]
|
||||
[ext_resource type="PackedScene" uid="uid://dslxb3psx30vp" path="res://assets/pistol1.tscn" id="3_rky7g"]
|
||||
[ext_resource type="PackedScene" uid="uid://20csd6dmwj4y" path="res://assets/jump_platform.tscn" id="4_8nxyr"]
|
||||
[ext_resource type="PackedScene" uid="uid://dws2vwfxubqvb" path="res://assets/cannon.tscn" id="5_28rul"]
|
||||
[ext_resource type="PackedScene" uid="uid://bpkmyd3wvqi5p" path="res://assets/boombox.tscn" id="6_xrg7k"]
|
||||
@@ -408,11 +408,12 @@ size = Vector3(16.265, 5.07275, 15.3267)
|
||||
[node name="Test Level 2" type="Node3D" node_paths=PackedStringArray("player")]
|
||||
script = ExtResource("1_orhgl")
|
||||
player = NodePath("Player")
|
||||
gun_1 = ExtResource("2_q7f7y")
|
||||
gun_2 = ExtResource("3_k8htc")
|
||||
gun_1 = ExtResource("2_6rjit")
|
||||
gun_2 = ExtResource("3_rky7g")
|
||||
|
||||
[node name="Player" parent="." instance=ExtResource("2_f87c2")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -4.0295, 1.4435, 21.1166)
|
||||
AUDIO = false
|
||||
weapon_sway_amount = 0.05
|
||||
weapon_rotation_amount = 0.05
|
||||
|
||||
|
||||
@@ -2,20 +2,20 @@ extends Label
|
||||
|
||||
const ASPECT_RATIO_STD = .5625 #9/16 for standard ratio
|
||||
@export var padding_amount = .05 #multiplied by screen size
|
||||
|
||||
@onready var level_control = $"../../../.."
|
||||
@onready var player = $"../../.."
|
||||
@onready var gun_anim = $"../gun/GunAnims"
|
||||
|
||||
var gun_index
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
var viewportWidth = get_viewport().size.x
|
||||
var viewportHeight = get_viewport().size.y
|
||||
var viewportHeightAdjusted = viewportWidth * ASPECT_RATIO_STD
|
||||
|
||||
gun_index = 0
|
||||
size = Vector2(viewportWidth - (padding_amount * viewportWidth), viewportHeight - (padding_amount * viewportHeightAdjusted))
|
||||
position = Vector2(0 - (padding_amount * viewportWidth) ,0 - (padding_amount * viewportHeightAdjusted))
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
text = "Ammo: " + str(player.ammo) +" " + str(player.ammo_reserve)
|
||||
text = str(player.gun.gun_name) + "\n Ammo: " + str(level_control.ammo_current[level_control.current_gun_index]) +" " + str(level_control.ammo_reserve[level_control.current_gun_index])
|
||||
|
||||
@@ -1,13 +1,51 @@
|
||||
extends Node3D
|
||||
|
||||
|
||||
@export var player : Node
|
||||
@export var gun_1 : Resource
|
||||
@export var gun_2 : Resource
|
||||
var held_guns = [gun_1,gun_2]
|
||||
var held_guns = []
|
||||
var ammo_current = [0,0]
|
||||
var ammo_reserve = [0,0]
|
||||
var guns_dict = {}
|
||||
var current_gun_index
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass
|
||||
held_guns = [gun_1,gun_2]
|
||||
var instance_gun = held_guns[0].instantiate()
|
||||
var instance_gun_2 = held_guns[1].instantiate()
|
||||
|
||||
#set up ammo for starting guns
|
||||
ammo_current[1] = instance_gun_2.max_ammo
|
||||
ammo_reserve[1] = instance_gun_2.max_ammo * instance_gun_2.start_mags
|
||||
ammo_current[0] = instance_gun.max_ammo
|
||||
ammo_reserve[0] = instance_gun.max_ammo * instance_gun.start_mags
|
||||
#spawn first gun
|
||||
current_gun_index = 0
|
||||
gun_spawn(0)
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
pass
|
||||
|
||||
func gun_spawn(index):
|
||||
#loop around if scrolling past available guns
|
||||
if index > held_guns.size() - 1:
|
||||
index = 0
|
||||
elif index < 0:
|
||||
index = held_guns.size() - 1
|
||||
|
||||
current_gun_index = index
|
||||
|
||||
var instance_gun = held_guns[index].instantiate()
|
||||
instance_gun.global_transform.origin = player.weapon_spawner.position
|
||||
player.gun = instance_gun
|
||||
player.def_weapon_holder_pos = player.weapon_holder.position
|
||||
player.ammo = player.gun.max_ammo
|
||||
player.ammo_reserve = player.gun.max_ammo * player.gun.start_mags
|
||||
player.gun_fire_pitch_starting = player.gun.audio_fire.pitch_scale
|
||||
instance_gun.gun_index = index
|
||||
instance_gun.anim_player.play("swap_in")
|
||||
player.weapon_holder.add_child(instance_gun)
|
||||
|
||||
@@ -7,6 +7,7 @@ var cycle_count_start
|
||||
var cycle_count
|
||||
|
||||
@export_group("Gun Feel")
|
||||
@export var gun_name : String
|
||||
@export_enum("Auto", "Single", "Burst") var fire_mode: int
|
||||
@export var recoil_amount = .2
|
||||
@export var max_ammo = 15
|
||||
@@ -35,7 +36,12 @@ var cycle_count
|
||||
@export var audio_reload : Node
|
||||
|
||||
@onready var player = $"../../../../"
|
||||
@onready var level_control = $"../../../../../"
|
||||
@onready var ammo_current
|
||||
var rng = RandomNumberGenerator.new()
|
||||
var gun_index
|
||||
#var ammo_current
|
||||
var ammo_reserve
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
@@ -43,6 +49,10 @@ func _ready():
|
||||
start_rotation = self.rotation
|
||||
random_spread_start = random_spread_amt
|
||||
|
||||
ammo_current = level_control.ammo_current[gun_index]
|
||||
ammo_reserve = level_control.ammo_reserve[gun_index]
|
||||
|
||||
|
||||
if fire_mode == 0:
|
||||
cycle_count = 1
|
||||
cycle_count_start = 1
|
||||
@@ -61,27 +71,27 @@ func _process(delta):
|
||||
|
||||
|
||||
func reload_finished():
|
||||
if player.ammo_reserve >= max_ammo:
|
||||
player.ammo += max_ammo
|
||||
player.ammo_reserve -= max_ammo
|
||||
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
|
||||
player.reloading = false
|
||||
else:
|
||||
player.ammo += player.ammo_reserve
|
||||
player.ammo_reserve -= player.ammo_reserve
|
||||
level_control.ammo_current[gun_index] += level_control.ammo_reserve[gun_index]
|
||||
level_control.ammo_reserve[gun_index] -= level_control.ammo_reserve[gun_index]
|
||||
player.reloading = false
|
||||
|
||||
func shoot(player,delta):
|
||||
|
||||
if player.ammo > 0 and cycle_count > 0:
|
||||
if level_control.ammo_current[gun_index] > 0 and cycle_count > 0:
|
||||
if !anim_player.is_playing():
|
||||
player.ammo -= 1
|
||||
level_control.ammo_current[gun_index] -= 1
|
||||
#RECOIL --- fix later to happen over a period of time
|
||||
player.camera.rotation.x = clamp(lerp(player.camera.rotation.x, player.camera.rotation.x + recoil_amount, delta * 10), deg_to_rad(-90), deg_to_rad(60))
|
||||
#player.camera.rotation.x = clamp(lerp(player.camera.rotation.x, player.camera.rotation.x + recoil_amount, delta * 10), deg_to_rad(-90), deg_to_rad(60))
|
||||
player.weapon_recoil(delta)
|
||||
#(ADD PLAYER KICK HERE. RELATIVE TO GUN POSITION)
|
||||
audio_fire.pitch_scale = 1 + rng.randf_range(-fire_pitch_scale_amt,fire_pitch_scale_amt)
|
||||
audio_fire.play()
|
||||
anim_player.play("shoot")
|
||||
|
||||
# instance bullet
|
||||
var instance_bullet = bullet.instantiate()
|
||||
instance_bullet.position = player.bullet_ray.global_position
|
||||
@@ -103,7 +113,7 @@ func shoot(player,delta):
|
||||
instance_casing.transform.basis = casing_ejector.global_transform.basis
|
||||
get_tree().get_root().add_child(instance_casing)
|
||||
|
||||
if fire_mode == 1 or fire_mode == 2:
|
||||
if fire_mode != 0:
|
||||
cycle_count -= 1
|
||||
|
||||
elif !anim_player.is_playing() and cycle_count != 0:
|
||||
@@ -111,18 +121,21 @@ func shoot(player,delta):
|
||||
audio_empty.play()
|
||||
|
||||
func reload(player,delta):
|
||||
if player.ammo < max_ammo and player.reloading == false and player.ammo_reserve > 0:
|
||||
if level_control.ammo_current[gun_index] < max_ammo and player.reloading == false and level_control.ammo_reserve[gun_index] > 0:
|
||||
player.reloading = true
|
||||
anim_player.play("reload")
|
||||
audio_reload.play()
|
||||
if anim_player.is_playing() and anim_player.current_animation == "reload":
|
||||
if player.ammo == 0:
|
||||
player.ammo = 0
|
||||
if level_control.ammo_current[gun_index] == 0:
|
||||
level_control.ammo_current[gun_index] = 0
|
||||
else:
|
||||
player.ammo = 1
|
||||
level_control.ammo_current[gun_index] = 1
|
||||
|
||||
func spawn_mag():
|
||||
var instance_mag = mag.instantiate()
|
||||
instance_mag.position = mag_ejector.global_position
|
||||
instance_mag.transform.basis = mag_ejector.global_transform.basis
|
||||
get_tree().get_root().add_child(instance_mag)
|
||||
|
||||
func swapped_out():
|
||||
queue_free()
|
||||
|
||||
@@ -47,6 +47,7 @@ var gun_folded = false
|
||||
var recoiling_fade = 0
|
||||
var bullet_destination
|
||||
var gun_fire_pitch_starting
|
||||
var current_weapon_index
|
||||
|
||||
# Slow Down Variables
|
||||
const SLOWSPEED = .2
|
||||
@@ -72,17 +73,6 @@ func _ready():
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||
start_sensitivity = SENSITIVITY
|
||||
|
||||
#Set up gun variables
|
||||
var instance_gun = level_control.gun_1.instantiate()
|
||||
instance_gun.global_transform.origin = weapon_spawner.position
|
||||
gun = instance_gun
|
||||
def_weapon_holder_pos = weapon_holder.position
|
||||
ammo = gun.max_ammo
|
||||
ammo_reserve = gun.max_ammo * gun.start_mags
|
||||
bullet_damage = gun.bullet_damage
|
||||
gun_fire_pitch_starting = gun.audio_fire.pitch_scale
|
||||
weapon_holder.add_child(instance_gun)
|
||||
|
||||
|
||||
#turn off audio if unchecked in player
|
||||
if AUDIO == false:
|
||||
@@ -190,29 +180,13 @@ func _physics_process(delta):
|
||||
gun_folded = false
|
||||
|
||||
#Weapon Swap Up
|
||||
if Input.is_action_just_pressed("scroll_up"):
|
||||
gun.queue_free()
|
||||
var instance_gun = level_control.gun_2.instantiate()
|
||||
instance_gun.global_transform.origin = weapon_spawner.position
|
||||
gun = instance_gun
|
||||
def_weapon_holder_pos = weapon_holder.position
|
||||
ammo = gun.max_ammo
|
||||
ammo_reserve = gun.max_ammo * gun.start_mags
|
||||
bullet_damage = gun.bullet_damage
|
||||
gun_fire_pitch_starting = gun.audio_fire.pitch_scale
|
||||
weapon_holder.add_child(instance_gun)
|
||||
if Input.is_action_just_pressed("scroll_up") and !gun.anim_player.is_playing():
|
||||
gun.anim_player.play("swap_out")
|
||||
level_control.gun_spawn(level_control.current_gun_index + 1)
|
||||
#Weapon Swap Down
|
||||
if Input.is_action_just_pressed("scroll_down"):
|
||||
gun.queue_free()
|
||||
var instance_gun = level_control.gun_1.instantiate()
|
||||
instance_gun.global_transform.origin = weapon_spawner.position
|
||||
gun = instance_gun
|
||||
def_weapon_holder_pos = weapon_holder.position
|
||||
ammo = gun.max_ammo
|
||||
ammo_reserve = gun.max_ammo * gun.start_mags
|
||||
bullet_damage = gun.bullet_damage
|
||||
gun_fire_pitch_starting = gun.audio_fire.pitch_scale
|
||||
weapon_holder.add_child(instance_gun)
|
||||
if Input.is_action_just_pressed("scroll_down") and !gun.anim_player.is_playing():
|
||||
gun.anim_player.play("swap_out")
|
||||
level_control.gun_spawn(level_control.current_gun_index - 1)
|
||||
|
||||
move_and_slide()
|
||||
weapon_tilt(input_dir.x, delta)
|
||||
@@ -239,7 +213,7 @@ func _on_pick_up_detection_body_entered(body):
|
||||
pickupmsg = pickup_announce.instantiate()
|
||||
pickupmsg.pickuptext = "ammo"
|
||||
get_parent().add_child(pickupmsg)
|
||||
ammo_reserve += int((body.rand_amt/100) * gun.max_ammo)
|
||||
level_control.ammo_reserve[level_control.current_gun_index] += int((body.rand_amt/100) * gun.max_ammo)
|
||||
picked_up = true
|
||||
picked_up_text = "ammo"
|
||||
pickup_sound.pitch_scale = 1 + rng.randf_range(-.3,.3)
|
||||
@@ -269,13 +243,8 @@ func weapon_tilt(input_x, delta):
|
||||
|
||||
func weapon_sway(delta):
|
||||
mouse_input = lerp(mouse_input, Vector2.ZERO, 10 * delta)
|
||||
weapon_holder.rotation.x = lerp(weapon_holder.rotation.x, mouse_input.y * weapon_rotation_amount, 1 * delta)
|
||||
weapon_holder.rotation.y = lerp(weapon_holder.rotation.y, mouse_input.x * weapon_rotation_amount, 1 * delta)
|
||||
|
||||
#crosshair.position.x = lerp(crosshair.position.x, mouse_input.x * 100, 2 * delta)
|
||||
|
||||
#crosshair.size.x = lerp(crosshair.size.x, clamp((abs(mouse_input.x * 10) + abs(mouse_input.y) * 1000),0.0,100.0), 1 * delta)
|
||||
#crosshair.size.y = lerp(crosshair.size.y, clamp((abs(mouse_input.x * 10) + abs(mouse_input.y) * 1000),0.0,100.0), 1 * delta)
|
||||
weapon_holder.rotation.x = lerp(weapon_holder.rotation.x, mouse_input.y * weapon_rotation_amount, 5 * delta)
|
||||
weapon_holder.rotation.y = lerp(weapon_holder.rotation.y, mouse_input.x * weapon_rotation_amount, 5 * delta)
|
||||
|
||||
func weapon_bob(vel : float, delta):
|
||||
if weapon_holder:
|
||||
@@ -287,3 +256,7 @@ func weapon_bob(vel : float, delta):
|
||||
else:
|
||||
weapon_holder.position.y = lerp(weapon_holder.position.y, def_weapon_holder_pos.y, .1 * delta)
|
||||
weapon_holder.position.x = lerp(weapon_holder.position.x, def_weapon_holder_pos.x, .1 * delta)
|
||||
|
||||
func weapon_recoil(delta):
|
||||
var recoil_to = camera.rotation.x + gun.recoil_amount
|
||||
camera.rotation.x = clamp(lerp(camera.rotation.x,recoil_to, delta * 10), deg_to_rad(-90), deg_to_rad(60))
|
||||
|
||||
11
scripts/weapon_resource.gd
Normal file
11
scripts/weapon_resource.gd
Normal file
@@ -0,0 +1,11 @@
|
||||
extends Node
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
pass
|
||||
Reference in New Issue
Block a user