using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; using Terraria.Audio; namespace CalamityMod.Projectiles.Ranged { public class FlashRoundProj : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Ranged"; public override void SetStaticDefaults() { ProjectileID.Sets.TrailCacheLength[Projectile.type] = 6; ProjectileID.Sets.TrailingMode[Projectile.type] = 0; } public override void SetDefaults() { Projectile.width = 4; Projectile.height = 4; Projectile.aiStyle = ProjAIStyleID.Arrow; Projectile.friendly = true; Projectile.DamageType = DamageClass.Ranged; Projectile.penetrate = 1; Projectile.timeLeft = 600; Projectile.extraUpdates = 3; AIType = ProjectileID.Bullet; Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void AI() { Lighting.AddLight(Projectile.Center, 0.1f, 0.1f, 0.1f); Projectile.localAI[0] += 1f; if (Projectile.localAI[0] > 4f) { if (Main.rand.NextBool(3)) { int num137 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), 1, 1, 264, 0f, 0f, 0, default, 0.5f); Main.dust[num137].alpha = Projectile.alpha; Main.dust[num137].velocity *= 0f; Main.dust[num137].noGravity = true; } } } public override bool PreDraw(ref Color lightColor) { CalamityUtils.DrawAfterimagesFromEdge(Projectile, 0, lightColor); return false; } public override void Kill(int timeLeft) { SoundEngine.PlaySound(SoundID.Item93, Projectile.position); if (Projectile.owner == Main.myPlayer) { Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 0.25), 0f, Projectile.owner, 0f, 0f); } for (int k = 0; k < 5; k++) { Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, 264, Projectile.oldVelocity.X * 0.5f, Projectile.oldVelocity.Y * 0.5f); } } } }