using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; using Terraria.Audio; namespace CalamityMod.Projectiles.Ranged { public class UniversalGenesisStar : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Ranged"; public override void SetStaticDefaults() { ProjectileID.Sets.TrailCacheLength[Projectile.type] = 6; ProjectileID.Sets.TrailingMode[Projectile.type] = 0; } public override void SetDefaults() { Projectile.width = 22; Projectile.height = 20; Projectile.friendly = true; Projectile.DamageType = DamageClass.Ranged; Projectile.alpha = 50; Projectile.tileCollide = false; Projectile.penetrate = 5; Projectile.timeLeft = 180; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 10; } public override void AI() { if (Projectile.soundDelay == 0 && Projectile.ai[0] == 0f) { Projectile.soundDelay = 20 + Main.rand.Next(40); if (Main.rand.NextBool(5)) { SoundEngine.PlaySound(SoundID.Item9, Projectile.position); } } Projectile.rotation += (Math.Abs(Projectile.velocity.X) + Math.Abs(Projectile.velocity.Y)) * 0.01f * Projectile.direction; if (Main.rand.NextBool(48) && Main.netMode != NetmodeID.Server) { int idx = Gore.NewGore(Projectile.GetSource_FromAI(), Projectile.Center, Projectile.velocity * 0.2f, 16, 1f); Main.gore[idx].velocity *= 0.66f; Main.gore[idx].velocity += Projectile.velocity * 0.3f; } if (Main.rand.NextBool(10)) { Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 173, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f, 150, default, 1.2f); } if (Main.rand.NextBool(20) && Main.netMode != NetmodeID.Server) { Gore.NewGore(Projectile.GetSource_FromAI(), Projectile.position, new Vector2(Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f), Main.rand.Next(16, 18), 1f); } } public override Color? GetAlpha(Color lightColor) => new Color(200, 200, 200, Projectile.alpha); public override bool PreDraw(ref Color lightColor) { if (Projectile.ai[1] == 1f) Projectile.DrawStarTrail(Color.Blue, Color.White); //Draw the actual projectile CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1); return false; } public override void Kill(int timeLeft) { Projectile.position += Projectile.Size; Projectile.width = 50; Projectile.height = 50; Projectile.position -= Projectile.Size; for (int i = 0; i < 5; i++) { int idx = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 16, 0f, 0f, 100, default, 1.2f); Main.dust[idx].velocity *= 3f; if (Main.rand.NextBool(2)) { Main.dust[idx].scale = 0.5f; Main.dust[idx].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } if (Main.netMode != NetmodeID.Server) { for (int i = 0; i < 3; i++) { Gore.NewGore(Projectile.GetSource_Death(), Projectile.position, Projectile.velocity * 0.05f, Main.rand.Next(16, 18), 1f); } } } } }