Reworked weapons and projectiles

This commit is contained in:
2025-12-20 18:35:27 +03:00
parent 2ecc53416a
commit 8227e8bcf3
312 changed files with 2466 additions and 1376 deletions
@@ -0,0 +1,12 @@
class_name AbstractRailgunProjectile
extends AbstractDirectHitProjectile
@export_range(1, 10) var piercing: int = 1
func _process_hit_for_projectile(_collided_body: Node2D) -> void:
if piercing == 0:
queue_free()
else:
piercing -= 1
@@ -1,14 +1,13 @@
[gd_scene load_steps=11 format=3 uid="uid://bab3bopsw74cb"]
[gd_scene load_steps=8 format=3 uid="uid://bab3bopsw74cb"]
[ext_resource type="Script" uid="uid://n3h1e3pj02g0" path="res://game/entities/weapons/railgun/railgun_projectile.gd" id="1_hycpq"]
[ext_resource type="PackedScene" uid="uid://cdv5n4t47hr8i" path="res://game/entities/weapons/direct_hit__projectile.tscn" id="1_rfd1j"]
[ext_resource type="Script" uid="uid://bhqvk5cnjg5mv" path="res://game/health_system/damage/kinetic_damage.gd" id="3_wbdf3"]
[ext_resource type="Texture2D" uid="uid://oj86smpsipw4" path="res://images/projectiles.png" id="4_u82jm"]
[ext_resource type="Script" uid="uid://n3h1e3pj02g0" path="res://game/entities/weapons/railgun/abstract_railgun_projectile.gd" id="1_hycpq"]
[ext_resource type="PackedScene" uid="uid://cdv5n4t47hr8i" path="res://game/entities/weapons/abstract_direct_hit_projectile.tscn" id="1_rfd1j"]
[ext_resource type="Script" uid="uid://bhqvk5cnjg5mv" path="res://game/data/damage/kinetic_damage.gd" id="3_wbdf3"]
[ext_resource type="Texture2D" uid="uid://c6aixtu6lbfud" path="res://particle_textures/energy_small.tres" id="4_whmfh"]
[sub_resource type="Resource" id="Resource_u82jm"]
script = ExtResource("3_wbdf3")
value = 45
value = 50
metadata/_custom_type_script = "uid://bhqvk5cnjg5mv"
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_yedu2"]
@@ -26,19 +25,11 @@ turbulence_enabled = true
turbulence_noise_strength = 2.0
turbulence_noise_speed_random = 1.0
[sub_resource type="AtlasTexture" id="AtlasTexture_u82jm"]
atlas = ExtResource("4_u82jm")
region = Rect2(32, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_whmfh"]
atlas = ExtResource("4_u82jm")
region = Rect2(16, 0, 16, 16)
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_u82jm"]
radius = 1.0
height = 8.0
[node name="RailgunProjectile" instance=ExtResource("1_rfd1j")]
[node name="AbstractRailgunProjectile" instance=ExtResource("1_rfd1j")]
collision_layer = 0
collision_mask = 0
script = ExtResource("1_hycpq")
@@ -52,11 +43,5 @@ texture = ExtResource("4_whmfh")
lifetime = 0.4
process_material = SubResource("ParticleProcessMaterial_yedu2")
[node name="Sprite2D_Left" type="Sprite2D" parent="." index="1"]
texture = SubResource("AtlasTexture_u82jm")
[node name="Sprite2D_Right" type="Sprite2D" parent="." index="2"]
texture = SubResource("AtlasTexture_whmfh")
[node name="CollisionShape2D" parent="." index="3"]
[node name="CollisionShape2D" parent="." index="1"]
shape = SubResource("CapsuleShape2D_u82jm")
@@ -0,0 +1,26 @@
class_name AbstractRailgunWeapon
extends AbstractWeapon
@onready var sprite : AnimatedSprite2D = $AnimatedSprite2D
func _ready() -> void:
sprite.play(IDLE_ANIMATION)
func shoot(ship_velocity: Vector2) -> bool:
var is_shot := super.shoot(ship_velocity)
if is_shot:
sprite.play(SHOT_ANIMATION)
_can_shoot = false
return is_shot
func _on_animated_sprite_2d_animation_finished() -> void:
if sprite.animation == SHOT_ANIMATION:
sprite.play(RELOAD_ANIMATION)
else:
sprite.play(IDLE_ANIMATION)
_can_shoot = true
@@ -0,0 +1,15 @@
[gd_scene load_steps=4 format=3 uid="uid://do6h77gmnreho"]
[ext_resource type="PackedScene" uid="uid://1o2ta17yc5bp" path="res://game/entities/weapons/abstract_weapon.tscn" id="1_0nxvu"]
[ext_resource type="Script" uid="uid://drnofu4ium56e" path="res://game/entities/weapons/railgun/abstract_railgun_weapon.gd" id="1_5nhwg"]
[sub_resource type="SpriteFrames" id="SpriteFrames_26k3l"]
[node name="AbstractRailgunWeapon" instance=ExtResource("1_0nxvu")]
script = ExtResource("1_5nhwg")
type = 3
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="." index="0"]
sprite_frames = SubResource("SpriteFrames_26k3l")
[connection signal="animation_finished" from="AnimatedSprite2D" to="." method="_on_animated_sprite_2d_animation_finished"]
@@ -0,0 +1,2 @@
class_name EnemyRailgunProjectile
extends AbstractRailgunProjectile
@@ -0,0 +1 @@
uid://c8m661bctu67t
@@ -0,0 +1,18 @@
[gd_scene load_steps=5 format=3 uid="uid://cxcitgofg7nwm"]
[ext_resource type="PackedScene" uid="uid://bab3bopsw74cb" path="res://game/entities/weapons/railgun/abstract_railgun_projectile.tscn" id="1_gmlv2"]
[ext_resource type="Script" uid="uid://c8m661bctu67t" path="res://game/entities/weapons/railgun/enemy_railgun_projectile.gd" id="2_m4kh0"]
[ext_resource type="Texture2D" uid="uid://oj86smpsipw4" path="res://images/projectiles.png" id="3_p7y7c"]
[sub_resource type="AtlasTexture" id="AtlasTexture_u82jm"]
atlas = ExtResource("3_p7y7c")
region = Rect2(32, 0, 16, 16)
[node name="EnemyRailgunProjectile" instance=ExtResource("1_gmlv2")]
collision_layer = 16
collision_mask = 2
script = ExtResource("2_m4kh0")
direction = Vector2(-1, 0)
[node name="Sprite2D" type="Sprite2D" parent="." index="2"]
texture = SubResource("AtlasTexture_u82jm")
@@ -0,0 +1,2 @@
class_name EnemyRailgunWeapon
extends AbstractRailgunWeapon
@@ -0,0 +1 @@
uid://b0eg0ye5mx8ao
@@ -0,0 +1,93 @@
[gd_scene load_steps=14 format=3 uid="uid://chgf0tdlikwlb"]
[ext_resource type="PackedScene" uid="uid://do6h77gmnreho" path="res://game/entities/weapons/railgun/abstract_railgun_weapon.tscn" id="1_rp2u5"]
[ext_resource type="Script" uid="uid://b0eg0ye5mx8ao" path="res://game/entities/weapons/railgun/enemy_railgun_weapon.gd" id="2_0wswa"]
[ext_resource type="Texture2D" uid="uid://6hh66k8s4a1e" path="res://images/weapons.png" id="2_nfcq7"]
[ext_resource type="PackedScene" uid="uid://cxcitgofg7nwm" path="res://game/entities/weapons/railgun/enemy_railgun_projectile.tscn" id="3_0wswa"]
[sub_resource type="AtlasTexture" id="AtlasTexture_qxcog"]
atlas = ExtResource("2_nfcq7")
region = Rect2(0, 112, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_6uyey"]
atlas = ExtResource("2_nfcq7")
region = Rect2(96, 112, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_knads"]
atlas = ExtResource("2_nfcq7")
region = Rect2(128, 112, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_jxlhs"]
atlas = ExtResource("2_nfcq7")
region = Rect2(160, 112, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_o0am2"]
atlas = ExtResource("2_nfcq7")
region = Rect2(192, 112, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_gxvdx"]
atlas = ExtResource("2_nfcq7")
region = Rect2(224, 112, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_caa1b"]
atlas = ExtResource("2_nfcq7")
region = Rect2(32, 112, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_dshqd"]
atlas = ExtResource("2_nfcq7")
region = Rect2(64, 112, 32, 16)
[sub_resource type="SpriteFrames" id="SpriteFrames_nfcq7"]
resource_local_to_scene = true
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_qxcog")
}],
"loop": true,
"name": &"idle",
"speed": 10.0
}, {
"frames": [{
"duration": 6.0,
"texture": SubResource("AtlasTexture_6uyey")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_knads")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_jxlhs")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_o0am2")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_gxvdx")
}],
"loop": false,
"name": &"reloading",
"speed": 10.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_caa1b")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_dshqd")
}],
"loop": false,
"name": &"shot",
"speed": 10.0
}]
[node name="EnemyRailgunWeapon" instance=ExtResource("1_rp2u5")]
script = ExtResource("2_0wswa")
projectile_scene = ExtResource("3_0wswa")
[node name="AnimatedSprite2D" parent="." index="0"]
position = Vector2(-5, 0)
sprite_frames = SubResource("SpriteFrames_nfcq7")
animation = &"reloading"
[node name="Muzzle" parent="." index="1"]
position = Vector2(-11, 0)
@@ -0,0 +1,2 @@
class_name PlayerRailgunProjectile
extends AbstractRailgunProjectile
@@ -0,0 +1 @@
uid://51vaxrloo65r
@@ -0,0 +1,18 @@
[gd_scene load_steps=5 format=3 uid="uid://cgq4yobd2bq5l"]
[ext_resource type="PackedScene" uid="uid://bab3bopsw74cb" path="res://game/entities/weapons/railgun/abstract_railgun_projectile.tscn" id="1_xytr4"]
[ext_resource type="Script" uid="uid://51vaxrloo65r" path="res://game/entities/weapons/railgun/player_railgun_projectile.gd" id="2_sy2xa"]
[ext_resource type="Texture2D" uid="uid://oj86smpsipw4" path="res://images/projectiles.png" id="3_xm7by"]
[sub_resource type="AtlasTexture" id="AtlasTexture_whmfh"]
atlas = ExtResource("3_xm7by")
region = Rect2(16, 0, 16, 16)
[node name="PlayerRailgunProjectile" instance=ExtResource("1_xytr4")]
collision_layer = 8
collision_mask = 4
script = ExtResource("2_sy2xa")
direction = Vector2(1, 0)
[node name="Sprite2D" type="Sprite2D" parent="." index="3"]
texture = SubResource("AtlasTexture_whmfh")
@@ -0,0 +1,2 @@
class_name PlayerRailgunWeapon
extends AbstractRailgunWeapon
@@ -0,0 +1 @@
uid://dixftp6f0w8ss
@@ -0,0 +1,93 @@
[gd_scene load_steps=14 format=3 uid="uid://b745401et1bom"]
[ext_resource type="PackedScene" uid="uid://do6h77gmnreho" path="res://game/entities/weapons/railgun/abstract_railgun_weapon.tscn" id="1_1bsls"]
[ext_resource type="Script" uid="uid://dixftp6f0w8ss" path="res://game/entities/weapons/railgun/player_railgun_weapon.gd" id="2_cw8e6"]
[ext_resource type="Texture2D" uid="uid://6hh66k8s4a1e" path="res://images/weapons.png" id="2_yykqk"]
[ext_resource type="PackedScene" uid="uid://cgq4yobd2bq5l" path="res://game/entities/weapons/railgun/player_railgun_projectile.tscn" id="3_cw8e6"]
[sub_resource type="AtlasTexture" id="AtlasTexture_12cl3"]
atlas = ExtResource("2_yykqk")
region = Rect2(0, 96, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_q6uk7"]
atlas = ExtResource("2_yykqk")
region = Rect2(96, 96, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_ggjt2"]
atlas = ExtResource("2_yykqk")
region = Rect2(128, 96, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_jra8e"]
atlas = ExtResource("2_yykqk")
region = Rect2(160, 96, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_hqd47"]
atlas = ExtResource("2_yykqk")
region = Rect2(192, 96, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_hu0my"]
atlas = ExtResource("2_yykqk")
region = Rect2(224, 96, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_kjbu2"]
atlas = ExtResource("2_yykqk")
region = Rect2(32, 96, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_2g4rr"]
atlas = ExtResource("2_yykqk")
region = Rect2(64, 96, 32, 16)
[sub_resource type="SpriteFrames" id="SpriteFrames_yykqk"]
resource_local_to_scene = true
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_12cl3")
}],
"loop": true,
"name": &"idle",
"speed": 10.0
}, {
"frames": [{
"duration": 6.0,
"texture": SubResource("AtlasTexture_q6uk7")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ggjt2")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_jra8e")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_hqd47")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_hu0my")
}],
"loop": false,
"name": &"reloading",
"speed": 10.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_kjbu2")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_2g4rr")
}],
"loop": false,
"name": &"shot",
"speed": 10.0
}]
[node name="PlayerRailgunWeapon" instance=ExtResource("1_1bsls")]
script = ExtResource("2_cw8e6")
projectile_scene = ExtResource("3_cw8e6")
[node name="AnimatedSprite2D" parent="." index="0"]
position = Vector2(5, 0)
sprite_frames = SubResource("SpriteFrames_yykqk")
animation = &"idle"
[node name="Muzzle" parent="." index="1"]
position = Vector2(11, 0)
@@ -1,16 +0,0 @@
[gd_resource type="Resource" script_class="WeaponData" load_steps=3 format=3 uid="uid://dtpk5apjti4vh"]
[ext_resource type="Script" uid="uid://870r1efinhqd" path="res://game/world/data/weapon_data.gd" id="1_6lcn5"]
[ext_resource type="PackedScene" uid="uid://do6h77gmnreho" path="res://game/entities/weapons/railgun/railgun_weapon.tscn" id="1_cbt0i"]
[resource]
script = ExtResource("1_6lcn5")
id = "railgun"
name = "Railgun"
group = "kinetic"
description = "High damage (kinetic)
Low firerate
High velocity
Can pierce enemies"
scene = ExtResource("1_cbt0i")
metadata/_custom_type_script = "uid://870r1efinhqd"
@@ -1,32 +0,0 @@
class_name RailgunProjectile
extends DirectHitProjectile
@export_range(1, 10) var piercing: int = 1
@onready var sprite_left := $Sprite2D_Left
@onready var sprite_right := $Sprite2D_Right
func _ready() -> void:
super._ready()
_update_sprite(_velocity)
func _update_sprite(velocity: Vector2) -> void:
var angle := posmod(floor(rad_to_deg(velocity.angle())), 360)
if angle > 90 and angle < 270:
sprite_left.show()
sprite_right.hide()
else:
sprite_left.hide()
sprite_right.show()
func _process_hit_for_projectile(_collided_body: Node2D) -> void:
if piercing == 0:
queue_free()
else:
piercing -= 1
@@ -1,27 +0,0 @@
extends AbstractWeapon
@onready var sprite : AnimatedSprite2D = $AnimatedSprite2D
func set_belonging(belonging: Belonging) -> void:
super.set_belonging(belonging)
sprite.play(PREFIXES[_belonging] + IDLE_POSTFIX)
func shoot(ship_velocity: Vector2) -> bool:
var is_shot := super.shoot(ship_velocity)
if is_shot:
sprite.play(PREFIXES[_belonging] + SHOT_POSTFIX)
_can_shoot = false
return is_shot
func _on_animated_sprite_2d_animation_finished() -> void:
if sprite.animation.ends_with(SHOT_POSTFIX):
sprite.play(PREFIXES[_belonging] + RELOAD_POSTFIX)
else:
sprite.play(PREFIXES[_belonging] + IDLE_POSTFIX)
_can_shoot = true
@@ -1,167 +0,0 @@
[gd_scene load_steps=22 format=3 uid="uid://do6h77gmnreho"]
[ext_resource type="PackedScene" uid="uid://1o2ta17yc5bp" path="res://game/entities/weapons/abstract_weapon.tscn" id="1_0nxvu"]
[ext_resource type="Script" uid="uid://drnofu4ium56e" path="res://game/entities/weapons/railgun/railgun_weapon.gd" id="1_5nhwg"]
[ext_resource type="PackedScene" uid="uid://bab3bopsw74cb" path="res://game/entities/weapons/railgun/railgun_projectile.tscn" id="2_cbsia"]
[ext_resource type="Texture2D" uid="uid://6hh66k8s4a1e" path="res://images/weapons.png" id="4_qxcog"]
[sub_resource type="AtlasTexture" id="AtlasTexture_qxcog"]
atlas = ExtResource("4_qxcog")
region = Rect2(0, 112, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_6uyey"]
atlas = ExtResource("4_qxcog")
region = Rect2(96, 112, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_knads"]
atlas = ExtResource("4_qxcog")
region = Rect2(128, 112, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_jxlhs"]
atlas = ExtResource("4_qxcog")
region = Rect2(160, 112, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_o0am2"]
atlas = ExtResource("4_qxcog")
region = Rect2(192, 112, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_gxvdx"]
atlas = ExtResource("4_qxcog")
region = Rect2(224, 112, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_caa1b"]
atlas = ExtResource("4_qxcog")
region = Rect2(32, 112, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_dshqd"]
atlas = ExtResource("4_qxcog")
region = Rect2(64, 112, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_12cl3"]
atlas = ExtResource("4_qxcog")
region = Rect2(0, 96, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_q6uk7"]
atlas = ExtResource("4_qxcog")
region = Rect2(96, 96, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_ggjt2"]
atlas = ExtResource("4_qxcog")
region = Rect2(128, 96, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_jra8e"]
atlas = ExtResource("4_qxcog")
region = Rect2(160, 96, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_hqd47"]
atlas = ExtResource("4_qxcog")
region = Rect2(192, 96, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_hu0my"]
atlas = ExtResource("4_qxcog")
region = Rect2(224, 96, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_kjbu2"]
atlas = ExtResource("4_qxcog")
region = Rect2(32, 96, 32, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_2g4rr"]
atlas = ExtResource("4_qxcog")
region = Rect2(64, 96, 32, 16)
[sub_resource type="SpriteFrames" id="SpriteFrames_caa1b"]
resource_local_to_scene = true
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_qxcog")
}],
"loop": true,
"name": &"enemy_idle",
"speed": 10.0
}, {
"frames": [{
"duration": 6.0,
"texture": SubResource("AtlasTexture_6uyey")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_knads")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_jxlhs")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_o0am2")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_gxvdx")
}],
"loop": false,
"name": &"enemy_reloading",
"speed": 10.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_caa1b")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_dshqd")
}],
"loop": false,
"name": &"enemy_shot",
"speed": 10.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_12cl3")
}],
"loop": true,
"name": &"player_idle",
"speed": 10.0
}, {
"frames": [{
"duration": 6.0,
"texture": SubResource("AtlasTexture_q6uk7")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ggjt2")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_jra8e")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_hqd47")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_hu0my")
}],
"loop": false,
"name": &"player_reloading",
"speed": 10.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_kjbu2")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_2g4rr")
}],
"loop": false,
"name": &"player_shot",
"speed": 10.0
}]
[node name="RailgunWeapon" instance=ExtResource("1_0nxvu")]
script = ExtResource("1_5nhwg")
Projectile = ExtResource("2_cbsia")
type = 3
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="." index="0"]
position = Vector2(5, 0)
sprite_frames = SubResource("SpriteFrames_caa1b")
animation = &"enemy_reloading"
[node name="Muzzle" parent="." index="1"]
position = Vector2(11, 0)
[connection signal="animation_finished" from="AnimatedSprite2D" to="." method="_on_animated_sprite_2d_animation_finished"]