using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; using Terraria.Audio; namespace CalamityMod.Projectiles.Summon { public class FrostMistFriendly : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Summon"; public override void SetStaticDefaults() { Main.projFrames[Projectile.type] = 8; ProjectileID.Sets.MinionShot[Projectile.type] = true; } public override void SetDefaults() { Projectile.width = 20; Projectile.height = 20; Projectile.friendly = true; Projectile.ignoreWater = true; Projectile.minion = true; Projectile.minionSlots = 0f; Projectile.penetrate = 1; Projectile.timeLeft = 300; Projectile.alpha = 255; Projectile.coldDamage = true; Projectile.DamageType = DamageClass.Summon; } public override void AI() { Projectile.frameCounter++; if (Projectile.frameCounter > 4) { Projectile.frame++; Projectile.frameCounter = 0; } if (Projectile.frame >= Main.projFrames[Projectile.type]) { Projectile.frame = 0; } if (Projectile.ai[1] == 0f) { for (int num621 = 0; num621 < 5; num621++) { int num622 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 187, 0f, 0f, 100, default, 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; } } Projectile.ai[1] = 1f; SoundEngine.PlaySound(SoundID.Item30, Projectile.position); } if (Projectile.localAI[0] == 0f) { Projectile.scale -= 0.02f; Projectile.alpha += 30; if (Projectile.alpha >= 250) { Projectile.alpha = 255; Projectile.localAI[0] = 1f; } } else if (Projectile.localAI[0] == 1f) { Projectile.scale += 0.02f; Projectile.alpha -= 30; if (Projectile.alpha <= 0) { Projectile.alpha = 0; Projectile.localAI[0] = 0f; } } int num103 = (int)Player.FindClosest(Projectile.Center, 1, 1); Projectile.ai[1] += 1f; if (Projectile.ai[1] < 110f && Projectile.ai[1] > 30f) { float scaleFactor2 = Projectile.velocity.Length(); Vector2 vector11 = Main.player[num103].Center - Projectile.Center; vector11.Normalize(); vector11 *= scaleFactor2; Projectile.velocity = (Projectile.velocity * 24f + vector11) / 25f; Projectile.velocity.Normalize(); Projectile.velocity *= scaleFactor2; } if (Projectile.ai[0] < 0f) { if (Projectile.velocity.Length() < 18f) { Projectile.velocity *= 1.02f; } } Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0f / 255f, (255 - Projectile.alpha) * 0.35f / 255f, (255 - Projectile.alpha) * 0.35f / 255f); } public override bool PreDraw(ref Color lightColor) { Texture2D texture2D13 = ModContent.Request(Texture).Value; int num214 = texture2D13.Height / Main.projFrames[Projectile.type]; int y6 = num214 * Projectile.frame; Main.EntitySpriteDraw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, num214)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)num214 / 2f), Projectile.scale, SpriteEffects.None, 0); return false; } public override Color? GetAlpha(Color lightColor) { return new Color(200, 200, 200, Projectile.alpha); } } }