using Microsoft.Xna.Framework; using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; using Terraria.Audio; namespace CalamityMod.Projectiles.Rogue { public class TotalityTar : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Rogue"; public override void SetDefaults() { Projectile.width = 14; Projectile.height = 14; Projectile.friendly = true; Projectile.penetrate = -1; Projectile.timeLeft = 30; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 10; Projectile.DamageType = RogueDamageClass.Instance; } public override void AI() { if (Projectile.velocity.X != Projectile.velocity.X) { Projectile.velocity.X *= -0.1f; } if (Projectile.velocity.X != Projectile.velocity.X) { Projectile.velocity.X *= -0.5f; } if (Projectile.velocity.Y != Projectile.velocity.Y && Projectile.velocity.Y > 1f) { Projectile.velocity.Y *= -0.5f; } Projectile.ai[0] += 1f; if (Projectile.ai[0] > 5f) { Projectile.ai[0] = 5f; if (Projectile.velocity.Y == 0f && Projectile.velocity.X != 0f) { Projectile.velocity.X *= 0.97f; if (Math.Abs(Projectile.velocity.X) < 0.01f) { Projectile.velocity.X = 0f; Projectile.netUpdate = true; } } Projectile.velocity.Y += 0.2f; } Projectile.rotation += Projectile.velocity.X * 0.1f; if (Projectile.velocity.Y < 0.25f && Projectile.velocity.Y > 0.15f) { Projectile.velocity.X *= 0.8f; } Projectile.rotation = -Projectile.velocity.X * 0.05f; if (Projectile.velocity.Y > 16f) { Projectile.velocity.Y = 16f; } } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { if (target.buffImmune[BuffID.Oiled]) { target.buffImmune[BuffID.Oiled] = false; } target.AddBuff(BuffID.Oiled, 600); target.AddBuff(BuffID.OnFire3, 300); } public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(BuffID.OnFire3, 300); public override void Kill(int timeLeft) { SoundEngine.PlaySound(SoundID.Item74, Projectile.position); Vector2 vector2 = new Vector2(20f, 20f); for (int index = 0; index < 3; ++index) Dust.NewDust(Projectile.Center - vector2 / 2f, (int) vector2.X, (int) vector2.Y, 191, 0.0f, 0.0f, 0, Color.Red, 1f); for (int index1 = 0; index1 < 5; ++index1) { int index2 = Dust.NewDust(Projectile.Center - vector2 / 2f, (int) vector2.X, (int) vector2.Y, 31, 0.0f, 0.0f, 100, new Color(), 1.5f); Dust dust = Main.dust[index2]; dust.velocity *= 1.4f; } for (int index1 = 0; index1 < 10; ++index1) { int index2 = Dust.NewDust(Projectile.Center - vector2 / 2f, (int) vector2.X, (int) vector2.Y, 6, 0.0f, 0.0f, 100, new Color(), 2.5f); Dust dust1 = Main.dust[index2]; dust1.noGravity = true; dust1.velocity *= 5f; int index3 = Dust.NewDust(Projectile.Center - vector2 / 2f, (int) vector2.X, (int) vector2.Y, 6, 0.0f, 0.0f, 100, new Color(), 1.5f); Dust dust2 = Main.dust[index3]; dust2.velocity *= 3f; } int fireAmt = Main.rand.Next(2, 4); if (Projectile.owner == Main.myPlayer) { for (int f = 0; f < fireAmt; f++) { Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), Projectile.damage, 1f, Main.myPlayer, 0f, 0f); } } } } }