Renamed GrenadeLauncher, added it into the Player. Tried fixing errors.

layered_gunshot
unfa 2021-04-04 23:25:11 +02:00
parent a505392644
commit 0a6846af9e
16 changed files with 42 additions and 362 deletions

View File

@ -3,7 +3,8 @@
[ext_resource path="res://Classes/Player/Player.tscn" type="PackedScene" id=1]
[ext_resource path="res://Assets/Characters/SmartFridge/SmartFridge.gltf" type="PackedScene" id=2]
[ext_resource path="res://Assets/Characters/SmartFridge/SmartFridge.gd" type="Script" id=3]
[ext_resource path="res://Assets/Audio/SFX/Player_Fridge_Ambient.wav" type="AudioStream" id=4]
[ext_resource path="res://Assets/Audio/SFX/Ambient_Pipes.wav" type="AudioStream" id=4]
[sub_resource type="AnimationNodeStateMachinePlayback" id=1]

View File

@ -1,74 +0,0 @@
[gd_scene load_steps=14 format=2]
[ext_resource path="res://Assets/Weapons/Granade Launcher/Granade Launcher.gltf" type="PackedScene" id=1]
[ext_resource path="res://Assets/Weapons/Weapon.gd" type="Script" id=2]
[ext_resource path="res://Assets/Audio/SFX/Weapons-Handgun-Shoot.wav" type="AudioStream" id=3]
[ext_resource path="res://Assets/Effects/CircleSoft.svg" type="Texture" id=4]
[ext_resource path="res://Assets/Audio/SFX/Weapons-Empty.wav" type="AudioStream" id=5]
[ext_resource path="res://Assets/Audio/SFX/Weapons-Handgun-Reload.wav" type="AudioStream" id=6]
[sub_resource type="Gradient" id=1]
offsets = PoolRealArray( 0, 0.0511628, 0.0883721, 0.302326, 1 )
colors = PoolColorArray( 0, 0, 0, 1, 2, 2, 2, 1, 0.901961, 0.866667, 0.576471, 1, 0.909804, 0.592157, 0.168627, 1, 0, 0, 0, 1 )
[sub_resource type="GradientTexture" id=2]
gradient = SubResource( 1 )
[sub_resource type="Curve" id=3]
_data = [ Vector2( 0, 0.986364 ), 0.0, -0.872434, 0, 0, Vector2( 0.092437, 0.752585 ), 0.0, 0.0, 0, 0, Vector2( 1, 0.198039 ), -0.85103, 0.0, 0, 0 ]
[sub_resource type="CurveTexture" id=4]
curve = SubResource( 3 )
[sub_resource type="ParticlesMaterial" id=5]
direction = Vector3( 0, 0, -5 )
spread = 15.0
gravity = Vector3( 0, 0, 0 )
initial_velocity = 8.0
initial_velocity_random = 0.75
damping = 100.0
damping_random = 0.5
scale_random = 1.0
scale_curve = SubResource( 4 )
color_ramp = SubResource( 2 )
[sub_resource type="SpatialMaterial" id=6]
flags_transparent = true
flags_unshaded = true
vertex_color_use_as_albedo = true
params_blend_mode = 1
params_billboard_mode = 3
particles_anim_h_frames = 1
particles_anim_v_frames = 1
particles_anim_loop = false
albedo_texture = ExtResource( 4 )
[sub_resource type="QuadMesh" id=7]
material = SubResource( 6 )
size = Vector2( 0.3, 0.3 )
[node name="Weapon" type="Spatial"]
script = ExtResource( 2 )
[node name="MuzzleFlash" type="Particles" parent="."]
transform = Transform( -4.37113e-08, 0, 0.999999, 0, 0.999999, 0, -1, 0, -4.37114e-08, -0.3053, 0.124057, 0 )
cast_shadow = 0
emitting = false
amount = 16
lifetime = 0.1
one_shot = true
explosiveness = 1.0
visibility_aabb = AABB( -0.176241, -0.185755, -0.556571, 0.352482, 0.37151, 0.655134 )
process_material = SubResource( 5 )
draw_pass_1 = SubResource( 7 )
[node name="Granade Launcher" parent="." instance=ExtResource( 1 )]
[node name="SoundShoot" type="AudioStreamPlayer3D" parent="."]
stream = ExtResource( 3 )
[node name="SoundEmpty" type="AudioStreamPlayer3D" parent="."]
stream = ExtResource( 5 )
[node name="SoundReload" type="AudioStreamPlayer3D" parent="."]
stream = ExtResource( 6 )

