First ever primary weapon
This commit is contained in:
parent
630cc8abb1
commit
eabc137ce8
14 changed files with 237 additions and 15 deletions
36
weapons/gun/mc/droppable_mc.tscn
Normal file
36
weapons/gun/mc/droppable_mc.tscn
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
[gd_scene load_steps=6 format=3 uid="uid://b3xux7url8d2s"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cskgqgkr7pmb0" path="res://systems/weapon_system/dropped_weapon.gd" id="1_xr2im"]
|
||||
[ext_resource type="PackedScene" uid="uid://8ohlfmr5bp0k" path="res://weapons/gun/mc/mc255.tscn" id="2_nf8ho"]
|
||||
[ext_resource type="PackedScene" uid="uid://b57k7qap3jn6a" path="res://models/weapons/mc255.glb" id="3_nf8ho"]
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_477rq"]
|
||||
size = Vector3(0.122802734, 0.3173828, 1.263977)
|
||||
|
||||
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_ddvbd"]
|
||||
properties/0/path = NodePath(".:position")
|
||||
properties/0/spawn = true
|
||||
properties/0/replication_mode = 1
|
||||
properties/1/path = NodePath(".:rotation")
|
||||
properties/1/spawn = true
|
||||
properties/1/replication_mode = 1
|
||||
|
||||
[node name="DroppableMC255" type="RigidBody3D" node_paths=PackedStringArray("weapon")]
|
||||
collision_layer = 8
|
||||
collision_mask = 9
|
||||
continuous_cd = true
|
||||
script = ExtResource("1_xr2im")
|
||||
slot = &"primary"
|
||||
weapon = NodePath("MC255")
|
||||
team = 3
|
||||
|
||||
[node name="MC255" parent="." instance=ExtResource("2_nf8ho")]
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -3.0517578e-05, 0.25790405)
|
||||
shape = SubResource("BoxShape3D_477rq")
|
||||
|
||||
[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."]
|
||||
replication_config = SubResource("SceneReplicationConfig_ddvbd")
|
||||
|
||||
[node name="mc255" parent="." instance=ExtResource("3_nf8ho")]
|
||||
69
weapons/gun/mc/mc255.tscn
Normal file
69
weapons/gun/mc/mc255.tscn
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
[gd_scene load_steps=10 format=3 uid="uid://8ohlfmr5bp0k"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://e6lqknfl4ngt" path="res://systems/weapon_system/weapon_substate_machine.gd" id="1_uck67"]
|
||||
[ext_resource type="Script" uid="uid://ofv4e3dsfe8" path="res://weapons/gun/idle_state.gd" id="2_rkf02"]
|
||||
[ext_resource type="Script" uid="uid://cvueeftqbxb7r" path="res://weapons/gun/semi_pellet_shoot_state.gd" id="3_jk5g7"]
|
||||
[ext_resource type="Script" uid="uid://hmekwp8444ao" path="res://weapons/gun/reload_state.gd" id="4_fs8hh"]
|
||||
[ext_resource type="Script" uid="uid://bmj0bwy2tlian" path="res://weapons/gun/intro_state.gd" id="5_3ok4b"]
|
||||
|
||||
[sub_resource type="Curve" id="Curve_cmn6f"]
|
||||
_limits = [0.0, 0.1, 0.0, 20.0]
|
||||
_data = [Vector2(0, 0.1), 0.0, 0.0, 0, 0, Vector2(20, 0.1), -2.2834061e-05, 0.0, 0, 0]
|
||||
point_count = 2
|
||||
metadata/_snap_enabled = true
|
||||
metadata/_snap_count = 8
|
||||
|
||||
[sub_resource type="Curve" id="Curve_jk5g7"]
|
||||
|
||||
[sub_resource type="Curve" id="Curve_bwg3m"]
|
||||
_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(0.25301203, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0]
|
||||
point_count = 3
|
||||
|
||||
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_bwg3m"]
|
||||
properties/0/path = NodePath(".:ammo")
|
||||
properties/0/spawn = true
|
||||
properties/0/replication_mode = 2
|
||||
properties/1/path = NodePath(".:remaining_ammo")
|
||||
properties/1/spawn = true
|
||||
properties/1/replication_mode = 2
|
||||
|
||||
[node name="MC255" type="Node" node_paths=PackedStringArray("enter_state")]
|
||||
script = ExtResource("1_uck67")
|
||||
animation_prefix = &"baked_mc_"
|
||||
weapon_gid = &"mc"
|
||||
max_ammo = 5
|
||||
ammo_mags = 8
|
||||
speed_modifier = 0.9
|
||||
slot = &"primary"
|
||||
enter_state = NodePath("Intro")
|
||||
metadata/_custom_type_script = "uid://e6lqknfl4ngt"
|
||||
|
||||
[node name="Idle" type="Node" parent="."]
|
||||
script = ExtResource("2_rkf02")
|
||||
|
||||
[node name="Shoot" type="Node" parent="." node_paths=PackedStringArray("fire_timer")]
|
||||
script = ExtResource("3_jk5g7")
|
||||
vertical_curve = SubResource("Curve_cmn6f")
|
||||
horizontal_curve = SubResource("Curve_jk5g7")
|
||||
damage_reduction_curve = SubResource("Curve_bwg3m")
|
||||
torso_total_damage = 100
|
||||
head_total_damage = 150
|
||||
limb_total_damage = 70
|
||||
arc = 0.08726646259971647
|
||||
max_pellets = 30
|
||||
min_pellets = 30
|
||||
shoot_distance = 40.0
|
||||
fire_timer = NodePath("../FireTimer")
|
||||
|
||||
[node name="Reload" type="Node" parent="."]
|
||||
script = ExtResource("4_fs8hh")
|
||||
|
||||
[node name="Intro" type="Node" parent="."]
|
||||
script = ExtResource("5_3ok4b")
|
||||
|
||||
[node name="FireTimer" type="Timer" parent="."]
|
||||
wait_time = 2.0
|
||||
one_shot = true
|
||||
|
||||
[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."]
|
||||
replication_config = SubResource("SceneReplicationConfig_bwg3m")
|
||||
55
weapons/gun/semi_pellet_shoot_state.gd
Normal file
55
weapons/gun/semi_pellet_shoot_state.gd
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
extends WeaponState
|
||||
|
||||
@export var vertical_curve: Curve
|
||||
@export var horizontal_curve: Curve
|
||||
@export var damage_reduction_curve: Curve
|
||||
|
||||
@export var emptyable: bool
|
||||
@export var torso_total_damage: int
|
||||
@export var head_total_damage: int
|
||||
@export var limb_total_damage: int
|
||||
@export_range(0,179,0.01,"radians_as_degrees") var arc: float
|
||||
@export_range(1,20,1,"or_greater") var max_pellets: int = 1
|
||||
@export_range(1,20,1,"or_greater") var min_pellets: int = 1
|
||||
@export var shoot_distance: float = 100
|
||||
|
||||
@export var fire_timer: Timer
|
||||
|
||||
var bullets_shot: int = 0
|
||||
|
||||
func _enter() -> void:
|
||||
fire()
|
||||
machine.animation_player.animation_finished.connect(on_animation_finished)
|
||||
|
||||
func _exit() -> void:
|
||||
bullets_shot = 0
|
||||
machine.animation_player.animation_finished.disconnect(on_animation_finished)
|
||||
|
||||
func on_animation_finished(animation):
|
||||
if animation == with_morphems("shoot"):
|
||||
transition.emit("Idle")
|
||||
|
||||
func _use_begin() -> void:
|
||||
if fire_timer.time_left > 0:
|
||||
return
|
||||
fire()
|
||||
|
||||
func fire() -> void:
|
||||
if machine.ammo == 0 or fire_timer.time_left > 0:
|
||||
return
|
||||
machine.ammo -= 1
|
||||
bullets_shot += 1
|
||||
|
||||
machine.animation_player.stop()
|
||||
machine.animation_player.play(with_morphems("shoot"))
|
||||
|
||||
if is_multiplayer_authority():
|
||||
var pellets: int = randi_range(min_pellets,max_pellets)
|
||||
Session.shoot_pellets(int(machine.player.name),pellets,limb_total_damage,torso_total_damage,head_total_damage,shoot_distance,arc,damage_reduction_curve)
|
||||
machine.player.get_node("ShootAudio").multiplayer_play()
|
||||
|
||||
fire_timer.start()
|
||||
machine.player_camera.recoil(horizontal_curve.sample(bullets_shot),vertical_curve.sample(bullets_shot))
|
||||
|
||||
func with_morphems(animation):
|
||||
return machine.animation_prefix + ((animation+"_empty") if emptyable and machine.ammo == 0 else animation)
|
||||
1
weapons/gun/semi_pellet_shoot_state.gd.uid
Normal file
1
weapons/gun/semi_pellet_shoot_state.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cvueeftqbxb7r
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
[ext_resource type="Script" uid="uid://e6lqknfl4ngt" path="res://systems/weapon_system/weapon_substate_machine.gd" id="1_g7s1i"]
|
||||
[ext_resource type="Script" uid="uid://ofv4e3dsfe8" path="res://weapons/gun/idle_state.gd" id="2_cmn6f"]
|
||||
[ext_resource type="Script" uid="uid://vj13r83l3xyq" path="res://weapons/gun/semi_auto_shoot_state.gd" id="3_016ti"]
|
||||
[ext_resource type="Script" uid="uid://vj13r83l3xyq" path="res://weapons/gun/semi_shoot_state.gd" id="3_016ti"]
|
||||
[ext_resource type="Script" uid="uid://hmekwp8444ao" path="res://weapons/gun/reload_state.gd" id="4_hoqxt"]
|
||||
[ext_resource type="Script" uid="uid://bmj0bwy2tlian" path="res://weapons/gun/intro_state.gd" id="5_ud1dr"]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue