using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Projectiles.Healing; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { public class Exocomet : ModProjectile { public override void SetStaticDefaults() { DisplayName.SetDefault("Comet"); Main.projFrames[projectile.type] = 5; ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; ProjectileID.Sets.TrailingMode[projectile.type] = 0; } public override void SetDefaults() { projectile.width = 12; projectile.height = 12; projectile.friendly = true; projectile.ignoreWater = true; projectile.tileCollide = false; projectile.melee = true; projectile.penetrate = 1; projectile.alpha = 50; } public override void AI() { projectile.frameCounter++; if (projectile.frameCounter > 5) { projectile.frame++; projectile.frameCounter = 0; } if (projectile.frame > 4) { projectile.frame = 0; } float num953 = 100f * projectile.ai[1]; //100 float scaleFactor12 = 20f * projectile.ai[1]; //5 float num954 = 40f; if (projectile.timeLeft > 30 && projectile.alpha > 0) { projectile.alpha -= 25; } if (projectile.timeLeft > 30 && projectile.alpha < 128 && Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) { projectile.alpha = 128; } if (projectile.alpha < 0) { projectile.alpha = 0; } if (projectile.alpha < 40) { int num309 = Dust.NewDust(new Vector2(projectile.position.X - projectile.velocity.X * 4f + 2f, projectile.position.Y + 2f - projectile.velocity.Y * 4f), 8, 8, 107, projectile.oldVelocity.X, projectile.oldVelocity.Y, 100, new Color(0, 255, 255), 0.5f); Main.dust[num309].velocity *= -0.25f; num309 = Dust.NewDust(new Vector2(projectile.position.X - projectile.velocity.X * 4f + 2f, projectile.position.Y + 2f - projectile.velocity.Y * 4f), 8, 8, 107, projectile.oldVelocity.X, projectile.oldVelocity.Y, 100, new Color(0, 255, 255), 0.5f); Main.dust[num309].velocity *= -0.25f; Main.dust[num309].position -= projectile.velocity * 0.5f; } projectile.rotation = projectile.velocity.ToRotation() + 1.57079637f; Lighting.AddLight(projectile.Center, 0f, 0.5f, 0.5f); if (Main.player[projectile.owner].active && !Main.player[projectile.owner].dead) { if (projectile.Distance(Main.player[projectile.owner].Center) > num954) { Vector2 vector102 = projectile.DirectionTo(Main.player[projectile.owner].Center); if (vector102.HasNaNs()) { vector102 = Vector2.UnitY; } projectile.velocity = (projectile.velocity * (num953 - 1f) + vector102 * scaleFactor12) / num953; } } else { if (projectile.timeLeft > 30) { projectile.timeLeft = 30; } } } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(ModContent.BuffType(), 30); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(BuffID.CursedInferno, 120); target.AddBuff(BuffID.Frostburn, 120); target.AddBuff(BuffID.OnFire, 120); target.AddBuff(BuffID.Ichor, 120); if (target.type == NPCID.TargetDummy) { return; } float num = (float)damage * 0.01f; if ((int)num == 0) { return; } if (Main.player[Main.myPlayer].lifeSteal <= 0f) { return; } Main.player[Main.myPlayer].lifeSteal -= num; int num2 = projectile.owner; Projectile.NewProjectile(target.position.X, target.position.Y, 0f, 0f, ModContent.ProjectileType(), 0, 0f, projectile.owner, (float)num2, num); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { CalamityGlobalProjectile.DrawCenteredAndAfterimage(projectile, lightColor, ProjectileID.Sets.TrailingMode[projectile.type], 1); return false; } public override Color? GetAlpha(Color lightColor) { return new Color(0, 255, 255, projectile.alpha); } public override void Kill(int timeLeft) { Main.PlaySound(29, (int)projectile.position.X, (int)projectile.position.Y, 103, 1f, 0f); projectile.position = projectile.Center; projectile.width = projectile.height = 80; projectile.position.X = projectile.position.X - (float)(projectile.width / 2); projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); for (int num193 = 0; num193 < 2; num193++) { Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); } for (int num194 = 0; num194 < 20; num194++) { int num195 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); Main.dust[num195].noGravity = true; Main.dust[num195].velocity *= 3f; num195 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); Main.dust[num195].velocity *= 2f; Main.dust[num195].noGravity = true; } } } }