blunderbuss working
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 76 KiB |
BIN
assets/Models/blunderbus.metal.rough.png
Normal file
BIN
assets/Models/blunderbus.metal.rough.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
35
assets/Models/blunderbus.metal.rough.png.import
Normal file
35
assets/Models/blunderbus.metal.rough.png.import
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://bf4m8j05ypctm"
|
||||||
|
path.s3tc="res://.godot/imported/blunderbus.metal.rough.png-27758ccaeedeb6eecbee5c6fe642fb10.s3tc.ctex"
|
||||||
|
metadata={
|
||||||
|
"imported_formats": ["s3tc_bptc"],
|
||||||
|
"vram_texture": true
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/Models/blunderbus.metal.rough.png"
|
||||||
|
dest_files=["res://.godot/imported/blunderbus.metal.rough.png-27758ccaeedeb6eecbee5c6fe642fb10.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/blunderbus.stock.rough.png
Normal file
BIN
assets/Models/blunderbus.stock.rough.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 28 KiB |
35
assets/Models/blunderbus.stock.rough.png.import
Normal file
35
assets/Models/blunderbus.stock.rough.png.import
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://ddrqh51fsq8gm"
|
||||||
|
path.s3tc="res://.godot/imported/blunderbus.stock.rough.png-d1267eec668d0b3781f4263190309c68.s3tc.ctex"
|
||||||
|
metadata={
|
||||||
|
"imported_formats": ["s3tc_bptc"],
|
||||||
|
"vram_texture": true
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/Models/blunderbus.stock.rough.png"
|
||||||
|
dest_files=["res://.godot/imported/blunderbus.stock.rough.png-d1267eec668d0b3781f4263190309c68.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.
Binary file not shown.
@@ -3,7 +3,6 @@
|
|||||||
[ext_resource type="Script" path="res://scripts/LevelManager.gd" id="1_sbpvn"]
|
[ext_resource type="Script" path="res://scripts/LevelManager.gd" id="1_sbpvn"]
|
||||||
[ext_resource type="PackedScene" uid="uid://brl0bsqjl5dg3" path="res://assets/mac_10.tscn" id="2_fn4vb"]
|
[ext_resource type="PackedScene" uid="uid://brl0bsqjl5dg3" path="res://assets/mac_10.tscn" id="2_fn4vb"]
|
||||||
[ext_resource type="Texture2D" uid="uid://ckjcv72jcojjh" path="res://assets/materials/91_laurel hedge PBR texture-seamless_hr/91_laurel hedge_DIFF (Custom).jpg" id="3_3ov8a"]
|
[ext_resource type="Texture2D" uid="uid://ckjcv72jcojjh" path="res://assets/materials/91_laurel hedge PBR texture-seamless_hr/91_laurel hedge_DIFF (Custom).jpg" id="3_3ov8a"]
|
||||||
[ext_resource type="PackedScene" uid="uid://dqwkal3t4gf2p" path="res://blunderbus.tscn" id="3_52ywj"]
|
|
||||||
[ext_resource type="LightmapGIData" uid="uid://bwpvltmeo4cfl" path="res://assets/LevelBlockouts/blockout_2.lmbake" id="3_d2pxn"]
|
[ext_resource type="LightmapGIData" uid="uid://bwpvltmeo4cfl" path="res://assets/LevelBlockouts/blockout_2.lmbake" id="3_d2pxn"]
|
||||||
[ext_resource type="Texture2D" uid="uid://d210plbmb7a2o" path="res://assets/materials/91_laurel hedge PBR texture-seamless_hr/91_laurel hedge_NORM (Custom).jpg" id="4_5u2rd"]
|
[ext_resource type="Texture2D" uid="uid://d210plbmb7a2o" path="res://assets/materials/91_laurel hedge PBR texture-seamless_hr/91_laurel hedge_NORM (Custom).jpg" id="4_5u2rd"]
|
||||||
[ext_resource type="PackedScene" uid="uid://20csd6dmwj4y" path="res://assets/jump_platform.tscn" id="4_j47q8"]
|
[ext_resource type="PackedScene" uid="uid://20csd6dmwj4y" path="res://assets/jump_platform.tscn" id="4_j47q8"]
|
||||||
@@ -38,6 +37,7 @@
|
|||||||
[ext_resource type="Script" path="res://scripts/switch_door.gd" id="33_1m5er"]
|
[ext_resource type="Script" path="res://scripts/switch_door.gd" id="33_1m5er"]
|
||||||
[ext_resource type="Script" path="res://scripts/switch_interactandshoot.gd" id="35_ybetb"]
|
[ext_resource type="Script" path="res://scripts/switch_interactandshoot.gd" id="35_ybetb"]
|
||||||
[ext_resource type="Script" path="res://levels/switch_target.gd" id="36_fuepo"]
|
[ext_resource type="Script" path="res://levels/switch_target.gd" id="36_fuepo"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://cucqbjb8bcha5" path="res://assets/blunderbuss_pickup.tscn" id="38_1e38i"]
|
||||||
|
|
||||||
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_eiud5"]
|
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_eiud5"]
|
||||||
sky_horizon_color = Color(0.64625, 0.65575, 0.67075, 1)
|
sky_horizon_color = Color(0.64625, 0.65575, 0.67075, 1)
|
||||||
@@ -1004,7 +1004,6 @@ player = NodePath("Player")
|
|||||||
money = 50
|
money = 50
|
||||||
start_health = 5
|
start_health = 5
|
||||||
gun_1 = ExtResource("2_fn4vb")
|
gun_1 = ExtResource("2_fn4vb")
|
||||||
gun_2 = ExtResource("3_52ywj")
|
|
||||||
health_drop_enabled = false
|
health_drop_enabled = false
|
||||||
|
|
||||||
[node name="Player" parent="." instance=ExtResource("9_3usor")]
|
[node name="Player" parent="." instance=ExtResource("9_3usor")]
|
||||||
@@ -2231,6 +2230,9 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -63.7211, 1.01162, 81.5595)
|
|||||||
[node name="Spikes 36" parent="." instance=ExtResource("12_w4dk0")]
|
[node name="Spikes 36" parent="." instance=ExtResource("12_w4dk0")]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -63.7211, 1.01162, 73.1301)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -63.7211, 1.01162, 73.1301)
|
||||||
|
|
||||||
|
[node name="blunderbuss_pickup" parent="." instance=ExtResource("38_1e38i")]
|
||||||
|
transform = Transform3D(0.680363, 0, 0.732875, 0, 1, 0, -0.732875, 0, 0.680363, -2.95896, 1.92659, 16.5021)
|
||||||
|
|
||||||
[connection signal="body_entered" from="Room1/RoomCheck" to="Room1/RoomCheck" method="_on_body_entered"]
|
[connection signal="body_entered" from="Room1/RoomCheck" to="Room1/RoomCheck" method="_on_body_entered"]
|
||||||
[connection signal="body_exited" from="Room1/RoomCheck" to="Room1/RoomCheck" method="_on_body_exited"]
|
[connection signal="body_exited" from="Room1/RoomCheck" to="Room1/RoomCheck" method="_on_body_exited"]
|
||||||
[connection signal="body_entered" from="Room3/RoomCheck2" to="Room3/RoomCheck2" method="_on_body_entered"]
|
[connection signal="body_entered" from="Room3/RoomCheck2" to="Room3/RoomCheck2" method="_on_body_entered"]
|
||||||
|
|||||||
272
assets/blunderbuss_pickup.tscn
Normal file
272
assets/blunderbuss_pickup.tscn
Normal file
File diff suppressed because one or more lines are too long
@@ -426,7 +426,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.086e-06, 0, -0.3, 0, 0.3, 0, 0.3, 0, -1.086e-06, 0, 0, 0)
|
transform = Transform3D(-0.120695, -0.0946483, -0.257826, 0.172433, -0.245315, 0.00933491, -0.213774, -0.144437, 0.153097, 0.948953, -2.62066, 0.655643)
|
||||||
|
|
||||||
[node name="RHandLocation" type="Node3D" parent="mac10" index="0"]
|
[node name="RHandLocation" type="Node3D" parent="mac10" index="0"]
|
||||||
transform = Transform3D(-1.20667e-05, 0, 3.33333, 0, 3.33333, 0, -3.33333, 0, -1.20667e-05, 0.255734, -0.514002, -9.25759e-07)
|
transform = Transform3D(-1.20667e-05, 0, 3.33333, 0, 3.33333, 0, -3.33333, 0, -1.20667e-05, 0.255734, -0.514002, -9.25759e-07)
|
||||||
|
|||||||
43
assets/shotgun_pellet.tscn
Normal file
43
assets/shotgun_pellet.tscn
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
[gd_scene load_steps=6 format=3 uid="uid://717hhehp83k8"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://scripts/shotgun_pellet.gd" id="1_1v1ju"]
|
||||||
|
|
||||||
|
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_0ewk3"]
|
||||||
|
bounce = 0.3
|
||||||
|
|
||||||
|
[sub_resource type="SphereMesh" id="SphereMesh_5okb1"]
|
||||||
|
radius = 0.05
|
||||||
|
height = 0.1
|
||||||
|
|
||||||
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_we7vv"]
|
||||||
|
metallic = 1.0
|
||||||
|
roughness = 0.3
|
||||||
|
emission_enabled = true
|
||||||
|
emission = Color(1, 0.476275, 0.212537, 1)
|
||||||
|
emission_energy_multiplier = 20.0
|
||||||
|
|
||||||
|
[sub_resource type="SphereShape3D" id="SphereShape3D_55xw1"]
|
||||||
|
radius = 0.05
|
||||||
|
|
||||||
|
[node name="ShotgunPellet" type="RigidBody3D" groups=["pellet", "spawned"]]
|
||||||
|
collision_layer = 160
|
||||||
|
collision_mask = 237
|
||||||
|
mass = 0.01
|
||||||
|
physics_material_override = SubResource("PhysicsMaterial_0ewk3")
|
||||||
|
continuous_cd = true
|
||||||
|
contact_monitor = true
|
||||||
|
max_contacts_reported = 1
|
||||||
|
script = ExtResource("1_1v1ju")
|
||||||
|
|
||||||
|
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
|
||||||
|
mesh = SubResource("SphereMesh_5okb1")
|
||||||
|
surface_material_override/0 = SubResource("StandardMaterial3D_we7vv")
|
||||||
|
|
||||||
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||||
|
shape = SubResource("SphereShape3D_55xw1")
|
||||||
|
|
||||||
|
[node name="Timer" type="Timer" parent="."]
|
||||||
|
wait_time = 10.0
|
||||||
|
|
||||||
|
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
||||||
|
[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]
|
||||||
@@ -879,8 +879,8 @@ mesh = SubResource("ArrayMesh_d210d")
|
|||||||
|
|
||||||
[node name="Area3D" type="Area3D" parent="body" groups=["enemy_target"]]
|
[node name="Area3D" type="Area3D" parent="body" groups=["enemy_target"]]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1.03709, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1.03709, 0)
|
||||||
collision_layer = 8
|
collision_layer = 136
|
||||||
collision_mask = 13
|
collision_mask = 141
|
||||||
script = ExtResource("7_8vkma")
|
script = ExtResource("7_8vkma")
|
||||||
|
|
||||||
[node name="TargetShape" type="CollisionShape3D" parent="body/Area3D" groups=["enemy"]]
|
[node name="TargetShape" type="CollisionShape3D" parent="body/Area3D" groups=["enemy"]]
|
||||||
@@ -922,6 +922,7 @@ volume_db = 10.0
|
|||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0258179, 1.03281, 0.00894165)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0258179, 1.03281, 0.00894165)
|
||||||
shape = SubResource("BoxShape3D_xxx55")
|
shape = SubResource("BoxShape3D_xxx55")
|
||||||
|
|
||||||
|
[connection signal="body_entered" from="body/Area3D" to="body/Area3D" method="_on_body_entered"]
|
||||||
[connection signal="body_part_hit" from="body/Area3D" to="." method="_on_area_3d_body_part_hit"]
|
[connection signal="body_part_hit" from="body/Area3D" to="." method="_on_area_3d_body_part_hit"]
|
||||||
[connection signal="timeout" from="Timers/prefire_timer" to="." method="_on_prefire_timer_timeout"]
|
[connection signal="timeout" from="Timers/prefire_timer" to="." method="_on_prefire_timer_timeout"]
|
||||||
[connection signal="timeout" from="Timers/postfire_timer" to="." method="_on_postfire_timer_timeout"]
|
[connection signal="timeout" from="Timers/postfire_timer" to="." method="_on_postfire_timer_timeout"]
|
||||||
|
|||||||
489
blunderbus.tscn
489
blunderbus.tscn
File diff suppressed because one or more lines are too long
@@ -44,6 +44,7 @@ magnet=""
|
|||||||
hud=""
|
hud=""
|
||||||
moveable=""
|
moveable=""
|
||||||
door=""
|
door=""
|
||||||
|
spawned=""
|
||||||
|
|
||||||
[input]
|
[input]
|
||||||
|
|
||||||
@@ -202,6 +203,7 @@ crouch={
|
|||||||
3d_physics/layer_5="Pickups"
|
3d_physics/layer_5="Pickups"
|
||||||
3d_physics/layer_6="Objects"
|
3d_physics/layer_6="Objects"
|
||||||
3d_physics/layer_7="NPC"
|
3d_physics/layer_7="NPC"
|
||||||
|
3d_physics/layer_8="Bullet"
|
||||||
|
|
||||||
[physics]
|
[physics]
|
||||||
|
|
||||||
|
|||||||
@@ -22,3 +22,8 @@ func hit(bullet_damage):
|
|||||||
number_spawn.damage_amt = bullet_damage * damage
|
number_spawn.damage_amt = bullet_damage * damage
|
||||||
number_spawn.position = global_position + Vector3(0,2,0)
|
number_spawn.position = global_position + Vector3(0,2,0)
|
||||||
get_tree().get_root().add_child(number_spawn)
|
get_tree().get_root().add_child(number_spawn)
|
||||||
|
|
||||||
|
func _on_body_entered(body: Node3D) -> void:
|
||||||
|
if body.is_in_group("pellet"):
|
||||||
|
hit(body.bullet_damage)
|
||||||
|
SignalBus.emit_signal("enemy_hit")
|
||||||
|
|||||||
138
scripts/blunderbus.gd
Normal file
138
scripts/blunderbus.gd
Normal file
@@ -0,0 +1,138 @@
|
|||||||
|
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 : Vector3 = Vector3(.2,0,0)
|
||||||
|
@export var spread : Vector3 = Vector3(1,1,1)
|
||||||
|
@export var kick_amount : float = 5
|
||||||
|
@export var max_ammo = 15
|
||||||
|
@export var start_mags = 3
|
||||||
|
@export var pellets_per_shot = 12
|
||||||
|
@export var bullet_damage = 1
|
||||||
|
@export var bullet_force_mod = 5
|
||||||
|
@export var blast_power = 50.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 bullet : Resource
|
||||||
|
@export_subgroup("Raycast Nodes")
|
||||||
|
@export var anim_player : Node
|
||||||
|
@export var barrel_raycast : Node
|
||||||
|
@export_subgroup("Audio Clips")
|
||||||
|
@export var audio_fire : Node
|
||||||
|
@export var audio_empty : Node
|
||||||
|
@export var audio_reload : Node
|
||||||
|
|
||||||
|
@onready var player = get_tree().current_scene.player
|
||||||
|
@onready var level_control = get_tree().current_scene
|
||||||
|
@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")
|
||||||
|
|
||||||
|
pellet_spawn()
|
||||||
|
player.recoil.add_recoil(Vector3(0,recoil_amount.y,recoil_amount.z),10,10)
|
||||||
|
player.recoil.add_gun_recoil(recoil_amount.x)
|
||||||
|
player.velocity += player.bullet_ray.global_basis * Vector3(0,0, kick_amount)
|
||||||
|
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():
|
||||||
|
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 pellet_spawn():
|
||||||
|
var pellets_remaining = pellets_per_shot
|
||||||
|
while pellets_remaining > 0:
|
||||||
|
var lv_x = randf_range(-spread.x,spread.x)
|
||||||
|
var lv_y = randf_range(-spread.y,spread.y)
|
||||||
|
# instance bullet
|
||||||
|
var instance_bullet = bullet.instantiate()
|
||||||
|
instance_bullet.position = player.bullet_ray.global_position
|
||||||
|
instance_bullet.transform.basis = player.bullet_ray.global_transform.basis
|
||||||
|
instance_bullet.linear_velocity += instance_bullet.transform.basis * Vector3(lv_x, lv_y, -bullet_speed) + player.velocity
|
||||||
|
instance_bullet.bullet_damage = bullet_damage
|
||||||
|
instance_bullet.bullet_force_mod = bullet_force_mod
|
||||||
|
instance_bullet.player_position = player.global_position
|
||||||
|
get_tree().get_root().add_child(instance_bullet)
|
||||||
|
pellets_remaining -= 1
|
||||||
|
|
||||||
|
func swapped_out():
|
||||||
|
queue_free()
|
||||||
@@ -105,7 +105,7 @@ func shoot(delta):
|
|||||||
anim_player.play("empty")
|
anim_player.play("empty")
|
||||||
audio_empty.play()
|
audio_empty.play()
|
||||||
|
|
||||||
func reload(delta):
|
func reload():
|
||||||
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:
|
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
|
#player.reloading = true
|
||||||
anim_player.play("reload")
|
anim_player.play("reload")
|
||||||
|
|||||||
@@ -263,7 +263,7 @@ func _physics_process(delta):
|
|||||||
|
|
||||||
# Reloading
|
# Reloading
|
||||||
if Input.is_action_just_pressed("reload"):
|
if Input.is_action_just_pressed("reload"):
|
||||||
gun.reload(delta)
|
gun.reload()
|
||||||
|
|
||||||
if Input.is_action_pressed("inspect") and !gun.anim_player.is_playing():
|
if Input.is_action_pressed("inspect") and !gun.anim_player.is_playing():
|
||||||
gun.anim_player.play("inspect")
|
gun.anim_player.play("inspect")
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ func fire(delta):
|
|||||||
player.recoil.add_gun_recoil(recoil_amount.x)
|
player.recoil.add_gun_recoil(recoil_amount.x)
|
||||||
chamber.rotate_object_local(Vector3(0,-1,0),deg_to_rad(60))
|
chamber.rotate_object_local(Vector3(0,-1,0),deg_to_rad(60))
|
||||||
|
|
||||||
func reload(delta):
|
func reload():
|
||||||
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:
|
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:
|
||||||
anim_player.play("reload")
|
anim_player.play("reload")
|
||||||
audio_reload.play()
|
audio_reload.play()
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ func shoot(delta):
|
|||||||
anim_player.play("empty")
|
anim_player.play("empty")
|
||||||
audio_empty.play()
|
audio_empty.play()
|
||||||
|
|
||||||
func reload(delta):
|
func reload():
|
||||||
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:
|
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
|
#player.reloading = true
|
||||||
anim_player.play("reload")
|
anim_player.play("reload")
|
||||||
|
|||||||
67
scripts/shotgun_pellet.gd
Normal file
67
scripts/shotgun_pellet.gd
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
extends RigidBody3D
|
||||||
|
|
||||||
|
@export var max_bounces : int = 10
|
||||||
|
|
||||||
|
@onready var collision_shape: CollisionShape3D = $CollisionShape3D
|
||||||
|
@onready var mesh: MeshInstance3D = $MeshInstance3D
|
||||||
|
@onready var material = mesh.get_surface_override_material(0)
|
||||||
|
|
||||||
|
var bullet_force_mod
|
||||||
|
var bullet_damage
|
||||||
|
var player_position
|
||||||
|
var bounces = 0
|
||||||
|
var start_time
|
||||||
|
var end_time
|
||||||
|
|
||||||
|
const EMISSION_MAX : float = 20
|
||||||
|
const EMISSION_LIFETIME : float = 2 #in seconds
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready() -> void:
|
||||||
|
visible = false
|
||||||
|
start_time = Time.get_ticks_msec()
|
||||||
|
end_time = start_time + (EMISSION_LIFETIME * 1000)
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
var current_time = (Time.get_ticks_msec())/end_time
|
||||||
|
material.emission_energy_multiplier = clamp(lerp(EMISSION_MAX,0.0,current_time),0,EMISSION_MAX)
|
||||||
|
|
||||||
|
var distance_from_player = abs(self.global_position - player_position)
|
||||||
|
|
||||||
|
if distance_from_player.length() > 1.5:
|
||||||
|
visible = true
|
||||||
|
|
||||||
|
|
||||||
|
func _on_body_entered(body: Node) -> void:
|
||||||
|
bounces += 1
|
||||||
|
if bounces >= max_bounces:
|
||||||
|
despawn()
|
||||||
|
|
||||||
|
if body != null and !body.is_in_group("player"):
|
||||||
|
|
||||||
|
|
||||||
|
if body.is_in_group("enemy_target"):
|
||||||
|
SignalBus.emit_signal("enemy_hit")
|
||||||
|
body.hit(bullet_damage)
|
||||||
|
|
||||||
|
|
||||||
|
if body.is_in_group("switch"):
|
||||||
|
body.hit()
|
||||||
|
|
||||||
|
#move rigidbodies
|
||||||
|
if body.is_in_group("scene_rigidbody"):
|
||||||
|
body.linear_velocity += transform.basis * Vector3(0,0,-1 * bullet_force_mod)
|
||||||
|
|
||||||
|
if body.is_in_group("breakable"):
|
||||||
|
var current_velocity = transform.basis * Vector3(0,0,-1 * bullet_force_mod)
|
||||||
|
body.breaking(current_velocity)
|
||||||
|
|
||||||
|
func despawn():
|
||||||
|
collision_shape.disabled = true
|
||||||
|
await get_tree().create_timer(1).timeout
|
||||||
|
self.queue_free()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_timer_timeout() -> void:
|
||||||
|
despawn()
|
||||||
@@ -213,3 +213,7 @@ func drop_loot(number_of_drops):
|
|||||||
|
|
||||||
if number_of_drops <= 0:
|
if number_of_drops <= 0:
|
||||||
can_die = true
|
can_die = true
|
||||||
|
|
||||||
|
|
||||||
|
func _on_area_3d_body_entered(body: Node3D) -> void:
|
||||||
|
pass # Replace with function body.
|
||||||
|
|||||||
Reference in New Issue
Block a user