diff --git a/prefab/weapons/StaffNecromancy.tscn b/prefab/weapons/StaffNecromancy.tscn
index 86278c7..602315c 100644
--- a/prefab/weapons/StaffNecromancy.tscn
+++ b/prefab/weapons/StaffNecromancy.tscn
@@ -16,7 +16,10 @@ size = Vector2(49, 5.25)
[node name="StaffOfTheUndead" type="RigidBody2D"]
collision_layer = 8
collision_mask = 34
+angular_damp = -1.0
script = ExtResource("1_w8hhv")
+OffsetAngle = 0.523
+NumberOfProjectiles = 15.0
ProjectileScenes = [ExtResource("2_34250"), ExtResource("3_hk5nr")]
Sequentially = true
FiringIntervalAsMillisecond = 300
diff --git a/scripts/weapon/ProjectileWeapon.cs b/scripts/weapon/ProjectileWeapon.cs
index 679e12b..0e65302 100644
--- a/scripts/weapon/ProjectileWeapon.cs
+++ b/scripts/weapon/ProjectileWeapon.cs
@@ -22,6 +22,18 @@ public partial class ProjectileWeapon : WeaponTemplate
///
private Marker2D? _marker2D;
+ ///
+ /// Scattering radians
+ /// 散射弧度
+ ///
+ [Export] protected float OffsetAngle;
+
+ ///
+ /// The number of projectiles fired at once
+ /// 一次可以发射多少个子弹
+ ///
+ [Export] protected float NumberOfProjectiles = 1;
+
[Export] protected PackedScene[] ProjectileScenes { get; set; } = [];
///
@@ -57,6 +69,24 @@ public partial class ProjectileWeapon : WeaponTemplate
}
}
+ ///
+ /// GetRandomAngle
+ /// 获取随机的偏移弧度
+ ///
+ ///
+ private float GetRandomAngle()
+ {
+ if (OffsetAngle == 0)
+ {
+ //If the offset angle is 0, then return 0
+ //弧度为0,不用偏移。
+ return 0;
+ }
+
+ var min = -OffsetAngle / 2;
+ return min + RandomUtils.Instance.NextSingle() * OffsetAngle;
+ }
+
protected override void DoFire(Node2D? owner, Vector2 enemyGlobalPosition)
{
@@ -89,21 +119,25 @@ public partial class ProjectileWeapon : WeaponTemplate
//Get the first projectile
//获取第一个抛射体
var projectileScene = GetNextProjectileScene();
- var projectile = NodeUtils.InstantiatePackedScene(projectileScene);
- if (projectile == null) return;
- if (Config.IsDebug())
+ for (int i = 0; i < NumberOfProjectiles; i++)
{
- var nodeSpawnOnKillCharacterDecorator = new NodeSpawnOnKillCharacterDecorator
+ var projectile = NodeUtils.InstantiatePackedScene(projectileScene);
+ if (projectile == null) return;
+ if (Config.IsDebug())
{
- DefaultParentNode = this,
- PackedScenePath = "res://prefab/entitys/BlackenedAboriginalWarrior.tscn"
- };
- projectile.AddProjectileDecorator(nodeSpawnOnKillCharacterDecorator);
- }
+ var nodeSpawnOnKillCharacterDecorator = new NodeSpawnOnKillCharacterDecorator
+ {
+ DefaultParentNode = this,
+ PackedScenePath = "res://prefab/entitys/BlackenedAboriginalWarrior.tscn"
+ };
+ projectile.AddProjectileDecorator(nodeSpawnOnKillCharacterDecorator);
+ }
- NodeUtils.CallDeferredAddChild(GameSceneNodeHolder.ProjectileContainer, projectile);
- projectile.Owner = owner;
- projectile.Velocity = (enemyGlobalPosition - _marker2D.GlobalPosition).Normalized() * projectile.Speed;
- projectile.Position = _marker2D.GlobalPosition;
+ NodeUtils.CallDeferredAddChild(GameSceneNodeHolder.ProjectileContainer, projectile);
+ projectile.Owner = owner;
+ projectile.Velocity =
+ ((enemyGlobalPosition - _marker2D.GlobalPosition).Normalized() * projectile.Speed).Rotated(GetRandomAngle());
+ projectile.Position = _marker2D.GlobalPosition;
+ }
}
}
\ No newline at end of file