Added the Timekeeper (WIP).
- The double helix pattern is broken at some rotation. - The bullet sometimes get killed for no reason.
This commit is contained in:
parent
340d245cbd
commit
e2e8537a01
41
Content/Items/Weapons/DuneWyrm/Timekeeper.cs
Normal file
41
Content/Items/Weapons/DuneWyrm/Timekeeper.cs
Normal file
@ -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<Projectiles.DuneWyrm.Timekeeper>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
Content/Items/Weapons/DuneWyrm/Timekeeper.png
Normal file
BIN
Content/Items/Weapons/DuneWyrm/Timekeeper.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.4 KiB |
110
Content/Projectiles/DuneWyrm/Timekeeper.cs
Normal file
110
Content/Projectiles/DuneWyrm/Timekeeper.cs
Normal file
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
Content/Projectiles/DuneWyrm/Timekeeper.png
Normal file
BIN
Content/Projectiles/DuneWyrm/Timekeeper.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 256 B |
@ -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;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user