refactored bullet script, broke shotgun pellets which will need to be fixed
This commit is contained in:
@@ -10,6 +10,7 @@ win_conditions = 0
|
||||
survival_time = 160.0
|
||||
max_number_of_chests = 3
|
||||
money_lost_multiplier = 0.5
|
||||
die_on_leaving_bounds = true
|
||||
weapon_penalty = 0
|
||||
weapon_drop_percentage = 0.5
|
||||
ammo_drop_percentage = 0.5
|
||||
|
||||
@@ -10,6 +10,7 @@ win_conditions = null
|
||||
survival_time = 160.0
|
||||
max_number_of_chests = 3
|
||||
money_lost_multiplier = 1.0
|
||||
die_on_leaving_bounds = false
|
||||
weapon_penalty = 2
|
||||
weapon_drop_percentage = 0.0
|
||||
ammo_drop_percentage = 0.5
|
||||
|
||||
@@ -10,6 +10,7 @@ win_conditions = 0
|
||||
survival_time = 160.0
|
||||
max_number_of_chests = 3
|
||||
money_lost_multiplier = 0.5
|
||||
die_on_leaving_bounds = true
|
||||
weapon_penalty = 1
|
||||
weapon_drop_percentage = 0.5
|
||||
ammo_drop_percentage = 0.5
|
||||
|
||||
BIN
assets/BlenderDesignFiles/AerialLandscape1.blend
Normal file
BIN
assets/BlenderDesignFiles/AerialLandscape1.blend
Normal file
Binary file not shown.
53
assets/BlenderDesignFiles/AerialLandscape1.blend.import
Normal file
53
assets/BlenderDesignFiles/AerialLandscape1.blend.import
Normal file
@@ -0,0 +1,53 @@
|
||||
[remap]
|
||||
|
||||
importer="scene"
|
||||
importer_version=1
|
||||
type="PackedScene"
|
||||
uid="uid://defxivhf1ui5g"
|
||||
path="res://.godot/imported/AerialLandscape1.blend-9a74fa80d6522f40d49c9d509ddf7cc4.scn"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/BlenderDesignFiles/AerialLandscape1.blend"
|
||||
dest_files=["res://.godot/imported/AerialLandscape1.blend-9a74fa80d6522f40d49c9d509ddf7cc4.scn"]
|
||||
|
||||
[params]
|
||||
|
||||
nodes/root_type=""
|
||||
nodes/root_name=""
|
||||
nodes/apply_root_scale=true
|
||||
nodes/root_scale=1.0
|
||||
nodes/import_as_skeleton_bones=false
|
||||
nodes/use_node_type_suffixes=true
|
||||
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
|
||||
animation/import_rest_as_RESET=false
|
||||
import_script/path=""
|
||||
_subresources={}
|
||||
blender/nodes/visible=0
|
||||
blender/nodes/active_collection_only=false
|
||||
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/export_geometry_nodes_instances=false
|
||||
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
|
||||
BIN
assets/BlenderDesignFiles/AerialLandscape1.blend1
Normal file
BIN
assets/BlenderDesignFiles/AerialLandscape1.blend1
Normal file
Binary file not shown.
BIN
assets/BlenderDesignFiles/landscape.png
Normal file
BIN
assets/BlenderDesignFiles/landscape.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.5 MiB |
35
assets/BlenderDesignFiles/landscape.png.import
Normal file
35
assets/BlenderDesignFiles/landscape.png.import
Normal file
@@ -0,0 +1,35 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://cq3kgfupvt4pa"
|
||||
path.s3tc="res://.godot/imported/landscape.png-d143f98839a79e559ecc6e73ef498612.s3tc.ctex"
|
||||
metadata={
|
||||
"imported_formats": ["s3tc_bptc"],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/BlenderDesignFiles/landscape.png"
|
||||
dest_files=["res://.godot/imported/landscape.png-d143f98839a79e559ecc6e73ef498612.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
|
||||
@@ -1,6 +1,6 @@
|
||||
[gd_scene load_steps=13 format=4 uid="uid://dqhltdnqyg8ni"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://btbe1gyu0llcc" path="res://scripts/bullet.gd" id="1_oj0f5"]
|
||||
[ext_resource type="Script" uid="uid://ds5mhgyjqkffa" path="res://scripts/projectile.gd" id="1_ev345"]
|
||||
[ext_resource type="Texture2D" uid="uid://dqytegxsmb5kg" path="res://assets/Models/bullet.transparency.png" id="2_0ks2n"]
|
||||
[ext_resource type="AudioStream" uid="uid://dqj4cx05f25jj" path="res://assets/Audio/punch-body-hard-SBA-300156881.wav" id="3_6j0l2"]
|
||||
|
||||
@@ -82,7 +82,7 @@ margin = 0.001
|
||||
height = 1.5
|
||||
radius = 0.055
|
||||
|
||||
[node name="Bullet" type="RigidBody3D"]
|
||||
[node name="Bullet" type="RigidBody3D" node_paths=PackedStringArray("collision_raycast_3d")]
|
||||
top_level = true
|
||||
collision_layer = 128
|
||||
collision_mask = 233
|
||||
@@ -94,7 +94,8 @@ center_of_mass_mode = 1
|
||||
continuous_cd = true
|
||||
contact_monitor = true
|
||||
max_contacts_reported = 3
|
||||
script = ExtResource("1_oj0f5")
|
||||
script = ExtResource("1_ev345")
|
||||
collision_raycast_3d = NodePath("RayCast3D")
|
||||
|
||||
[node name="Cylinder" type="MeshInstance3D" parent="."]
|
||||
transform = Transform3D(-2, -3.01992e-07, 0, 0, 0, -2, 3.01992e-07, -2, 0, 1.46364e-07, 0, 0.627698)
|
||||
|
||||
@@ -35,6 +35,7 @@ ssil_enabled = true
|
||||
sdfgi_enabled = true
|
||||
glow_enabled = true
|
||||
fog_density = 0.0005
|
||||
volumetric_fog_density = 0.0
|
||||
|
||||
[node name="Realtime Day Night Cycle" type="Node3D"]
|
||||
script = ExtResource("1_idjmm")
|
||||
|
||||
@@ -28,9 +28,8 @@ _data = {
|
||||
}
|
||||
|
||||
[node name="ShotgunPellet" type="RigidBody3D" groups=["pellet", "spawned"]]
|
||||
visible = false
|
||||
collision_layer = 160
|
||||
collision_mask = 237
|
||||
collision_mask = 233
|
||||
mass = 0.01
|
||||
physics_material_override = SubResource("PhysicsMaterial_0ewk3")
|
||||
continuous_cd = true
|
||||
|
||||
1045
customHDRTest2_v1.hdr
Normal file
1045
customHDRTest2_v1.hdr
Normal file
File diff suppressed because one or more lines are too long
35
customHDRTest2_v1.hdr.import
Normal file
35
customHDRTest2_v1.hdr.import
Normal file
@@ -0,0 +1,35 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://c4hjvlfvvhn0s"
|
||||
path.bptc="res://.godot/imported/customHDRTest2_v1.hdr-b0c366e6930f12b79c42f69cafd17072.bptc.ctex"
|
||||
metadata={
|
||||
"imported_formats": ["s3tc_bptc"],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://customHDRTest2_v1.hdr"
|
||||
dest_files=["res://.godot/imported/customHDRTest2_v1.hdr-b0c366e6930f12b79c42f69cafd17072.bptc.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
|
||||
@@ -9,6 +9,7 @@ class_name gamemode
|
||||
@export_group("Rewards and Penalties")
|
||||
@export var max_number_of_chests : int = 3
|
||||
@export var money_lost_multiplier : float = .5
|
||||
@export var die_on_leaving_bounds : bool = true
|
||||
@export_enum("Drop All Weapons","Drop Random","Drop None") var weapon_penalty = 1
|
||||
@export var weapon_drop_percentage : float = .5
|
||||
@export var ammo_drop_percentage : float = .5
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=22 format=3 uid="uid://jdwpc622vmok"]
|
||||
[gd_scene load_steps=24 format=3 uid="uid://jdwpc622vmok"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bkii8jwf0k7tq" path="res://scripts/LevelManager.gd" id="1_1bnbi"]
|
||||
[ext_resource type="Resource" uid="uid://bxcxqt7rmfvdw" path="res://GameModes/hubworld.tres" id="2_62iy8"]
|
||||
@@ -20,9 +20,11 @@
|
||||
[ext_resource type="PackedScene" uid="uid://dyu46bns8mesv" path="res://assets/mac10_pickup.tscn" id="17_u30rd"]
|
||||
[ext_resource type="PackedScene" uid="uid://c1xw80jkg3reb" path="res://assets/target_1.tscn" id="19_sx5wx"]
|
||||
[ext_resource type="Script" uid="uid://bdxonkxnmxe6n" path="res://scripts/level_bounds.gd" id="20_vf4a6"]
|
||||
[ext_resource type="PackedScene" uid="uid://clu76sc4uoswn" path="res://assets/rocketlauncher_pickup.tscn" id="21_141ag"]
|
||||
[ext_resource type="PackedScene" uid="uid://cucqbjb8bcha5" path="res://assets/blunderbuss_pickup.tscn" id="22_2yaaf"]
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_141ag"]
|
||||
size = Vector3(80, 80, 80)
|
||||
size = Vector3(483.481, 625.469, 570.092)
|
||||
|
||||
[node name="HUB_1" type="Node3D" groups=["hub_level"]]
|
||||
script = ExtResource("1_1bnbi")
|
||||
@@ -263,6 +265,13 @@ collision_mask = 4
|
||||
script = ExtResource("20_vf4a6")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="LEVEL BOUNDS"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -272.734, 0)
|
||||
shape = SubResource("BoxShape3D_141ag")
|
||||
|
||||
[node name="rocketlauncher1_pickup" parent="." instance=ExtResource("21_141ag")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -7.78741, 1.53856, 9.41904)
|
||||
|
||||
[node name="blunderbuss_pickup" parent="." instance=ExtResource("22_2yaaf")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.76056, 2.37684, 5.52356)
|
||||
|
||||
[connection signal="body_exited" from="LEVEL BOUNDS" to="LEVEL BOUNDS" method="_on_body_exited"]
|
||||
|
||||
@@ -12,9 +12,9 @@ func _ready() -> void:
|
||||
center = Vector2(sub_viewport.size.x/2,sub_viewport.size.y/2)
|
||||
|
||||
func _draw() -> void:
|
||||
print("CHARACTER HEALTH : ")
|
||||
var health_percentage : float = health_bar_sprite.character.health/health_bar_sprite.character.start_health
|
||||
#background
|
||||
|
||||
#draw background
|
||||
draw_line(Vector2(0,center.y),Vector2(sub_viewport.size.x,center.y),Color(.5,.5,.5,.75),MARGIN * 2,true)
|
||||
|
||||
#health
|
||||
|
||||
@@ -4,75 +4,13 @@ extends Projectile
|
||||
@onready var mesh = $Cylinder
|
||||
@onready var particles = $GPUParticles3D
|
||||
@onready var enemy_particles = $GPUParticlesEnemy
|
||||
@onready var hit_indicator = $Audio/HitIndicator
|
||||
@onready var ray: RayCast3D = $RayCast3D
|
||||
@onready var water_leak : Resource = preload("res://assets/water_leak.tscn")
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
|
||||
visible = false
|
||||
linear_velocity += transform.basis * Vector3(0, 0, -bullet_speed) + player_velocity
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _physics_process(delta):
|
||||
|
||||
angular_velocity = Vector3(0,0,0)
|
||||
|
||||
var distance_from_player = abs(self.global_position - player_position)
|
||||
|
||||
if distance_from_player.length() > 2:
|
||||
visible = true
|
||||
|
||||
if ray.is_colliding():
|
||||
var body = ray.get_collider()
|
||||
if body != null and !body.is_in_group("player"):
|
||||
|
||||
mesh.visible = false
|
||||
ray.enabled = false
|
||||
|
||||
if body.has_method("hit"):
|
||||
hit_indicator.play()
|
||||
enemy_particles.emitting = true
|
||||
body.hit(bullet_damage)
|
||||
|
||||
#bullethole effect
|
||||
body.add_child(instance_bullethole)
|
||||
instance_bullethole.global_transform.origin = ray.get_collision_point()
|
||||
if (abs(ray.get_collision_normal().y) > 0.99):
|
||||
instance_bullethole.look_at(ray.get_collision_point() + ray.get_collision_normal(), Vector3(0,0,1))
|
||||
else:
|
||||
instance_bullethole.look_at(ray.get_collision_point() + ray.get_collision_normal())
|
||||
instance_bullethole.rotation.z = deg_to_rad(randf_range(0,360))
|
||||
|
||||
#range target
|
||||
if body.is_in_group("range_target"):
|
||||
body.add_marker(ray.get_collision_point(),ray.global_rotation)
|
||||
|
||||
# Leaking effect
|
||||
if body.is_in_group("leak"):
|
||||
var leakspawn = water_leak.instantiate()
|
||||
body.add_child(leakspawn)
|
||||
leakspawn.global_transform.origin = ray.get_collision_point()
|
||||
if (abs(ray.get_collision_normal().y) > 0.99):
|
||||
leakspawn.look_at(ray.get_collision_point() + ray.get_collision_normal(), Vector3(0,0,1))
|
||||
else:
|
||||
leakspawn.look_at(ray.get_collision_point() + ray.get_collision_normal())
|
||||
leakspawn.rotation.z = deg_to_rad(randf_range(0,360))
|
||||
|
||||
if body.is_in_group("switch"):
|
||||
body.hit(bullet_damage)
|
||||
|
||||
if body.is_in_group("breakable"):
|
||||
var current_velocity = transform.basis * Vector3(0,0,-1 * bullet_force_mod)
|
||||
ray.get_collider().breaking(current_velocity)
|
||||
|
||||
queue_free()
|
||||
|
||||
func _on_body_entered(body: Node) -> void:
|
||||
if !body.is_in_group("player"):
|
||||
await get_tree().create_timer(.1).timeout
|
||||
mesh.visible = false
|
||||
|
||||
func despawn():
|
||||
queue_free()
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
extends Sprite3D
|
||||
class_name HealthBar
|
||||
|
||||
@export var character : Node
|
||||
@onready var health_bar: Control = $SubViewport/HealthBar
|
||||
|
||||
@@ -2,4 +2,8 @@ extends Area3D
|
||||
|
||||
func _on_body_exited(body: Node3D) -> void:
|
||||
print("PLAYER OUT OF BOUNDS")
|
||||
get_tree().current_scene.die()
|
||||
var level_control = get_tree().current_scene
|
||||
if level_control.gamemode.die_on_leaving_bounds == true:
|
||||
get_tree().current_scene.die()
|
||||
else:
|
||||
body.global_position = body.last_ground_pos + Vector3(0,10,0)
|
||||
|
||||
@@ -36,6 +36,8 @@ var moving_fast_top_speed = 0.0
|
||||
var mouse_input : Vector2
|
||||
var ads : bool
|
||||
|
||||
var last_ground_pos
|
||||
|
||||
@export_group("Game Settings")
|
||||
@export var AUDIO = true
|
||||
@export_group("Player Movement")
|
||||
@@ -473,6 +475,7 @@ func _physics_process(delta):
|
||||
if GameGlobals.health <= 0:
|
||||
level_control.die()
|
||||
|
||||
cache_ground_pos()
|
||||
focus_on_target()
|
||||
joypad_look()
|
||||
aim_down_sights(delta)
|
||||
@@ -511,6 +514,10 @@ func joypad_look():
|
||||
head.rotate_x(-yAxis * JOYSTICK_SENSITIVITY * 1)
|
||||
head.rotation.x = clamp(head.rotation.x, deg_to_rad(-90), deg_to_rad(85))
|
||||
|
||||
func cache_ground_pos():
|
||||
if is_on_floor():
|
||||
last_ground_pos = global_position
|
||||
|
||||
func punch():
|
||||
if interact_ray.is_colliding():
|
||||
if interact_ray.get_collider().has_method("hit"):
|
||||
|
||||
@@ -3,6 +3,8 @@ class_name Projectile
|
||||
|
||||
@export var collision_raycast_3d : RayCast3D
|
||||
|
||||
const BULLET_HOLE = preload("res://assets/bullet_hole.tscn")
|
||||
|
||||
var player_position
|
||||
var player_velocity
|
||||
var bullet_active = true
|
||||
@@ -16,13 +18,61 @@ var blast_radius
|
||||
func _ready() -> void:
|
||||
visible = false
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
var distance_from_player = abs(self.global_position - player_position)
|
||||
func _physics_process(delta: float) -> void:
|
||||
#make bullet visible when far enough from player
|
||||
if !visible:
|
||||
var distance_from_player = abs(self.global_position - player_position)
|
||||
|
||||
if distance_from_player.length() > 2.0:
|
||||
visible = true
|
||||
|
||||
if distance_from_player.length() > 2:
|
||||
visible = true
|
||||
if collision_raycast_3d != null:
|
||||
if collision_raycast_3d.is_colliding():
|
||||
var body = collision_raycast_3d.get_collider()
|
||||
damage(body)
|
||||
|
||||
collision_ray_length_adj()
|
||||
|
||||
func collision_ray():
|
||||
func damage(body):
|
||||
if body != null and !body.is_in_group("player"):
|
||||
|
||||
if collision_raycast_3d != null:
|
||||
collision_raycast_3d.enabled = false
|
||||
|
||||
if body.has_method("hit"):
|
||||
SignalBus.emit_signal("enemy_hit")
|
||||
body.hit(bullet_damage)
|
||||
|
||||
#bullethole effect, eventually add group test for different bullet hole textures
|
||||
add_normal_decal(body,BULLET_HOLE)
|
||||
|
||||
#mark range target
|
||||
if body.is_in_group("range_target") and collision_raycast_3d != null:
|
||||
body.add_marker(collision_raycast_3d.get_collision_point(),collision_raycast_3d.global_rotation)
|
||||
|
||||
#start leaking effect
|
||||
if body.is_in_group("leak") and body.water_leak != null:
|
||||
add_normal_decal(body,body.water_leak)
|
||||
|
||||
#break breakables
|
||||
if body.is_in_group("breakable"):
|
||||
var current_velocity = transform.basis * Vector3(0,0,-1 * bullet_force_mod)
|
||||
collision_raycast_3d.get_collider().breaking(current_velocity)
|
||||
|
||||
queue_free()
|
||||
|
||||
func add_normal_decal(body,instance):
|
||||
if collision_raycast_3d != null:
|
||||
var decal_spawn = instance.instantiate()
|
||||
body.add_child(decal_spawn)
|
||||
decal_spawn.global_transform.origin = collision_raycast_3d.get_collision_point()
|
||||
if (abs(collision_raycast_3d.get_collision_normal().y) > 0.99):
|
||||
decal_spawn.look_at(collision_raycast_3d.get_collision_point() + collision_raycast_3d.get_collision_normal(), Vector3(0,0,1))
|
||||
else:
|
||||
decal_spawn.look_at(collision_raycast_3d.get_collision_point() + collision_raycast_3d.get_collision_normal())
|
||||
decal_spawn.rotation.z = deg_to_rad(randf_range(0,360))
|
||||
|
||||
func collision_ray_length_adj():
|
||||
if collision_raycast_3d != null:
|
||||
#do looking towards velocity
|
||||
#do lenghth of distance traveled next frame
|
||||
|
||||
@@ -8,25 +8,18 @@ extends Projectile
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
linear_velocity += transform.basis * Vector3(0, 0, -bullet_speed)
|
||||
blast_radius = radius_shape.shape.radius
|
||||
|
||||
# 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):
|
||||
if !body.is_in_group("player"):
|
||||
#move objects
|
||||
explode()
|
||||
|
||||
#Spawn gpu particles
|
||||
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()
|
||||
#move objects
|
||||
explode()
|
||||
|
||||
#Spawn gpu particles
|
||||
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()
|
||||
|
||||
func explode():
|
||||
#get all collision objects that can be moved
|
||||
|
||||
@@ -9,7 +9,6 @@ extends Projectile
|
||||
var bounces = 0
|
||||
var start_time
|
||||
var end_time
|
||||
var start_velocity
|
||||
|
||||
const EMISSION_MAX : float = 200
|
||||
const EMISSION_LIFETIME : float = 1.75 #in seconds
|
||||
@@ -17,39 +16,22 @@ const VELOCITY_REQUIRED_TO_HIT : float = 10
|
||||
|
||||
# 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)
|
||||
start_velocity = linear_velocity.length()
|
||||
|
||||
# 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") and linear_velocity.length() >= VELOCITY_REQUIRED_TO_HIT:
|
||||
|
||||
if body.is_in_group("switch"):
|
||||
body.hit(bullet_damage)
|
||||
|
||||
if body.has_method("hit") and !body.is_in_group("player"):
|
||||
body.hit(1)
|
||||
|
||||
if body.is_in_group("breakable"):
|
||||
var current_velocity = transform.basis * Vector3(0,0,-1 * bullet_force_mod)
|
||||
body.breaking(current_velocity)
|
||||
if linear_velocity.length() >= VELOCITY_REQUIRED_TO_HIT:
|
||||
damage(body)
|
||||
|
||||
func despawn():
|
||||
collision_shape.disabled = true
|
||||
|
||||
@@ -48,12 +48,14 @@ func _ready():
|
||||
if weapon_info.weapon_type != 1:
|
||||
casings_chamber_last = weapon_info.max_ammo
|
||||
|
||||
if weapon_info.fire_mode == 0:
|
||||
cycle_count_start = 1
|
||||
elif weapon_info.fire_mode == 1:
|
||||
cycle_count_start = 1
|
||||
elif weapon_info.fire_mode == 2:
|
||||
cycle_count_start = 3
|
||||
match weapon_info.fire_mode:
|
||||
0:
|
||||
cycle_count_start = 1
|
||||
1:
|
||||
cycle_count_start = 1
|
||||
2:
|
||||
cycle_count_start = 3
|
||||
|
||||
cycle_count = cycle_count_start
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
@@ -252,22 +254,24 @@ func projectile_initialize():
|
||||
instance_bullet.transform.basis = player.bullet_ray.global_transform.basis
|
||||
else:
|
||||
instance_bullet.transform.basis = barrel_ray.global_transform.basis
|
||||
instance_bullet.bullet_speed = weapon_info.bullet_speed
|
||||
instance_bullet.player_velocity = player.velocity * transform.basis
|
||||
instance_bullet.bullet_damage = weapon_info.bullet_damage
|
||||
instance_bullet.blast_power = weapon_info.blast_power
|
||||
instance_bullet.bullet_force_mod = weapon_info.bullet_force_mod
|
||||
if weapon_info.bullet.bullet_hole != null:
|
||||
instance_bullet.instance_bullethole = weapon_info.bullet.bullet_hole.instantiate()
|
||||
instance_bullet.player_position = player.global_position
|
||||
instance_bullet.linear_velocity += instance_bullet.transform.basis * Vector3(0, 0, -weapon_info.bullet_speed) + player.velocity
|
||||
return instance_bullet
|
||||
|
||||
func bullet_fire():
|
||||
SignalBus.emit_signal("shot_fired",weapon_info.crosshair_jump_amount)
|
||||
audio_fire.play()
|
||||
get_tree().current_scene.add_child(projectile_initialize())
|
||||
var bullet_spawn = projectile_initialize()
|
||||
get_tree().current_scene.add_child(bullet_spawn)
|
||||
|
||||
spawn_casing()
|
||||
vibration()
|
||||
|
||||
if chamber != null:
|
||||
revolver_chamber_rot_amt += weapon_info.chamber_rot_amount
|
||||
if weapon_info.smoke_enabled:
|
||||
|
||||
Reference in New Issue
Block a user