Files
CalamityModPublic/Projectiles/Rogue/TurbulanceWindSlash.cs
T

82 lines
2.7 KiB
C#

using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Rogue
{
public class TurbulanceWindSlash : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Rogue";
public override void SetStaticDefaults()
{
Main.projFrames[Projectile.type] = 4;
ProjectileID.Sets.TrailCacheLength[Projectile.type] = 3;
ProjectileID.Sets.TrailingMode[Projectile.type] = 0;
}
public override void SetDefaults()
{
Projectile.width = 10;
Projectile.height = 10;
Projectile.friendly = true;
Projectile.penetrate = 1;
Projectile.extraUpdates = 0;
Projectile.alpha = 255;
Projectile.ignoreWater = true;
Projectile.DamageType = RogueDamageClass.Instance;
Projectile.timeLeft = 180;
}
public override bool? CanHitNPC(NPC target) => Projectile.timeLeft < 150 && target.CanBeChasedBy(Projectile);
public override void AI()
{
Projectile.velocity *= 0.99f;
if (Projectile.localAI[0] == 0f)
{
Projectile.scale += 0.005f;
}
if (Projectile.alpha > 0)
{
Projectile.alpha -= 30;
}
if (Projectile.alpha < 0)
{
Projectile.alpha = 0;
}
Projectile.frameCounter++;
if (Projectile.frameCounter > 1)
{
Projectile.frameCounter = 0;
Projectile.frame++;
if (Projectile.frame >= 4)
{
Projectile.frame = 0;
}
}
if (Projectile.ai[0] == 1f) //stealth strike
{
Projectile.rotation = Projectile.velocity.ToRotation() - MathHelper.PiOver2;
}
if (Projectile.ai[1] == 1f)
{
CalamityUtils.HomeInOnNPC(Projectile, !Projectile.tileCollide, Projectile.ai[0] == 1f ? 900f : 450f, 8f, 20f);
}
}
public override bool PreDraw(ref Color lightColor)
{
CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1);
return false;
}
public override void Kill(int timeLeft)
{
for (int k = 0; k < 10; k++)
{
Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, 187, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f, 100, new Color(53, Main.DiscoG, 255));
}
}
}
}