using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { public class AstrageldonLaser : ModProjectile { public override void SetStaticDefaults() { DisplayName.SetDefault("Astral Laser"); Main.projFrames[projectile.type] = 3; ProjectileID.Sets.TrailCacheLength[projectile.type] = 5; ProjectileID.Sets.TrailingMode[projectile.type] = 0; ProjectileID.Sets.MinionShot[projectile.type] = true; } public override void SetDefaults() { projectile.width = 10; projectile.height = 10; projectile.friendly = true; projectile.minion = true; projectile.ignoreWater = true; projectile.alpha = 255; projectile.penetrate = -1; projectile.timeLeft = 600; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = -2; projectile.extraUpdates = 1; } public override void AI() { projectile.frameCounter++; if (projectile.frameCounter > 4) { projectile.frame++; projectile.frameCounter = 0; } if (projectile.frame >= 3) { projectile.frame = 0; } if (projectile.ai[0] == 0f) { projectile.ai[0] = 1f; Main.PlaySound(SoundID.Item, (int)projectile.position.X, (int)projectile.position.Y, 12); } if (projectile.alpha > 0) { projectile.alpha -= 25; } if (projectile.alpha < 0) { projectile.alpha = 0; } projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X); } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(ModContent.BuffType(), 120); } public override Color? GetAlpha(Color lightColor) { return new Color(255, 255, 255, projectile.alpha); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); return false; } } }