got the script closer but also broke it harder
This commit is contained in:
@@ -8,6 +8,7 @@ gamemode_name = "Do Not Get Hit"
|
|||||||
estimated_difficulty = 4
|
estimated_difficulty = 4
|
||||||
win_conditions = 0
|
win_conditions = 0
|
||||||
survival_time = 160.0
|
survival_time = 160.0
|
||||||
|
max_number_of_chests = 3
|
||||||
money_lost_multiplier = 0.5
|
money_lost_multiplier = 0.5
|
||||||
weapon_penalty = 0
|
weapon_penalty = 0
|
||||||
weapon_drop_percentage = 0.5
|
weapon_drop_percentage = 0.5
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ gamemode_name = "Standard with regen"
|
|||||||
estimated_difficulty = 0
|
estimated_difficulty = 0
|
||||||
win_conditions = 0
|
win_conditions = 0
|
||||||
survival_time = 160.0
|
survival_time = 160.0
|
||||||
|
max_number_of_chests = 3
|
||||||
money_lost_multiplier = 0.5
|
money_lost_multiplier = 0.5
|
||||||
weapon_penalty = 0
|
weapon_penalty = 0
|
||||||
weapon_drop_percentage = 0.5
|
weapon_drop_percentage = 0.5
|
||||||
|
|||||||
@@ -41,7 +41,8 @@ bullet_damage = 1
|
|||||||
smoke_enabled = false
|
smoke_enabled = false
|
||||||
bullet_force_mod = 5.0
|
bullet_force_mod = 5.0
|
||||||
bullet_speed = 600
|
bullet_speed = 600
|
||||||
shotgun_spread = Vector3(0.1, 0.1, 0.1)
|
shotgun_spread = Vector3(10, 10, 10)
|
||||||
|
pellets_per_shot = 20
|
||||||
|
|
||||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_11x5l"]
|
[sub_resource type="ShaderMaterial" id="ShaderMaterial_11x5l"]
|
||||||
resource_name = "blunderbus.stock"
|
resource_name = "blunderbus.stock"
|
||||||
@@ -637,7 +638,7 @@ tracks/4/keys = {
|
|||||||
"transitions": PackedFloat32Array(1, 1),
|
"transitions": PackedFloat32Array(1, 1),
|
||||||
"values": [{
|
"values": [{
|
||||||
"args": [],
|
"args": [],
|
||||||
"method": &"fire"
|
"method": &"shotgun_pellet_spawn"
|
||||||
}, {
|
}, {
|
||||||
"args": [true],
|
"args": [true],
|
||||||
"method": &"barrel_smoke"
|
"method": &"barrel_smoke"
|
||||||
|
|||||||
@@ -1376,7 +1376,7 @@ lod_bias = 10.0
|
|||||||
mesh = SubResource("ArrayMesh_a1hah")
|
mesh = SubResource("ArrayMesh_a1hah")
|
||||||
|
|
||||||
[node name="Chamber" parent="revolver1" index="0"]
|
[node name="Chamber" parent="revolver1" index="0"]
|
||||||
transform = Transform3D(1, 0, 0, 0, -3.61999e-06, -1, 0, 1, -3.61999e-06, -0.0143475, 0, -0.0849619)
|
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, -0.0143475, 0, -0.0849619)
|
||||||
cast_shadow = 0
|
cast_shadow = 0
|
||||||
mesh = SubResource("ArrayMesh_x43wl")
|
mesh = SubResource("ArrayMesh_x43wl")
|
||||||
|
|
||||||
@@ -1452,7 +1452,7 @@ cast_shadow = 0
|
|||||||
mesh = SubResource("ArrayMesh_0w43n")
|
mesh = SubResource("ArrayMesh_0w43n")
|
||||||
|
|
||||||
[node name="Trigger" parent="revolver1" index="2"]
|
[node name="Trigger" parent="revolver1" index="2"]
|
||||||
transform = Transform3D(0.207537, -0.978227, 3.54117e-06, 0, -3.61999e-06, -1, 0.978227, 0.207537, -7.51281e-07, 0.226752, 0, -0.00209358)
|
transform = Transform3D(0.207537, -0.978227, 4.27597e-08, 0, -4.37114e-08, -1, 0.978227, 0.207537, -9.07173e-09, 0.226752, 0, -0.00209358)
|
||||||
cast_shadow = 0
|
cast_shadow = 0
|
||||||
mesh = SubResource("ArrayMesh_ahftj")
|
mesh = SubResource("ArrayMesh_ahftj")
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
[gd_resource type="Resource" script_class="weapon_resource" load_steps=4 format=3 uid="uid://cqphw4ll1bjjx"]
|
[gd_resource type="Resource" script_class="weapon_resource" load_steps=5 format=3 uid="uid://cqphw4ll1bjjx"]
|
||||||
|
|
||||||
[ext_resource type="Resource" uid="uid://b4sqlnsf0jla2" path="res://assets/weaponresources/medium_ammo.tres" id="1_53e42"]
|
[ext_resource type="Resource" uid="uid://b4sqlnsf0jla2" path="res://assets/weaponresources/medium_ammo.tres" id="1_53e42"]
|
||||||
[ext_resource type="Texture2D" uid="uid://bho7c8s2yno12" path="res://assets/Textures/ObjectTextures/revolver1.png" id="2_n6mhi"]
|
[ext_resource type="Texture2D" uid="uid://bho7c8s2yno12" path="res://assets/Textures/ObjectTextures/revolver1.png" id="2_n6mhi"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://c1gdehrsytlkk" path="res://assets/casing.tscn" id="2_ylruw"]
|
||||||
[ext_resource type="Script" path="res://scripts/weapon_resource.gd" id="3_1a2hk"]
|
[ext_resource type="Script" path="res://scripts/weapon_resource.gd" id="3_1a2hk"]
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
@@ -16,9 +17,11 @@ fov_zoom_amt = 0.98
|
|||||||
ads = false
|
ads = false
|
||||||
recoil_amount = Vector3(0.05, 0.05, 0.05)
|
recoil_amount = Vector3(0.05, 0.05, 0.05)
|
||||||
kick_amount = 0.1
|
kick_amount = 0.1
|
||||||
max_ammo = 15
|
max_ammo = 6
|
||||||
start_mags = 3
|
start_mags = 3
|
||||||
bullet_damage = 1
|
bullet_damage = 1
|
||||||
smoke_enabled = false
|
smoke_enabled = false
|
||||||
bullet_force_mod = 5.0
|
bullet_force_mod = 5.0
|
||||||
bullet_speed = 1200
|
bullet_speed = 1200
|
||||||
|
casing = ExtResource("2_ylruw")
|
||||||
|
shotgun_spread = Vector3(0.1, 0.1, 0.1)
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ extends RigidBody3D
|
|||||||
@onready var mesh: MeshInstance3D = $MeshInstance3D
|
@onready var mesh: MeshInstance3D = $MeshInstance3D
|
||||||
@onready var material = mesh.get_surface_override_material(0)
|
@onready var material = mesh.get_surface_override_material(0)
|
||||||
|
|
||||||
|
var bullet_speed
|
||||||
|
var player_velocity
|
||||||
var bullet_force_mod
|
var bullet_force_mod
|
||||||
var bullet_damage
|
var bullet_damage
|
||||||
var player_position
|
var player_position
|
||||||
|
|||||||
@@ -22,3 +22,4 @@ class_name weapon_resource
|
|||||||
@export var mag : Resource
|
@export var mag : Resource
|
||||||
@export_group("Shotgun Settings")
|
@export_group("Shotgun Settings")
|
||||||
@export var shotgun_spread : Vector3 = Vector3(.1,.1,.1)
|
@export var shotgun_spread : Vector3 = Vector3(.1,.1,.1)
|
||||||
|
@export var pellets_per_shot : int = 20
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
extends Node3D
|
extends Node3D
|
||||||
|
class_name weapon
|
||||||
|
|
||||||
@export var weapon_info : weapon_resource
|
@export var weapon_info : weapon_resource
|
||||||
@export var anim_player : AnimationPlayer
|
@export var anim_player : AnimationPlayer
|
||||||
@@ -20,7 +20,10 @@ extends Node3D
|
|||||||
|
|
||||||
@onready var player = get_tree().current_scene.player
|
@onready var player = get_tree().current_scene.player
|
||||||
|
|
||||||
var revolver_chamber_rot_amt
|
# Revolver vars
|
||||||
|
var revolver_chamber_rot_amt = 0
|
||||||
|
var casings_chamber_last
|
||||||
|
|
||||||
var start_position
|
var start_position
|
||||||
var start_rotation
|
var start_rotation
|
||||||
var cycle_count_start
|
var cycle_count_start
|
||||||
@@ -31,6 +34,9 @@ var gun_index
|
|||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready():
|
func _ready():
|
||||||
|
|
||||||
|
if weapon_info.weapon_type == 0:
|
||||||
|
casings_chamber_last = weapon_info.max_ammo
|
||||||
|
|
||||||
if weapon_info.fire_mode == 0:
|
if weapon_info.fire_mode == 0:
|
||||||
cycle_count = 1
|
cycle_count = 1
|
||||||
cycle_count_start = 1
|
cycle_count_start = 1
|
||||||
@@ -55,9 +61,11 @@ func reload_finished():
|
|||||||
if GameGlobals.ammo_reserve[str(weapon_info.bullet.ammo_type)] >= weapon_info.max_ammo:
|
if GameGlobals.ammo_reserve[str(weapon_info.bullet.ammo_type)] >= weapon_info.max_ammo:
|
||||||
GameGlobals.gun_ammo[weapon_info.gun_name] += weapon_info.max_ammo
|
GameGlobals.gun_ammo[weapon_info.gun_name] += weapon_info.max_ammo
|
||||||
GameGlobals.ammo_reserve[str(weapon_info.bullet.ammo_type)] -= weapon_info.max_ammo
|
GameGlobals.ammo_reserve[str(weapon_info.bullet.ammo_type)] -= weapon_info.max_ammo
|
||||||
|
casings_chamber_last = weapon_info.max_ammo
|
||||||
else:
|
else:
|
||||||
GameGlobals.gun_ammo[weapon_info.gun_name] += GameGlobals.ammo_reserve[str(weapon_info.bullet.ammo_type)]
|
GameGlobals.gun_ammo[weapon_info.gun_name] += GameGlobals.ammo_reserve[str(weapon_info.bullet.ammo_type)]
|
||||||
GameGlobals.ammo_reserve[str(weapon_info.bullet.ammo_type)] -= GameGlobals.ammo_reserve[str(weapon_info.bullet.ammo_type)]
|
GameGlobals.ammo_reserve[str(weapon_info.bullet.ammo_type)] -= GameGlobals.ammo_reserve[str(weapon_info.bullet.ammo_type)]
|
||||||
|
casings_chamber_last = GameGlobals.ammo_reserve[str(weapon_info.bullet.ammo_type)]
|
||||||
|
|
||||||
func shoot(delta):
|
func shoot(delta):
|
||||||
if weapon_info.weapon_type == 0:
|
if weapon_info.weapon_type == 0:
|
||||||
@@ -68,8 +76,6 @@ func shoot(delta):
|
|||||||
audio_fire.play()
|
audio_fire.play()
|
||||||
anim_player.play("shoot")
|
anim_player.play("shoot")
|
||||||
vibration()
|
vibration()
|
||||||
bullet_fire()
|
|
||||||
spawn_casing()
|
|
||||||
if chamber != null:
|
if chamber != null:
|
||||||
revolver_chamber_rot_amt += 60
|
revolver_chamber_rot_amt += 60
|
||||||
if weapon_info.smoke_enabled:
|
if weapon_info.smoke_enabled:
|
||||||
@@ -114,19 +120,21 @@ func spawn_mag():
|
|||||||
get_tree().get_root().add_child(instance_mag)
|
get_tree().get_root().add_child(instance_mag)
|
||||||
|
|
||||||
func spawn_casing():
|
func spawn_casing():
|
||||||
# Casing transform
|
if weapon_info.casing != null:
|
||||||
var instance_casing = weapon_info.casing.instantiate()
|
# Casing transform
|
||||||
instance_casing.position = casing_ejector.global_position
|
var instance_casing = weapon_info.casing.instantiate()
|
||||||
instance_casing.transform.basis = casing_ejector.global_transform.basis
|
instance_casing.position = casing_ejector.global_position
|
||||||
instance_casing.player_velocity = player.velocity * transform.basis
|
instance_casing.transform.basis = casing_ejector.global_transform.basis
|
||||||
get_tree().get_root().add_child(instance_casing)
|
instance_casing.player_velocity = player.velocity * transform.basis
|
||||||
|
get_tree().get_root().add_child(instance_casing)
|
||||||
|
|
||||||
|
|
||||||
func spawn_revolver_casings():
|
func spawn_revolver_casings():
|
||||||
if casing_array.size() > 0:
|
if casing_array.size() > 0:
|
||||||
for i in casing_array:
|
for i in casing_array:
|
||||||
i.visible = false
|
i.visible = false
|
||||||
if weapon_info.casings_chamber_last > 0:
|
if casings_chamber_last > 0:
|
||||||
var instance_casing = weapon_info.spawn_casing.instantiate()
|
var instance_casing = weapon_info.casing.instantiate()
|
||||||
instance_casing.position = i.global_position
|
instance_casing.position = i.global_position
|
||||||
instance_casing.random_rotation = false
|
instance_casing.random_rotation = false
|
||||||
instance_casing.transform.basis = i.global_transform.basis
|
instance_casing.transform.basis = i.global_transform.basis
|
||||||
@@ -134,7 +142,7 @@ func spawn_revolver_casings():
|
|||||||
instance_casing.rotation.x += deg_to_rad(90)
|
instance_casing.rotation.x += deg_to_rad(90)
|
||||||
instance_casing.linear_velocity.y = -(8 + rng.randf_range(0,3))
|
instance_casing.linear_velocity.y = -(8 + rng.randf_range(0,3))
|
||||||
get_tree().get_root().add_child(instance_casing)
|
get_tree().get_root().add_child(instance_casing)
|
||||||
weapon_info.casings_chamber_last -= 1
|
casings_chamber_last -= 1
|
||||||
|
|
||||||
func shotgun_pellet_spawn():
|
func shotgun_pellet_spawn():
|
||||||
|
|
||||||
@@ -146,7 +154,7 @@ func shotgun_pellet_spawn():
|
|||||||
var lv_x = rng.randf_range(-weapon_info.shotgun_spread.x,weapon_info.shotgun_spread.x)
|
var lv_x = rng.randf_range(-weapon_info.shotgun_spread.x,weapon_info.shotgun_spread.x)
|
||||||
var lv_y = rng.randf_range(-weapon_info.shotgun_spread.y,weapon_info.shotgun_spread.y)
|
var lv_y = rng.randf_range(-weapon_info.shotgun_spread.y,weapon_info.shotgun_spread.y)
|
||||||
# instance bullet
|
# instance bullet
|
||||||
var instance_bullet = weapon_info.bullet.instantiate()
|
var instance_bullet = weapon_info.bullet.asset.instantiate()
|
||||||
instance_bullet.position = player.bullet_ray.global_position
|
instance_bullet.position = player.bullet_ray.global_position
|
||||||
instance_bullet.transform.basis = player.bullet_ray.global_transform.basis
|
instance_bullet.transform.basis = player.bullet_ray.global_transform.basis
|
||||||
instance_bullet.linear_velocity += instance_bullet.transform.basis * Vector3(lv_x, lv_y, -weapon_info.bullet_speed) + player.velocity
|
instance_bullet.linear_velocity += instance_bullet.transform.basis * Vector3(lv_x, lv_y, -weapon_info.bullet_speed) + player.velocity
|
||||||
@@ -155,9 +163,10 @@ func shotgun_pellet_spawn():
|
|||||||
pellets_remaining -= 1
|
pellets_remaining -= 1
|
||||||
|
|
||||||
vibration()
|
vibration()
|
||||||
fire_smoke.restart()
|
if fire_smoke != null:
|
||||||
fire_smoke.emitting = true
|
fire_smoke.restart()
|
||||||
smoke_timer.start()
|
fire_smoke.emitting = true
|
||||||
|
smoke_timer.start()
|
||||||
player.recoil.add_recoil(Vector3(0,weapon_info.recoil_amount.y,weapon_info.recoil_amount.z),10,10)
|
player.recoil.add_recoil(Vector3(0,weapon_info.recoil_amount.y,weapon_info.recoil_amount.z),10,10)
|
||||||
player.recoil.add_gun_recoil(weapon_info.recoil_amount.x)
|
player.recoil.add_gun_recoil(weapon_info.recoil_amount.x)
|
||||||
player.velocity += player.bullet_ray.global_basis * Vector3(0,0, weapon_info.kick_amount)
|
player.velocity += player.bullet_ray.global_basis * Vector3(0,0, weapon_info.kick_amount)
|
||||||
|
|||||||
Reference in New Issue
Block a user