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 BrimstoneSwordProj : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Melee"; public override string Texture => "CalamityMod/Items/Weapons/Melee/BrimstoneSword"; public override void SetDefaults() { Projectile.width = 10; Projectile.height = 10; Projectile.friendly = true; Projectile.penetrate = 5; Projectile.aiStyle = ProjAIStyleID.StickProjectile; Projectile.timeLeft = 600; AIType = ProjectileID.BoneJavelin; Projectile.DamageType = DamageClass.Melee; Projectile.MaxUpdates = 2; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 10 * Projectile.MaxUpdates; } 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, NPC.HitInfo hit, int damageDone) { target.AddBuff(ModContent.BuffType(), 180); if (Main.myPlayer == Projectile.owner && Projectile.numHits == 0) { Projectile.NewProjectile(Projectile.GetSource_FromThis(), target.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 0.5), hit.Knockback, Projectile.owner); } if (Projectile.damage > 1) Projectile.damage = (int)(Projectile.damage * 0.6); else Projectile.Kill(); } } }