using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { public class BurningMeteor : ModProjectile { private int noTileHitCounter = 120; public override void SetStaticDefaults() { DisplayName.SetDefault("Meteor"); ProjectileID.Sets.TrailCacheLength[projectile.type] = 5; ProjectileID.Sets.TrailingMode[projectile.type] = 0; } public override void SetDefaults() { projectile.width = 46; projectile.height = 46; projectile.alpha = 150; projectile.friendly = true; projectile.melee = true; projectile.tileCollide = false; projectile.penetrate = 1; projectile.timeLeft = 180; projectile.ignoreWater = true; } public override void AI() { int randomToSubtract = Main.rand.Next(1, 4); noTileHitCounter -= randomToSubtract; if (noTileHitCounter == 0) { projectile.tileCollide = true; } if (projectile.soundDelay == 0) { projectile.soundDelay = 20 + Main.rand.Next(40); if (Main.rand.NextBool(5)) { Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 20); } } projectile.localAI[0] += 1f; if (projectile.localAI[0] == 30f) { projectile.localAI[0] = 0f; for (int l = 0; l < 12; l++) { Vector2 vector3 = Vector2.UnitX * (float)-(float)projectile.width / 2f; vector3 += -Vector2.UnitY.RotatedBy((double)((float)l * 3.14159274f / 6f), default) * new Vector2(8f, 16f); vector3 = vector3.RotatedBy((double)(projectile.rotation - 1.57079637f), default); int num9 = Dust.NewDust(projectile.Center, 0, 0, 244, 0f, 0f, 160, default, 1f); Main.dust[num9].scale = 1.1f; Main.dust[num9].noGravity = true; Main.dust[num9].position = projectile.Center + vector3; Main.dust[num9].velocity = projectile.velocity * 0.1f; Main.dust[num9].velocity = Vector2.Normalize(projectile.Center - projectile.velocity * 3f - Main.dust[num9].position) * 1.25f; } } projectile.alpha -= 15; int num58 = 150; if (projectile.Center.Y >= projectile.ai[1]) { num58 = 0; } if (projectile.alpha < num58) { projectile.alpha = num58; } projectile.rotation = projectile.velocity.ToRotation() - 1.57079637f; if (Main.rand.NextBool(36)) { Vector2 value3 = Vector2.UnitX.RotatedByRandom(1.5707963705062866).RotatedBy((double)projectile.velocity.ToRotation(), default); int num59 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f, 150, default, 1.2f); Main.dust[num59].velocity = value3 * 0.66f; Main.dust[num59].position = projectile.Center + value3 * 12f; } if (projectile.ai[1] == 1f) { projectile.light = 0.9f; if (Main.rand.NextBool(30)) { Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f, 150, default, 1.2f); } if (Main.rand.NextBool(60)) { Dust.NewDust(projectile.position, projectile.width, projectile.height, 244, projectile.velocity.X * 1.5f, projectile.velocity.Y * 1.5f, 150, default, 2f); } } Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0.75f / 255f, (255 - projectile.alpha) * 0.5f / 255f, (255 - projectile.alpha) * 0f / 255f); } public override void Kill(int timeLeft) { Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 20); for (int k = 0; k < 10; k++) { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 244, 0f, 0f); } } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(BuffID.Daybreak, 600); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { if (projectile.timeLeft > 175) return false; CalamityGlobalProjectile.DrawCenteredAndAfterimage(projectile, lightColor, ProjectileID.Sets.TrailingMode[projectile.type], 1); return false; } } }