diff --git a/Content/Items/Weapons/DuneWyrm/Timekeeper.cs b/Content/Items/Weapons/DuneWyrm/Timekeeper.cs new file mode 100644 index 0000000..b8220d7 --- /dev/null +++ b/Content/Items/Weapons/DuneWyrm/Timekeeper.cs @@ -0,0 +1,41 @@ +using Decimation.Lib.Items; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace Decimation.Content.Items.Weapons.DuneWyrm +{ + public class Timekeeper : DecimationWeapon + { + protected override string ItemName => "The Timekeeper"; + protected override int Damages => 45; + protected override DamageType DamagesType => DamageType.Ranged; + protected override int ProjectileId => ModContent.ProjectileType(); + protected override int AmmoId => AmmoID.Bullet; + + protected override void InitWeapon() + { + item.width = 58; + item.height = 22; + item.useStyle = ItemUseStyleID.HoldingOut; + item.useTime = 10; + item.useAnimation = 10; + item.crit = 6; + item.shootSpeed = 10f; + } + + public override bool ConsumeAmmo(Player player) + { + return !Main.rand.NextBool(10); + } + + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, + ref float knockBack) + { + type = ProjectileId; + + return true; + } + } +} \ No newline at end of file diff --git a/Content/Items/Weapons/DuneWyrm/Timekeeper.png b/Content/Items/Weapons/DuneWyrm/Timekeeper.png new file mode 100644 index 0000000..dbf50f8 Binary files /dev/null and b/Content/Items/Weapons/DuneWyrm/Timekeeper.png differ diff --git a/Content/Projectiles/DuneWyrm/Timekeeper.cs b/Content/Projectiles/DuneWyrm/Timekeeper.cs new file mode 100644 index 0000000..907a1e4 --- /dev/null +++ b/Content/Projectiles/DuneWyrm/Timekeeper.cs @@ -0,0 +1,110 @@ +using System; +using Decimation.Lib.Items; +using Microsoft.Xna.Framework; +using Terraria; + +namespace Decimation.Content.Projectiles.DuneWyrm +{ + public class Timekeeper : DecimationProjectile + { + protected override int Damages => 45; + protected override DecimationWeapon.DamageType DamageType => DecimationWeapon.DamageType.Ranged; + + private int Sibling + { + get => (int) projectile.localAI[0]; + set => projectile.localAI[0] = value; + } + + private float Rotation + { + get => projectile.localAI[1]; + set => projectile.localAI[1] = value; + } + + private Projectile SiblingProjectile => Main.projectile[Sibling]; + + private int Counter + { + get => (int) projectile.ai[0]; + set => projectile.ai[0] = value; + } + + private bool IsChild => projectile.ai[1] == 1f; + + private float Speed { get; set; } + private bool Initialization { get; set; } = true; + + protected override void Init() + { + projectile.width = 12; + projectile.height = 12; + projectile.penetrate = -1; + projectile.aiStyle = -1; + projectile.timeLeft = 600; + + Sibling = -1; + } + + public override bool PreKill(int timeLeft) + { + SiblingProjectile.Kill(); + + return true; + } + + public override void Kill(int timeLeft) + { + for (int i = 0; i < 8; i++) + { + Dust.NewDust(projectile.position, projectile.width, projectile.height, 135, 0, + 0, 100, default, 4f * projectile.scale); + } + } + + public override void AI() + { + if (!IsChild) + { + if (Sibling == -1) + { + projectile.position.Y -= 8f; + + Rotation = projectile.velocity.ToRotation(); + Speed = projectile.velocity.Length(); + + Sibling = Projectile.NewProjectile(projectile.position, new Vector2(Speed, Rotation), + projectile.type, + projectile.damage, projectile.knockBack, projectile.owner, 0, 1); + } + + // Parent + Vector2 parentVelocity = new Vector2(0, 1) * (float) (1.5f * Math.Sin(Counter * (1 / 8f))); + parentVelocity.X = Speed; + projectile.velocity = parentVelocity.RotatedBy(Rotation); + + // Sibling + Vector2 siblingVelocity = parentVelocity * new Vector2(1, -1); + SiblingProjectile.velocity = siblingVelocity.RotatedBy(Rotation); + + if (Initialization) + { + Vector2 offset = new Vector2(projectile.position.X - SiblingProjectile.position.X, -16); + projectile.velocity += offset.RotatedBy(Rotation); + + Initialization = false; + } + + Counter++; + } + else if (IsChild && Sibling == -1) + { + Sibling = projectile.owner; + } + + Lighting.AddLight(projectile.Center, 0f, 0f, 1f); + Dust.NewDust(projectile.position, projectile.width, projectile.height, 135, projectile.velocity.X * 0.2f, + projectile.velocity.Y * 0.2f, 100, default, 2f * projectile.scale); + } + } +} \ No newline at end of file diff --git a/Content/Projectiles/DuneWyrm/Timekeeper.png b/Content/Projectiles/DuneWyrm/Timekeeper.png new file mode 100644 index 0000000..1fc5f35 Binary files /dev/null and b/Content/Projectiles/DuneWyrm/Timekeeper.png differ diff --git a/Lib/Items/DecimationWeapon.cs b/Lib/Items/DecimationWeapon.cs index 742e278..e234fd9 100644 --- a/Lib/Items/DecimationWeapon.cs +++ b/Lib/Items/DecimationWeapon.cs @@ -63,7 +63,7 @@ namespace Decimation.Lib.Items if (AmmoName != null) item.useAmmo = ItemUtils.GetIdFromName(AmmoName, typeof(Item), VanillaAmmo); - if (AmmoId > -1) item.ammo = AmmoId; + if (AmmoId > -1) item.useAmmo = AmmoId; if (item.melee) item.noMelee = false; }