Skip to content

Commit

Permalink
Merge pull request #40 from qvintopus/master
Browse files Browse the repository at this point in the history
add weapon damage
  • Loading branch information
nezvers authored Sep 9, 2024
2 parents ee8a2ed + eb7d911 commit 3fdd8a5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion scenes/weapons/gun.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[ext_resource type="PackedScene" uid="uid://do8p6aamuv46h" path="res://scenes/weapons/weapon.tscn" id="1_1sltl"]
[ext_resource type="PackedScene" uid="uid://dc8ulx4o43ue3" path="res://scenes/projectiles/bullet.tscn" id="2_4cp7v"]
[ext_resource type="Texture2D" uid="uid://ch26kh0j2e3ev" path="res://assets/images/weapon/gun_0.png" id="2_l47j0"]
[ext_resource type="Texture2D" uid="uid://c033lvuk0vrbu" path="res://assets/images/weapon/gun_0.png" id="2_l47j0"]
[ext_resource type="Resource" uid="uid://bsgm5x8805se7" path="res://resources/sounds/bullet.tres" id="3_k087s"]
[ext_resource type="Script" path="res://scripts/weapon_system/WeaponRotation.gd" id="4_3cx23"]
[ext_resource type="Script" path="res://scripts/weapon_system/projectile/ProjectileInterval.gd" id="4_a4uon"]
Expand Down Expand Up @@ -52,6 +52,7 @@ _data = {
projectile_scene = ExtResource("2_4cp7v")
sound_resource = ExtResource("3_k087s")
projectile_parent_reference = ExtResource("4_c42bw")
projectile_damage = 3

[node name="ProjectileInterval" type="Node" parent="." index="0" node_paths=PackedStringArray("weapon")]
script = ExtResource("4_a4uon")
Expand Down
3 changes: 2 additions & 1 deletion scenes/weapons/shotgun.tscn
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
[gd_scene load_steps=3 format=3 uid="uid://ghnv48d18ftl"]

[ext_resource type="PackedScene" uid="uid://bxf4p5yoajpdu" path="res://scenes/weapons/gun.tscn" id="1_xioje"]
[ext_resource type="Texture2D" uid="uid://cim2x6e31yf1g" path="res://assets/images/weapon/gun_1.png" id="2_hrbvp"]
[ext_resource type="Texture2D" uid="uid://c8xqcvug18kj" path="res://assets/images/weapon/gun_1.png" id="2_hrbvp"]

[node name="Shotgun" instance=ExtResource("1_xioje")]
projectile_angles = Array[float]([0.0, -5.0, 5.0, -10.0, 10.0])
projectile_damage = 1

[node name="ProjectileInterval" parent="." index="0"]
interval = 0.75
Expand Down
3 changes: 2 additions & 1 deletion scenes/weapons/sword.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[ext_resource type="PackedScene" uid="uid://bxf4p5yoajpdu" path="res://scenes/weapons/gun.tscn" id="1_tcvta"]
[ext_resource type="PackedScene" uid="uid://c6ys2qs8aeu8n" path="res://scenes/projectiles/sword_slash.tscn" id="2_x78ie"]
[ext_resource type="Texture2D" uid="uid://bapiaemh2qekg" path="res://assets/images/weapon/sword_0.png" id="3_ah0df"]
[ext_resource type="Texture2D" uid="uid://cnygfi3chigkm" path="res://assets/images/weapon/sword_0.png" id="3_ah0df"]

[sub_resource type="Animation" id="Animation_ku8ja"]
length = 0.001
Expand Down Expand Up @@ -67,6 +67,7 @@ _data = {

[node name="Sword" instance=ExtResource("1_tcvta")]
projectile_scene = ExtResource("2_x78ie")
projectile_damage = 4

[node name="ProjectileInterval" parent="." index="0"]
interval = 0.4
Expand Down
4 changes: 3 additions & 1 deletion scripts/weapon_system/Weapon.gd
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ signal prepare_spawn
## No angle, no projectile
## Use prepare_spawn signal to manipulate spread
@export var projectile_angles:Array[float] = [0.0]

## Used for defining projectile damage
@export var projectile_damage:int = 1

func _ready()->void:
set_enabled(enabled)
Expand All @@ -53,6 +54,7 @@ func spawn_projectile()->void:
for angle:float in projectile_angles:
var direction:Vector2 = mover.input_resource.aim_direction.rotated(deg_to_rad(angle))
var inst:Projectile2D = projectile_scene.instantiate()
inst.damage = projectile_damage
inst.direction = direction
inst.collision_mask = Bitwise.append_flags(inst.collision_mask, collision_mask)
projectile_parent_reference.node.add_child(inst)
Expand Down

0 comments on commit 3fdd8a5

Please sign in to comment.