rocket launcher shoots and explodes
This commit is contained in:
BIN
assets/Models/rocket.rough.png
Normal file
BIN
assets/Models/rocket.rough.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 91 KiB |
35
assets/Models/rocket.rough.png.import
Normal file
35
assets/Models/rocket.rough.png.import
Normal file
@@ -0,0 +1,35 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://cfanvwkgixns0"
|
||||
path.s3tc="res://.godot/imported/rocket.rough.png-5a26d73be3529d8e10afdbbdf2b356d8.s3tc.ctex"
|
||||
metadata={
|
||||
"imported_formats": ["s3tc_bptc"],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/Models/rocket.rough.png"
|
||||
dest_files=["res://.godot/imported/rocket.rough.png-5a26d73be3529d8e10afdbbdf2b356d8.s3tc.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=2
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=true
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=0
|
||||
BIN
assets/Models/rocket1.png
Normal file
BIN
assets/Models/rocket1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 125 KiB |
35
assets/Models/rocket1.png.import
Normal file
35
assets/Models/rocket1.png.import
Normal file
@@ -0,0 +1,35 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://v6217lr32l0m"
|
||||
path.s3tc="res://.godot/imported/rocket1.png-7e346101e32b659ff970ea4bdf6196e0.s3tc.ctex"
|
||||
metadata={
|
||||
"imported_formats": ["s3tc_bptc"],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/Models/rocket1.png"
|
||||
dest_files=["res://.godot/imported/rocket1.png-7e346101e32b659ff970ea4bdf6196e0.s3tc.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=2
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=true
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=0
|
||||
Binary file not shown.
50
assets/Models/rocketlauncher.blend.import
Normal file
50
assets/Models/rocketlauncher.blend.import
Normal file
@@ -0,0 +1,50 @@
|
||||
[remap]
|
||||
|
||||
importer="scene"
|
||||
importer_version=1
|
||||
type="PackedScene"
|
||||
uid="uid://d3dmtkan3612"
|
||||
path="res://.godot/imported/rocketlauncher.blend-ed28fdfc65f06d3dfc52ef5bd8c9fe98.scn"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/Models/rocketlauncher.blend"
|
||||
dest_files=["res://.godot/imported/rocketlauncher.blend-ed28fdfc65f06d3dfc52ef5bd8c9fe98.scn"]
|
||||
|
||||
[params]
|
||||
|
||||
nodes/root_type=""
|
||||
nodes/root_name=""
|
||||
nodes/apply_root_scale=true
|
||||
nodes/root_scale=1.0
|
||||
meshes/ensure_tangents=true
|
||||
meshes/generate_lods=true
|
||||
meshes/create_shadow_meshes=true
|
||||
meshes/light_baking=1
|
||||
meshes/lightmap_texel_size=0.2
|
||||
meshes/force_disable_compression=false
|
||||
skins/use_named_skins=true
|
||||
animation/import=true
|
||||
animation/fps=30
|
||||
animation/trimming=false
|
||||
animation/remove_immutable_tracks=true
|
||||
import_script/path=""
|
||||
_subresources={}
|
||||
gltf/naming_version=1
|
||||
gltf/embedded_image_handling=1
|
||||
blender/nodes/visible=0
|
||||
blender/nodes/punctual_lights=true
|
||||
blender/nodes/cameras=true
|
||||
blender/nodes/custom_properties=true
|
||||
blender/nodes/modifiers=1
|
||||
blender/meshes/colors=false
|
||||
blender/meshes/uvs=true
|
||||
blender/meshes/normals=true
|
||||
blender/meshes/tangents=true
|
||||
blender/meshes/skins=2
|
||||
blender/meshes/export_bones_deforming_mesh_only=false
|
||||
blender/materials/unpack_enabled=true
|
||||
blender/materials/export_materials=1
|
||||
blender/animation/limit_playback=true
|
||||
blender/animation/always_sample=true
|
||||
blender/animation/group_tracks=true
|
||||
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 79 KiB After Width: | Height: | Size: 49 KiB |
35
assets/Models/rocketlauncher1.normal.png.import
Normal file
35
assets/Models/rocketlauncher1.normal.png.import
Normal file
@@ -0,0 +1,35 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://c2hi7c5hl2yk2"
|
||||
path.s3tc="res://.godot/imported/rocketlauncher1.normal.png-368dfa5a4eb879dd27fe865ae018e8f1.s3tc.ctex"
|
||||
metadata={
|
||||
"imported_formats": ["s3tc_bptc"],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/Models/rocketlauncher1.normal.png"
|
||||
dest_files=["res://.godot/imported/rocketlauncher1.normal.png-368dfa5a4eb879dd27fe865ae018e8f1.s3tc.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=2
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=1
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=true
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=1
|
||||
roughness/src_normal="res://assets/Models/rocketlauncher1.normal.png"
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=0
|
||||
35
assets/Models/rocketlauncher1.rough.png.import
Normal file
35
assets/Models/rocketlauncher1.rough.png.import
Normal file
@@ -0,0 +1,35 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://b82yqx4tml6hn"
|
||||
path.s3tc="res://.godot/imported/rocketlauncher1.rough.png-1bb9b6da20d78ee3344c66924c3ba617.s3tc.ctex"
|
||||
metadata={
|
||||
"imported_formats": ["s3tc_bptc"],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/Models/rocketlauncher1.rough.png"
|
||||
dest_files=["res://.godot/imported/rocketlauncher1.rough.png-1bb9b6da20d78ee3344c66924c3ba617.s3tc.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=2
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=true
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=0
|
||||
BIN
assets/Models/rocketlauncher2.blend1
Normal file
BIN
assets/Models/rocketlauncher2.blend1
Normal file
Binary file not shown.
@@ -232,7 +232,7 @@ tracks/7/keys = {
|
||||
|
||||
[sub_resource type="Animation" id="Animation_bsc1a"]
|
||||
resource_name = "shoot"
|
||||
length = 0.1
|
||||
length = 0.08
|
||||
step = 0.01
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
@@ -241,7 +241,7 @@ tracks/0/path = NodePath("mac10:position")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.03, 0.1),
|
||||
"times": PackedFloat32Array(0, 0.03, 0.08),
|
||||
"transitions": PackedFloat32Array(1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector3(0, 0, 0), Vector3(0, 0.187845, 0.217808), Vector3(0, 0, 0)]
|
||||
@@ -253,7 +253,7 @@ tracks/1/path = NodePath("mac10:rotation")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0, 0.03, 0.1),
|
||||
"times": PackedFloat32Array(0, 0.03, 0.08),
|
||||
"transitions": PackedFloat32Array(1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector3(0, -1.5708, 0), Vector3(-1.15092e-08, -1.5708, -0.266442), Vector3(0, -1.5708, 0)]
|
||||
@@ -265,7 +265,7 @@ tracks/2/path = NodePath("mac10/chargerpull:position")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/keys = {
|
||||
"times": PackedFloat32Array(0, 0.04, 0.1),
|
||||
"times": PackedFloat32Array(0, 0.04, 0.08),
|
||||
"transitions": PackedFloat32Array(1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector3(0, 0, 0), Vector3(1, 0, 0), Vector3(0, 0, 0)]
|
||||
@@ -277,7 +277,7 @@ tracks/3/path = NodePath("mac10/Trigger:rotation")
|
||||
tracks/3/interp = 1
|
||||
tracks/3/loop_wrap = true
|
||||
tracks/3/keys = {
|
||||
"times": PackedFloat32Array(0, 0.01, 0.1),
|
||||
"times": PackedFloat32Array(0, 0.01, 0.08),
|
||||
"transitions": PackedFloat32Array(1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector3(0, 0, -0.209061), Vector3(1.82515e-06, 6.88119e-07, 0.336512), Vector3(0, 0, -0.209061)]
|
||||
@@ -289,7 +289,7 @@ tracks/4/path = NodePath("mac10/SpotLight3D:light_energy")
|
||||
tracks/4/interp = 1
|
||||
tracks/4/loop_wrap = true
|
||||
tracks/4/keys = {
|
||||
"times": PackedFloat32Array(0, 0.03, 0.1),
|
||||
"times": PackedFloat32Array(0, 0.03, 0.08),
|
||||
"transitions": PackedFloat32Array(1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [0.0, 10.0, 0.0]
|
||||
@@ -394,7 +394,7 @@ _data = {
|
||||
[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"
|
||||
recoil_amount = 0.7
|
||||
recoil_amount = 1.5
|
||||
max_ammo = 30
|
||||
bullet_damage = 2
|
||||
bullet_drop = 0.01
|
||||
|
||||
75
assets/rocket.tscn
Normal file
75
assets/rocket.tscn
Normal file
File diff suppressed because one or more lines are too long
54
assets/rocket_explosion.tscn
Normal file
54
assets/rocket_explosion.tscn
Normal file
@@ -0,0 +1,54 @@
|
||||
[gd_scene load_steps=8 format=3 uid="uid://6p7d7txcox7i"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/die_particles.gd" id="1_ssw3i"]
|
||||
[ext_resource type="AudioStream" uid="uid://wd061pl0d7rl" path="res://assets/Audio/deep-low-explosion-SBA-300054677.wav" id="5_awm3r"]
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_e1gej"]
|
||||
albedo_color = Color(0.586219, 0.0370184, 0.140967, 1)
|
||||
emission_enabled = true
|
||||
emission = Color(0.941176, 0, 0, 1)
|
||||
emission_energy_multiplier = 8.0
|
||||
|
||||
[sub_resource type="Curve" id="Curve_741s1"]
|
||||
min_value = -1.0
|
||||
_data = [Vector2(0, -1), 0.0, 0.0, 0, 0, Vector2(1, 1), 2.8, 0.0, 0, 0]
|
||||
point_count = 2
|
||||
|
||||
[sub_resource type="CurveTexture" id="CurveTexture_7652j"]
|
||||
curve = SubResource("Curve_741s1")
|
||||
|
||||
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_evi0f"]
|
||||
inherit_velocity_ratio = 1.0
|
||||
direction = Vector3(0, 1, 0)
|
||||
spread = 66.739
|
||||
initial_velocity_min = 10.0
|
||||
initial_velocity_max = 15.0
|
||||
scale_min = 0.1
|
||||
hue_variation_min = 0.1
|
||||
hue_variation_max = 0.2
|
||||
hue_variation_curve = SubResource("CurveTexture_7652j")
|
||||
|
||||
[sub_resource type="BoxMesh" id="BoxMesh_rsjsy"]
|
||||
|
||||
[node name="rocketexplosion" type="Node3D"]
|
||||
script = ExtResource("1_ssw3i")
|
||||
|
||||
[node name="dieParticles" type="GPUParticles3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.17952, 0)
|
||||
material_override = SubResource("StandardMaterial3D_e1gej")
|
||||
cast_shadow = 0
|
||||
emitting = false
|
||||
amount = 250
|
||||
lifetime = 5.0
|
||||
one_shot = true
|
||||
explosiveness = 1.0
|
||||
trail_enabled = true
|
||||
trail_lifetime = 3.2
|
||||
process_material = SubResource("ParticleProcessMaterial_evi0f")
|
||||
draw_pass_1 = SubResource("BoxMesh_rsjsy")
|
||||
|
||||
[node name="Audio" type="Node3D" parent="."]
|
||||
|
||||
[node name="Die" type="AudioStreamPlayer3D" parent="Audio"]
|
||||
stream = ExtResource("5_awm3r")
|
||||
volume_db = 10.0
|
||||
401
assets/rocket_launcher.tscn
Normal file
401
assets/rocket_launcher.tscn
Normal file
File diff suppressed because one or more lines are too long
5
assets/rocketlauncher_IMPORT.tscn
Normal file
5
assets/rocketlauncher_IMPORT.tscn
Normal file
@@ -0,0 +1,5 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://di83of3sq2127"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://d3dmtkan3612" path="res://assets/Models/rocketlauncher.blend" id="1_v0rrk"]
|
||||
|
||||
[node name="rocketlauncher" instance=ExtResource("1_v0rrk")]
|
||||
@@ -11,7 +11,7 @@ config_version=5
|
||||
[application]
|
||||
|
||||
config/name="First Person Test"
|
||||
run/main_scene="res://scenes/test_level_2v2.tscn"
|
||||
run/main_scene="res://scenes/test_level_2v2 NO ENEMIES.tscn"
|
||||
config/features=PackedStringArray("4.2", "Forward Plus")
|
||||
config/icon="res://icon.svg"
|
||||
|
||||
@@ -110,6 +110,7 @@ interact={
|
||||
|
||||
[rendering]
|
||||
|
||||
textures/canvas_textures/default_texture_filter=0
|
||||
lights_and_shadows/directional_shadow/soft_shadow_filter_quality=5
|
||||
lights_and_shadows/positional_shadow/soft_shadow_filter_quality=5
|
||||
anti_aliasing/quality/msaa_2d=3
|
||||
|
||||
1559
scenes/test_level_2v2 NO ENEMIES.tscn
Normal file
1559
scenes/test_level_2v2 NO ENEMIES.tscn
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -54,7 +54,7 @@ func gun_spawn(index):
|
||||
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
|
||||
#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)
|
||||
|
||||
@@ -75,11 +75,9 @@ func reload_finished():
|
||||
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:
|
||||
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(delta):
|
||||
|
||||
@@ -100,7 +98,7 @@ func shoot(delta):
|
||||
else:
|
||||
instance_bullet.transform.basis = barrel_raycast.global_transform.basis
|
||||
instance_bullet.bullet_speed = bullet_speed
|
||||
instance_bullet.player_velocity = player.velocity.length()
|
||||
instance_bullet.player_velocity = player.velocity
|
||||
instance_bullet.bullet_drop = bullet_drop
|
||||
instance_bullet.random_spread_amt = random_spread_amt
|
||||
instance_bullet.bullet_damage = bullet_damage
|
||||
|
||||
25
scripts/rocket.gd
Normal file
25
scripts/rocket.gd
Normal file
@@ -0,0 +1,25 @@
|
||||
extends RigidBody3D
|
||||
|
||||
@export var explosion : Resource
|
||||
|
||||
var bullet_speed
|
||||
var player_velocity
|
||||
var bullet_damage
|
||||
var player_position
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
linear_velocity += transform.basis * Vector3(0, 0, -bullet_speed) + player_velocity
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
pass
|
||||
|
||||
|
||||
func _on_body_shape_entered(body_rid, body, body_shape_index, local_shape_index):
|
||||
var explosionspawn = explosion.instantiate()
|
||||
explosionspawn.position = self.global_position
|
||||
explosionspawn.transform.basis = self.global_transform.basis
|
||||
get_tree().get_root().add_child(explosionspawn)
|
||||
queue_free()
|
||||
134
scripts/rocket_launcher.gd
Normal file
134
scripts/rocket_launcher.gd
Normal file
@@ -0,0 +1,134 @@
|
||||
extends Node3D
|
||||
|
||||
var start_position
|
||||
var start_rotation
|
||||
var random_spread_start
|
||||
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 fov_zoom_amt = .98
|
||||
@export var recoil_amount = .2
|
||||
@export var max_ammo = 15
|
||||
@export var start_mags = 3
|
||||
@export var bullet_damage = 1
|
||||
@export var bullet_force_mod = 5.0
|
||||
@export var bullet_speed : float = 150
|
||||
@export var bullet_drop = .3
|
||||
@export var random_spread_amt = 1.0
|
||||
@export var fire_pitch_scale_amt = .2
|
||||
@export_group("Gun Assets")
|
||||
@export_subgroup("Main Assets")
|
||||
@export var flare_light : Node
|
||||
@export var bullet : Resource
|
||||
@export var casing : Resource
|
||||
@export var mag : Resource
|
||||
@export_subgroup("Raycast Nodes")
|
||||
@export var anim_player : Node
|
||||
@export var barrel_raycast : Node
|
||||
@export var casing_ejector : Node
|
||||
@export var mag_ejector : Node
|
||||
@export_subgroup("Audio Clips")
|
||||
@export var audio_fire : Node
|
||||
@export var audio_empty : Node
|
||||
@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():
|
||||
start_position = self.position
|
||||
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
|
||||
elif fire_mode == 1:
|
||||
cycle_count = 1
|
||||
cycle_count_start = 1
|
||||
elif fire_mode == 2:
|
||||
cycle_count = 3
|
||||
cycle_count_start = 3
|
||||
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(_delta):
|
||||
pass
|
||||
|
||||
|
||||
func reload_finished():
|
||||
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
|
||||
|
||||
else:
|
||||
level_control.ammo_current[gun_index] += level_control.ammo_reserve[gun_index]
|
||||
level_control.ammo_reserve[gun_index] -= level_control.ammo_reserve[gun_index]
|
||||
|
||||
|
||||
func shoot(delta):
|
||||
|
||||
if level_control.ammo_current[gun_index] > 0 and cycle_count > 0:
|
||||
if !anim_player.is_playing():
|
||||
level_control.ammo_current[gun_index] -= 1
|
||||
#RECOIL --- fix later to happen over a period of time
|
||||
#(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 = barrel_raycast.global_position
|
||||
instance_bullet.transform.basis = barrel_raycast.global_transform.basis
|
||||
instance_bullet.bullet_speed = bullet_speed
|
||||
instance_bullet.player_velocity = player.velocity
|
||||
instance_bullet.bullet_damage = bullet_damage
|
||||
instance_bullet.player_position = player.global_position
|
||||
get_tree().get_root().add_child(instance_bullet)
|
||||
|
||||
# Casing transform
|
||||
#var instance_casing = casing.instantiate()
|
||||
#instance_casing.position = casing_ejector.global_position
|
||||
#instance_casing.transform.basis = casing_ejector.global_transform.basis
|
||||
#get_tree().get_root().add_child(instance_casing)
|
||||
player.weapon_recoil(delta)
|
||||
if fire_mode != 0:
|
||||
cycle_count -= 1
|
||||
|
||||
elif !anim_player.is_playing() and cycle_count != 0:
|
||||
anim_player.play("empty")
|
||||
audio_empty.play()
|
||||
|
||||
func reload(delta):
|
||||
if level_control.ammo_current[gun_index] < max_ammo and player.gun.anim_player.get_current_animation() != "reload" 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 level_control.ammo_current[gun_index] == 0:
|
||||
level_control.ammo_current[gun_index] = 0
|
||||
else:
|
||||
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()
|
||||
Reference in New Issue
Block a user