using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { public class SupernovaSpike : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Rogue"; public override string Texture => "CalamityMod/Projectiles/Rogue/BallisticPoisonBombSpike"; private Color currentColor = Color.Black; public override void SetDefaults() { Projectile.width = 10; Projectile.height = 10; Projectile.alpha = 255; Projectile.friendly = true; Projectile.ignoreWater = true; Projectile.penetrate = 3; Projectile.alpha = 255; Projectile.extraUpdates = 2; Projectile.aiStyle = ProjAIStyleID.Nail; AIType = ProjectileID.NailFriendly; Projectile.DamageType = RogueDamageClass.Instance; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 5; } public override void AI() { Projectile.alpha -= 10; if (Projectile.alpha < 0) { Projectile.alpha = 0; } int num298 = Main.rand.NextBool(2) ? 107 : 234; if (Main.rand.NextBool(4)) { num298 = 269; } Projectile.localAI[1] += 1f; if (Projectile.localAI[1] > 4f) { int num469 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, num298, 0f, 0f, 100, default, 0.75f); Main.dust[num469].noGravity = true; Main.dust[num469].velocity *= 0f; } if (currentColor == Color.Black) { int startPoint = Main.rand.Next(6); Projectile.localAI[0] = startPoint; currentColor = GetStartingColor(startPoint); } Visuals(Projectile, ref currentColor); } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 180); public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), 180); internal static void Visuals(Projectile projectile, ref Color c) { CalamityUtils.IterateDisco(ref c, ref projectile.localAI[0], 15); Vector3 compositeColor = 0.1f * Color.White.ToVector3() + 0.05f * c.ToVector3(); Lighting.AddLight(projectile.Center, compositeColor); } internal static Color GetStartingColor(int startPoint = 0) { switch (startPoint) { default: return new Color(1f, 0f, 0f, 0f); // Color.Red case 1: return new Color(1f, 1f, 0f, 0f); // Color.Yellow case 2: return new Color(0f, 1f, 0f, 0f); // Color.Green case 3: return new Color(0f, 1f, 1f, 0f); // Color.Turquoise case 4: return new Color(0f, 0f, 1f, 0f); // Color.Blue case 5: return new Color(1f, 0f, 1f, 0f); // Color.Violet } } // This projectile is always fullbright. public override Color? GetAlpha(Color lightColor) { return currentColor; } public override void Kill(int timeLeft) { Projectile.position = Projectile.Center; Projectile.width = Projectile.height = 32; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); int num298 = Main.rand.NextBool(2) ? 107 : 234; if (Main.rand.NextBool(4)) { num298 = 269; } for (int num621 = 0; num621 < 2; num621++) { int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, num298, 0f, 0f, 100, default, 1.2f); Main.dust[num622].velocity *= 3f; if (Main.rand.NextBool(2)) { Main.dust[num622].scale = 0.5f; Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } for (int num623 = 0; num623 < 2; num623++) { int num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 6, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1.7f); Main.dust[num624].noGravity = true; Main.dust[num624].velocity *= 5f; num624 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 6, 0f, 0f, 100, new Color(Main.DiscoR, 203, 103), 1f); Main.dust[num624].velocity *= 2f; } } } }