using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; using Terraria.Audio; using Microsoft.Xna.Framework.Graphics; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; namespace CalamityMod.Projectiles.Magic { public class PoseidonTyphoon : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Magic"; public override void SetDefaults() { Projectile.width = 30; Projectile.height = 30; Projectile.friendly = true; Projectile.DamageType = DamageClass.Magic; Projectile.penetrate = 10; //randomized in the item file now, penetrates 4 to 10 times Projectile.timeLeft = 300; Projectile.ignoreWater = true; Projectile.scale = 1.6f; } public override void AI() { Projectile.rotation += Projectile.velocity.X * 0.01f; Projectile.rotation = MathHelper.WrapAngle(Projectile.rotation); Lighting.AddLight(Projectile.Center, 0, (255 - Projectile.alpha) * 0.7f / 255f, (255 - Projectile.alpha) / 255f); CalamityUtils.HomeInOnNPC(Projectile, !Projectile.tileCollide, 600f, 6f, 30f); } 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); public override void Kill(int timeLeft) { SoundEngine.PlaySound(SoundID.Item10, Projectile.position); } public override Color? GetAlpha(Color lightColor) { return new Color(200, 200, 200, 0); } public override bool OnTileCollide(Vector2 oldVelocity) { Projectile.penetrate--; if (Projectile.penetrate <= 0) { Projectile.Kill(); } else { if (Projectile.velocity.X != oldVelocity.X) { Projectile.velocity.X = -oldVelocity.X; } if (Projectile.velocity.Y != oldVelocity.Y) { Projectile.velocity.Y = -oldVelocity.Y; } } return false; } public override bool PreDraw(ref Color lightColor) { Texture2D texture = ModContent.Request(Texture).Value; Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition, null, lightColor, Projectile.rotation, texture.Size() / 2f, Projectile.scale, SpriteEffects.None, 0); return false; } } }