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
|
||||
win_conditions = 0
|
||||
survival_time = 160.0
|
||||
max_number_of_chests = 3
|
||||
money_lost_multiplier = 0.5
|
||||
weapon_penalty = 0
|
||||
weapon_drop_percentage = 0.5
|
||||
|
||||
@@ -8,6 +8,7 @@ gamemode_name = "Standard with regen"
|
||||
estimated_difficulty = 0
|
||||
win_conditions = 0
|
||||
survival_time = 160.0
|
||||
max_number_of_chests = 3
|
||||
money_lost_multiplier = 0.5
|
||||
weapon_penalty = 0
|
||||
weapon_drop_percentage = 0.5
|
||||
|
||||
@@ -41,7 +41,8 @@ bullet_damage = 1
|
||||
smoke_enabled = false
|
||||
bullet_force_mod = 5.0
|
||||
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"]
|
||||
resource_name = "blunderbus.stock"
|
||||
@@ -637,7 +638,7 @@ tracks/4/keys = {
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"values": [{
|
||||
"args": [],
|
||||
"method": &"fire"
|
||||
"method": &"shotgun_pellet_spawn"
|
||||
}, {
|
||||
"args": [true],
|
||||
"method": &"barrel_smoke"
|
||||
|
||||
@@ -1376,7 +1376,7 @@ lod_bias = 10.0
|
||||
mesh = SubResource("ArrayMesh_a1hah")
|
||||
|
||||
[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
|
||||
mesh = SubResource("ArrayMesh_x43wl")
|
||||
|
||||
@@ -1452,7 +1452,7 @@ cast_shadow = 0
|
||||
mesh = SubResource("ArrayMesh_0w43n")
|
||||
|
||||
[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
|
||||
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="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"]
|
||||
|
||||
[resource]
|
||||
@@ -16,9 +17,11 @@ fov_zoom_amt = 0.98
|
||||
ads = false
|
||||
recoil_amount = Vector3(0.05, 0.05, 0.05)
|
||||
kick_amount = 0.1
|
||||
max_ammo = 15
|
||||
max_ammo = 6
|
||||
start_mags = 3
|
||||
bullet_damage = 1
|
||||
smoke_enabled = false
|
||||
bullet_force_mod = 5.0
|
||||
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 material = mesh.get_surface_override_material(0)
|
||||
|
||||
var bullet_speed
|
||||
var player_velocity
|
||||
var bullet_force_mod
|
||||
var bullet_damage
|
||||
var player_position
|
||||
|
||||
@@ -22,3 +22,4 @@ class_name weapon_resource
|
||||
@export var mag : Resource
|
||||
@export_group("Shotgun Settings")
|
||||
@export var shotgun_spread : Vector3 = Vector3(.1,.1,.1)
|
||||
@export var pellets_per_shot : int = 20
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
extends Node3D
|
||||
|
||||
class_name weapon
|
||||
|
||||
@export var weapon_info : weapon_resource
|
||||
@export var anim_player : AnimationPlayer
|
||||
@@ -20,7 +20,10 @@ extends Node3D
|
||||
|
||||
@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_rotation
|
||||
var cycle_count_start
|
||||
@@ -31,6 +34,9 @@ var gun_index
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
|
||||
if weapon_info.weapon_type == 0:
|
||||
casings_chamber_last = weapon_info.max_ammo
|
||||
|
||||
if weapon_info.fire_mode == 0:
|
||||
cycle_count = 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:
|
||||
GameGlobals.gun_ammo[weapon_info.gun_name] += 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:
|
||||
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)]
|
||||
casings_chamber_last = GameGlobals.ammo_reserve[str(weapon_info.bullet.ammo_type)]
|
||||
|
||||
func shoot(delta):
|
||||
if weapon_info.weapon_type == 0:
|
||||
@@ -68,8 +76,6 @@ func shoot(delta):
|
||||
audio_fire.play()
|
||||
anim_player.play("shoot")
|
||||
vibration()
|
||||
bullet_fire()
|
||||
spawn_casing()
|
||||
if chamber != null:
|
||||
revolver_chamber_rot_amt += 60
|
||||
if weapon_info.smoke_enabled:
|
||||
@@ -114,19 +120,21 @@ func spawn_mag():
|
||||
get_tree().get_root().add_child(instance_mag)
|
||||
|
||||
func spawn_casing():
|
||||
# Casing transform
|
||||
var instance_casing = weapon_info.casing.instantiate()
|
||||
instance_casing.position = casing_ejector.global_position
|
||||
instance_casing.transform.basis = casing_ejector.global_transform.basis
|
||||
instance_casing.player_velocity = player.velocity * transform.basis
|
||||
get_tree().get_root().add_child(instance_casing)
|
||||
if weapon_info.casing != null:
|
||||
# Casing transform
|
||||
var instance_casing = weapon_info.casing.instantiate()
|
||||
instance_casing.position = casing_ejector.global_position
|
||||
instance_casing.transform.basis = casing_ejector.global_transform.basis
|
||||
instance_casing.player_velocity = player.velocity * transform.basis
|
||||
get_tree().get_root().add_child(instance_casing)
|
||||
|
||||
|
||||
func spawn_revolver_casings():
|
||||
if casing_array.size() > 0:
|
||||
for i in casing_array:
|
||||
i.visible = false
|
||||
if weapon_info.casings_chamber_last > 0:
|
||||
var instance_casing = weapon_info.spawn_casing.instantiate()
|
||||
if casings_chamber_last > 0:
|
||||
var instance_casing = weapon_info.casing.instantiate()
|
||||
instance_casing.position = i.global_position
|
||||
instance_casing.random_rotation = false
|
||||
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.linear_velocity.y = -(8 + rng.randf_range(0,3))
|
||||
get_tree().get_root().add_child(instance_casing)
|
||||
weapon_info.casings_chamber_last -= 1
|
||||
casings_chamber_last -= 1
|
||||
|
||||
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_y = rng.randf_range(-weapon_info.shotgun_spread.y,weapon_info.shotgun_spread.y)
|
||||
# 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.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
|
||||
@@ -155,9 +163,10 @@ func shotgun_pellet_spawn():
|
||||
pellets_remaining -= 1
|
||||
|
||||
vibration()
|
||||
fire_smoke.restart()
|
||||
fire_smoke.emitting = true
|
||||
smoke_timer.start()
|
||||
if fire_smoke != null:
|
||||
fire_smoke.restart()
|
||||
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_gun_recoil(weapon_info.recoil_amount.x)
|
||||
player.velocity += player.bullet_ray.global_basis * Vector3(0,0, weapon_info.kick_amount)
|
||||
|
||||
Reference in New Issue
Block a user