using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { public class SylvanSlash : ModProjectile { public override void SetStaticDefaults() { DisplayName.SetDefault("Slash"); } public override void SetDefaults() { projectile.width = 30; projectile.height = 30; aiType = 348; projectile.friendly = true; projectile.ignoreWater = true; projectile.Calamity().rogue = true; projectile.penetrate = 2; projectile.alpha = 120; projectile.timeLeft = 200; ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; ProjectileID.Sets.TrailingMode[projectile.type] = 1; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; projectile.tileCollide = false; } public override void AI() { if (projectile.localAI[0] == 0f) { Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 92); projectile.localAI[0] += 1f; } Lighting.AddLight(projectile.Center, 0.1f, 1f, 2f); projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f; projectile.velocity.Y += projectile.ai[0]; if (Main.rand.NextBool(2)) { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 111, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); } } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { if (projectile.timeLeft > 195) return false; CalamityGlobalProjectile.DrawCenteredAndAfterimage(projectile, lightColor, ProjectileID.Sets.TrailingMode[projectile.type], 2); return false; } public override Color? GetAlpha(Color lightColor) { return new Color(200, 200, 200, projectile.alpha); } public override void Kill(int timeLeft) { for (int k = 0; k < 3; k++) { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 111, projectile.oldVelocity.X * 0.5f, projectile.oldVelocity.Y * 0.5f); } } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { projectile.velocity *= 0.5f; } } }