using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { public class ProfanedSwordProj : ModProjectile { public override string Texture => "CalamityMod/Items/Weapons/Melee/BrimstoneSword"; private int explosionCount = 0; public override void SetStaticDefaults() { DisplayName.SetDefault("Profaned Sword"); } public override void SetDefaults() { Projectile.width = 10; Projectile.height = 10; Projectile.friendly = true; Projectile.penetrate = -1; Projectile.aiStyle = ProjAIStyleID.StickProjectile; Projectile.timeLeft = 600; AIType = ProjectileID.BoneJavelin; Projectile.DamageType = DamageClass.Melee; } public override void AI() { Projectile.rotation = (float)Math.Atan2((double)Projectile.velocity.Y, (double)Projectile.velocity.X) + MathHelper.ToRadians(45f); if (Main.rand.NextBool(4)) { Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f); } if (Projectile.spriteDirection == -1) { Projectile.rotation -= MathHelper.ToRadians(90f); } } public override bool PreDraw(ref Color lightColor) { if (Projectile.timeLeft > 595) return false; Texture2D tex = ModContent.Request(Texture).Value; Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, null, Projectile.GetAlpha(lightColor), Projectile.rotation, tex.Size() / 2f, Projectile.scale, SpriteEffects.None, 0); return false; } public override void Kill(int timeLeft) { for (int k = 0; k < 5; k++) { Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, Projectile.oldVelocity.X * 0.5f, Projectile.oldVelocity.Y * 0.5f); } } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.immune[Projectile.owner] = 6; target.AddBuff(ModContent.BuffType(), 180); if (Main.myPlayer == Projectile.owner) { if (explosionCount < 3) { Projectile.NewProjectile(Projectile.GetSource_FromThis(), target.Center.X, target.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(Projectile.damage * 0.5), knockback, Projectile.owner); explosionCount++; } } if (Projectile.damage > 1) Projectile.damage = (int)(Projectile.damage * 0.6); if (Projectile.damage <= 0) Projectile.damage = 1; } } }