View File

@ -2,12 +2,12 @@
importer="scene"
type="PackedScene"
path="res://.import/Granade Launcher.gltf-165b0d86da95606ec889632aa962d922.scn"
path="res://.import/GranadeLauncher.gltf-ca56a6672dae21dfb777c46e15746d8e.scn"
[deps]
source_file="res://Assets/Weapons/Granade Launcher/Granade Launcher.gltf"
dest_files=[ "res://.import/Granade Launcher.gltf-165b0d86da95606ec889632aa962d922.scn" ]
source_file="res://Assets/Weapons/GrenadeLauncher/GranadeLauncher.gltf"
dest_files=[ "res://.import/GranadeLauncher.gltf-ca56a6672dae21dfb777c46e15746d8e.scn" ]
[params]

View File

@ -1,11 +1,11 @@
[gd_scene load_steps=15 format=2]
[gd_scene load_steps=14 format=2]
[ext_resource path="res://Assets/Weapons/Weapon.gd" type="Script" id=1]
[ext_resource path="res://Assets/Weapons/Handgun/Handgun.gltf" type="PackedScene" id=2]
[ext_resource path="res://Assets/Audio/SFX/Weapons-Handgun-Reload.wav" type="AudioStream" id=3]
[ext_resource path="res://Assets/Audio/SFX/Weapons_Handun_Shot.wav" type="AudioStream" id=4]
[ext_resource path="res://Assets/Weapons/GrenadeLauncher/GranadeLauncher.gltf" type="PackedScene" id=1]
[ext_resource path="res://Classes/Weapon/Weapon.gd" type="Script" id=2]
[ext_resource path="res://Assets/Audio/SFX/Weapons_Handun_Shot.wav" type="AudioStream" id=3]
[ext_resource path="res://Assets/Effects/CircleSoft.svg" type="Texture" id=4]
[ext_resource path="res://Assets/Audio/SFX/Weapons-Empty.wav" type="AudioStream" id=5]
[ext_resource path="res://Assets/Effects/CircleSoft.svg" type="Texture" id=6]
[ext_resource path="res://Assets/Audio/SFX/Weapons-Handgun-Reload.wav" type="AudioStream" id=6]
[sub_resource type="Gradient" id=1]
offsets = PoolRealArray( 0, 0.0511628, 0.0883721, 0.302326, 1 )
@ -41,21 +41,17 @@ params_billboard_mode = 3
particles_anim_h_frames = 1
particles_anim_v_frames = 1
particles_anim_loop = false
albedo_texture = ExtResource( 6 )
albedo_texture = ExtResource( 4 )
[sub_resource type="QuadMesh" id=7]
material = SubResource( 6 )
size = Vector2( 0.3, 0.3 )
[sub_resource type="SphereMesh" id=8]
radius = 0.05
height = 0.1
[node name="OtherHandgun" type="Spatial"]
script = ExtResource( 1 )
[node name="Weapon" type="Spatial"]
script = ExtResource( 2 )
[node name="MuzzleFlash" type="Particles" parent="."]
transform = Transform( -4.37113e-08, 0, 0.999999, 0, 0.999999, 0, -1, 0, -4.37114e-08, -0.3053, 0.124057, 0 )
transform = Transform( -4.37113e-08, 0, 0.999999, 0, 0.999999, 0, -1, 0, -4.37114e-08, -0.562363, 0.0926898, 0 )
cast_shadow = 0
emitting = false
amount = 16
@ -66,28 +62,18 @@ visibility_aabb = AABB( -0.176241, -0.185755, -0.556571, 0.352482, 0.37151, 0.65
process_material = SubResource( 5 )
draw_pass_1 = SubResource( 7 )
[node name="MeshInstance" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.270753, 0.207034, 0 )
mesh = SubResource( 8 )
material/0 = null
[node name="Handgun" parent="." instance=ExtResource( 2 )]
[node name="Muzzle" parent="Handgun" index="0"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.331868, 0.125291, 0 )
[node name="Ejector" parent="Handgun" index="1"]
transform = Transform( -1.62921e-07, -1, 0, 1, -1.62921e-07, 0, 0, 0, 1, -0.0373496, 0.126382, -0.00737098 )
[node name="GranadeLauncher" parent="." instance=ExtResource( 1 )]
[node name="Sounds" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.295478, 0.724833, 0.584699 )
[node name="SoundShoot" type="AudioStreamPlayer3D" parent="Sounds"]
transform = Transform( -4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 0, 0 )
stream = ExtResource( 4 )
stream = ExtResource( 3 )
attenuation_model = 3
unit_db = 3.0
unit_size = 25.0
pitch_scale = 0.5
emission_angle_enabled = true
emission_angle_degrees = 60.0
attenuation_filter_cutoff_hz = 15000.0
@ -96,6 +82,4 @@ attenuation_filter_cutoff_hz = 15000.0
stream = ExtResource( 5 )
[node name="SoundReload" type="AudioStreamPlayer3D" parent="Sounds"]
stream = ExtResource( 3 )
[editable path="Handgun"]
stream = ExtResource( 6 )

Binary file not shown.

View File

@ -1,7 +1,7 @@
[gd_scene load_steps=14 format=2]
[ext_resource path="res://Assets/Weapons/Handgun/Handgun.gltf" type="PackedScene" id=1]
[ext_resource path="res://Assets/Weapons/Weapon.gd" type="Script" id=2]
[ext_resource path="res://Classes/Weapon/Weapon.gd" type="Script" id=2]
[ext_resource path="res://Assets/Audio/SFX/Weapons_Handun_Shot.wav" type="AudioStream" id=3]
[ext_resource path="res://Assets/Effects/CircleSoft.svg" type="Texture" id=4]
[ext_resource path="res://Assets/Audio/SFX/Weapons-Empty.wav" type="AudioStream" id=5]

View File

@ -1,153 +0,0 @@
extends Spatial
signal damage_dealt
signal ammo_changed(type, amount)
export(bool) var Hitscan = false
export(int) var Damage = 100
export(float) var Delay = 0.1
export(bool) var Automatic = false
export(int) var Rounds = 10
export(int) var MaxRoundsInClip = 10
export(int) var Clips = 1
export(int) var MaxClips = 4
onready var camera = get_parent().get_parent().get_parent()
onready var player = camera.get_parent()
onready var ejector = find_node("Ejector")
onready var muzzle = find_node("Muzzle")
onready var current_rounds = Rounds
var currently_fireing = false
var cached_fire = false
#onready var sound_shoot = $SoundShoot
var casing = preload("res://Assets/Weapons/Handgun/Casing.tscn")
var tracer = preload("res://Assets/Effects/BulletTracer.tscn")
func _ready():
$Sounds.global_transform.origin = camera.global_transform.origin
func shoot(camera):
if cached_fire == true:
return
if currently_fireing == true:
cached_fire = true
yield($Handgun/AnimationPlayer, "animation_finished")
# TODO: mutexes
currently_fireing = true
cached_fire = false
if current_rounds > 0:
rpc("fire_weapon", current_rounds)
rpc("compute_bullet_flyby")
current_rounds -= 1
emit_signal("ammo_changed", "handgun", current_rounds)
var space_state = get_world().direct_space_state
var crosshair_pos = get_viewport().size / 2
var from = camera.project_ray_origin(crosshair_pos)
var to = from + camera.project_ray_normal(crosshair_pos) * 1000
var result = space_state.intersect_ray(from, to)
if "collider" in result:
var hit = result.collider
if hit.has_method("on_hit"):
hit.rpc("on_hit", 30, result.position)
if hit is Player:
emit_signal("damage_dealt")
print(player.get_network_master())
else:
reload()
return current_rounds
sync func fire_weapon(var rounds_left):
show_muzzle_flash(rounds_left)
show_tracer()
spawn_casing()
yield($Handgun/AnimationPlayer, "animation_finished")
if !cached_fire:
currently_fireing = false
sync func dry_fire():
pass
func show_muzzle_flash(var rounds_left):
$Handgun/AnimationPlayer.stop()
if rounds_left == 1:
$Handgun/AnimationPlayer.play("Empty", -1, 2)
else:
$Handgun/AnimationPlayer.play("Shoot", -1, 2)
$MuzzleFlash.emitting = true
yield(get_tree().create_timer(0.07),"timeout")
$MuzzleFlash.emitting = false
$Sounds/SoundShoot.play()
func show_tracer():
var tracer_instance = tracer.instance()
tracer_instance.hide()
tracer_instance.global_transform = muzzle.global_transform
get_tree().root.call_deferred("add_child", tracer_instance)
tracer_instance.call_deferred("show")
func spawn_casing():
#while [ true ]:
#var casing_instance = load("res://Assets/Weapons/Handgun/Casing.tscn").instance()
var casing_instance = casing.instance()
casing_instance.global_transform = ejector.global_transform
casing_instance.rotate_object_local(Vector3.FORWARD, deg2rad(90))
casing_instance.angular_velocity = - ejector.global_transform.basis[2] * rand_range(23, 37)
casing_instance.linear_velocity = ejector.global_transform.basis[0] * rand_range(3.2, 4.5) - ejector.global_transform.basis[2] * rand_range(2.6, 3.7)
get_tree().root.call_deferred("add_child", casing_instance)
#yield(get_tree().create_timer(1),"timeout")
remote func compute_bullet_flyby():
var local_player = get_tree().root.get_node("Game").local_player
var transform = find_node("Muzzle").global_transform
var from = global_transform.xform(Vector3())
var to = global_transform.xform(Vector3(-1000, 0, 0))
if local_player:
local_player.on_bullet_flyby(from, to)
func reload():
rpc("play_reload_animation")
currently_fireing = true
cached_fire = false
yield($Handgun/AnimationPlayer, "animation_finished")
if not cached_fire:
currently_fireing = false
current_rounds = Rounds
emit_signal("ammo_changed", "handgun", current_rounds)
sync func play_reload_animation():
$Handgun/AnimationPlayer.play("Reload", 0.5, 1)
$Sounds/SoundReload.play()

View File

@ -1,80 +0,0 @@
[gd_scene load_steps=12 format=2]
[ext_resource path="res://Assets/Weapons/Handgun/Handgun.gltf" type="PackedScene" id=1]
[ext_resource path="res://Assets/Weapons/Weapon.gd" type="Script" id=2]
[ext_resource path="res://Assets/Audio/SFX/Weapons_Handun_Shot.wav" type="AudioStream" id=3]
[ext_resource path="res://Assets/Effects/CircleSoft.svg" type="Texture" id=4]
[sub_resource type="Gradient" id=1]
offsets = PoolRealArray( 0, 0.0511628, 0.0883721, 0.302326, 1 )
colors = PoolColorArray( 0, 0, 0, 1, 2, 2, 2, 1, 0.901961, 0.866667, 0.576471, 1, 0.909804, 0.592157, 0.168627, 1, 0, 0, 0, 1 )
[sub_resource type="GradientTexture" id=2]
gradient = SubResource( 1 )
[sub_resource type="Curve" id=3]
_data = [ Vector2( 0, 0.986364 ), 0.0, -0.872434, 0, 0, Vector2( 0.092437, 0.752585 ), 0.0, 0.0, 0, 0, Vector2( 1, 0.198039 ), -0.85103, 0.0, 0, 0 ]
[sub_resource type="CurveTexture" id=4]
curve = SubResource( 3 )
[sub_resource type="ParticlesMaterial" id=5]
direction = Vector3( 0, 0, -5 )
spread = 15.0
gravity = Vector3( 0, 0, 0 )
initial_velocity = 8.0
initial_velocity_random = 0.75
damping = 100.0
damping_random = 0.5
scale_random = 1.0
scale_curve = SubResource( 4 )
color_ramp = SubResource( 2 )
[sub_resource type="SpatialMaterial" id=6]
flags_transparent = true
flags_unshaded = true
vertex_color_use_as_albedo = true
params_blend_mode = 1
params_billboard_mode = 3
particles_anim_h_frames = 1
particles_anim_v_frames = 1
particles_anim_loop = false
albedo_texture = ExtResource( 4 )
[sub_resource type="QuadMesh" id=7]
material = SubResource( 6 )
size = Vector2( 0.3, 0.3 )
[node name="Weapon" type="Spatial"]
script = ExtResource( 2 )
[node name="MuzzleFlash" type="Particles" parent="."]
transform = Transform( -4.37113e-08, 0, 0.999999, 0, 0.999999, 0, -1, 0, -4.37114e-08, -0.3053, 0.124057, 0 )
cast_shadow = 0
emitting = false
amount = 16
lifetime = 0.1
one_shot = true
explosiveness = 1.0
visibility_aabb = AABB( -0.176241, -0.185755, -0.556571, 0.352482, 0.37151, 0.655134 )
process_material = SubResource( 5 )
draw_pass_1 = SubResource( 7 )
[node name="Handgun" parent="." instance=ExtResource( 1 )]
[node name="Muzzle" parent="Handgun" index="0"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.331868, 0.125291, 0 )
[node name="Ejector" parent="Handgun" index="1"]
transform = Transform( -1.62921e-07, -1, 0, 1, -1.62921e-07, 0, 0, 0, 1, -0.0373496, 0.126382, -0.00737098 )
[node name="SoundShoot" type="AudioStreamPlayer3D" parent="."]
transform = Transform( -4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0.63089, 0.616708, 0.43745 )
stream = ExtResource( 3 )
unit_db = 4.0
unit_size = 25.0
emission_angle_enabled = true
emission_angle_degrees = 60.0
attenuation_filter_cutoff_hz = 15000.0
[editable path="Handgun"]

View File

@ -9,7 +9,7 @@
[ext_resource path="res://Assets/UI/HUD.tscn" type="PackedScene" id=7]
[ext_resource path="res://Classes/Player/Player.gd" type="Script" id=8]
[ext_resource path="res://Classes/Player/WeaponsManager.gd" type="Script" id=9]
[ext_resource path="res://Assets/Weapons/Handgun/OtherHandgun.tscn" type="PackedScene" id=10]
[ext_resource path="res://Assets/Weapons/GrenadeLauncher/GranadeLauncher.tscn" type="PackedScene" id=10]
[ext_resource path="res://Assets/Effects/CircleSoft.svg" type="Texture" id=11]
[ext_resource path="res://Assets/Maps/DM1/OmniFlicker.gd" type="Script" id=12]
@ -133,18 +133,18 @@ size = Vector2( 2, 0.6 )
radius = 0.33
height = 1.1
[sub_resource type="Gradient" id=33]
[sub_resource type="Gradient" id=20]
offsets = PoolRealArray( 0, 0.427256, 0.992634 )
colors = PoolColorArray( 0.34902, 0.662745, 1, 1, 0.972656, 0.962386, 0.315353, 1, 1, 0.15741, 0.0195312, 0 )
[sub_resource type="GradientTexture" id=34]
gradient = SubResource( 33 )
[sub_resource type="GradientTexture" id=21]
gradient = SubResource( 20 )
[sub_resource type="Curve" id=28]
[sub_resource type="Curve" id=22]
_data = [ Vector2( 0.0229682, 0 ), 0.0, 9.50791, 0, 0, Vector2( 0.0706714, 0.304545 ), 1.50076, 1.50076, 0, 0, Vector2( 1, 1 ), 0.857576, 0.0, 0, 0 ]
[sub_resource type="CurveTexture" id=23]
curve = SubResource( 28 )
curve = SubResource( 22 )
[sub_resource type="ParticlesMaterial" id=24]
lifetime_randomness = 0.25
@ -158,7 +158,7 @@ damping_random = 0.2
scale = 2.0
scale_random = 0.2
scale_curve = SubResource( 23 )
color_ramp = SubResource( 34 )
color_ramp = SubResource( 21 )
[sub_resource type="SpatialMaterial" id=25]
flags_transparent = true
@ -175,14 +175,14 @@ albedo_texture = ExtResource( 11 )
material = SubResource( 25 )
size = Vector2( 0.3, 0.3 )
[sub_resource type="Gradient" id=20]
[sub_resource type="Gradient" id=27]
offsets = PoolRealArray( 0, 0.379374, 0.992634 )
colors = PoolColorArray( 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0 )
[sub_resource type="GradientTexture" id=29]
gradient = SubResource( 20 )
[sub_resource type="GradientTexture" id=28]
gradient = SubResource( 27 )
[sub_resource type="ParticlesMaterial" id=30]
[sub_resource type="ParticlesMaterial" id=29]
lifetime_randomness = 0.1
direction = Vector3( 0, -15, 0 )
spread = 0.01
@ -194,9 +194,9 @@ damping_random = 0.2
scale = 3.0
scale_random = 0.4
scale_curve = SubResource( 23 )
color_ramp = SubResource( 29 )
color_ramp = SubResource( 28 )
[sub_resource type="SpatialMaterial" id=31]
[sub_resource type="SpatialMaterial" id=30]
flags_transparent = true
vertex_color_use_as_albedo = true
params_specular_mode = 4
@ -209,8 +209,8 @@ albedo_texture = ExtResource( 11 )
transmission_enabled = true
transmission = Color( 1, 1, 1, 1 )
[sub_resource type="QuadMesh" id=32]
material = SubResource( 31 )
[sub_resource type="QuadMesh" id=31]
material = SubResource( 30 )
size = Vector2( 0.5, 0.5 )
[node name="Player" type="KinematicBody"]
@ -220,7 +220,7 @@ script = ExtResource( 8 )
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.53592, -0.0651628 )
[node name="Hand" type="Spatial" parent="Camera"]
transform = Transform( -4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 0.335, -0.39301, -0.559 )
transform = Transform( -4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 0.335, -0.394059, -0.559 )
[node name="WeaponBobAnimationTree" type="AnimationTree" parent="Camera/Hand"]
tree_root = SubResource( 12 )
@ -237,9 +237,9 @@ anims/Walk = SubResource( 17 )
[node name="Weapons" type="Spatial" parent="Camera/Hand"]
script = ExtResource( 9 )
[node name="Weapon" parent="Camera/Hand/Weapons" instance=ExtResource( 6 )]
[node name="Handgun" parent="Camera/Hand/Weapons" instance=ExtResource( 6 )]
[node name="OtherHandgun" parent="Camera/Hand/Weapons" instance=ExtResource( 10 )]
[node name="GrenadeLauncher" parent="Camera/Hand/Weapons" instance=ExtResource( 10 )]
[node name="Billboard" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.49795, 0 )
@ -300,6 +300,7 @@ __meta__ = {
[node name="JetpackFlame" type="Particles" parent="Effects"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.317267, 0 )
emitting = false
amount = 32
lifetime = 0.3
visibility_aabb = AABB( -0.88845, -4.39128, -1.0129, 1.77577, 4.6895, 2.02716 )
@ -309,12 +310,13 @@ draw_pass_1 = SubResource( 26 )
[node name="JetpackSmoke" type="Particles" parent="Effects"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.317267, 0 )
emitting = false
amount = 128
lifetime = 2.0
visibility_aabb = AABB( -5, -5, -5, 10, 10, 10 )
local_coords = false
process_material = SubResource( 30 )
draw_pass_1 = SubResource( 32 )
process_material = SubResource( 29 )
draw_pass_1 = SubResource( 31 )
[node name="JetpackLight" type="OmniLight" parent="Effects"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.317267, 0 )