using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; using Terraria.Audio; namespace CalamityMod.Projectiles.Ranged { public class BubonicRoundProj : 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, 0f, 0.25f, 0f); Projectile.localAI[0] += 1f; if (Projectile.localAI[0] > 4f) { if (Main.rand.NextBool(2)) { int num137 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), 1, 1, 107, 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 OnTileCollide(Vector2 oldVelocity) { Collision.HitTiles(Projectile.position, Projectile.velocity, Projectile.width, Projectile.height); SoundEngine.PlaySound(SoundID.Dig, Projectile.position); return true; } public override bool PreDraw(ref Color lightColor) { CalamityUtils.DrawAfterimagesFromEdge(Projectile, 0, lightColor); return false; } // This projectile is always fullbright. public override Color? GetAlpha(Color lightColor) { return new Color(1f, 1f, 1f, 0f); } // Ignores 25% of armor public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) => modifiers.ScalingArmorPenetration += 0.25f; public override void ModifyHitPlayer(Player target, ref Player.HurtModifiers modifiers) => modifiers.ScalingArmorPenetration += 0.25f; // Inflicts Plague for 3 seconds public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 180); public override void Kill(int timeLeft) { for (int k = 0; k < 5; k++) { Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, 107, Projectile.oldVelocity.X * 0.5f, Projectile.oldVelocity.Y * 0.5f); } } } }