using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; using Terraria.Audio; namespace CalamityMod.Projectiles.Rogue { public class PlaguenadeProj : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Rogue"; public override string Texture => "CalamityMod/Items/Weapons/Rogue/Plaguenade"; public override void SetDefaults() { Projectile.width = 20; Projectile.height = 20; Projectile.friendly = true; Projectile.penetrate = 1; Projectile.extraUpdates = 1; Projectile.timeLeft = 180; Projectile.DamageType = RogueDamageClass.Instance; } public override void AI() { Projectile.ai[0] += 1f; if (Projectile.ai[0] > 5f) { Projectile.ai[0] = 5f; if (Projectile.velocity.Y == 0f && Projectile.velocity.X != 0f) { Projectile.velocity.X *= 0.97f; if (Projectile.velocity.X > -0.01f && Projectile.velocity.X < 0.01f) { Projectile.velocity.X = 0f; Projectile.netUpdate = true; } } Projectile.velocity.Y += 0.2f; } Projectile.rotation += Projectile.velocity.X * 0.1f; if (Projectile.velocity.Y > 16f) { Projectile.velocity.Y = 16f; } } public override bool OnTileCollide(Vector2 oldVelocity) { if (Projectile.velocity.X != oldVelocity.X) { Projectile.velocity.X = oldVelocity.X * -0.5f; } if (Projectile.velocity.Y != oldVelocity.Y && oldVelocity.Y > 1f) { Projectile.velocity.Y = oldVelocity.Y * -0.5f; } return false; } public override bool PreDraw(ref Color lightColor) { Texture2D tex = ModContent.Request(Texture).Value; Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, null, Projectile.GetAlpha(lightColor), Projectile.rotation, tex.Size() / 2f, Projectile.scale, SpriteEffects.None, 0); return false; } public override void Kill(int timeLeft) { if (Projectile.owner == Main.myPlayer) { Player player = Main.player[Projectile.owner]; int projAmt = Projectile.Calamity().stealthStrike ? 28 : 20; for (int projIndex = 0; projIndex < projAmt; projIndex++) { float speedX = (float)Main.rand.Next(-35, 36) * 0.02f; float speedY = (float)Main.rand.Next(-35, 36) * 0.02f; Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.position.X, Projectile.position.Y, speedX, speedY, ModContent.ProjectileType(), player.beeDamage(Projectile.damage), player.beeKB(0f), Projectile.owner, 0f, 0f); } SoundEngine.PlaySound(SoundID.Item14, Projectile.position); if (Projectile.Calamity().stealthStrike) { Projectile.position = Projectile.Center; Projectile.width = Projectile.height = 75; } Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); Projectile.maxPenetrate = -1; Projectile.penetrate = -1; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 10; Projectile.Damage(); for (int i = 0; i < 10; i++) { int smoke = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 31, 0f, 0f, 100, default, 2f); Main.dust[smoke].velocity *= 3f; if (Main.rand.NextBool(2)) { Main.dust[smoke].scale = 0.5f; Main.dust[smoke].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } for (int j = 0; j < 15; j++) { int plague = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 89, 0f, 0f, 100, default, 3f); Main.dust[plague].noGravity = true; Main.dust[plague].velocity *= 5f; int fire = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 6, 0f, 0f, 100, default, 2f); Main.dust[fire].velocity *= 2f; } if (Main.netMode != NetmodeID.Server) { Vector2 goreSource = Projectile.Center; int goreAmt = 3; Vector2 source = new Vector2(goreSource.X - 24f, goreSource.Y - 24f); for (int goreIndex = 0; goreIndex < goreAmt; goreIndex++) { float velocityMult = 0.33f; if (goreIndex < (goreAmt / 3)) { velocityMult = 0.66f; } if (goreIndex >= (2 * goreAmt / 3)) { velocityMult = 1f; } Mod mod = ModContent.GetInstance(); int type = Main.rand.Next(61, 64); int smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f); Gore gore = Main.gore[smoke]; gore.velocity *= velocityMult; gore.velocity.X += 1f; gore.velocity.Y += 1f; type = Main.rand.Next(61, 64); smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f); gore = Main.gore[smoke]; gore.velocity *= velocityMult; gore.velocity.X -= 1f; gore.velocity.Y += 1f; type = Main.rand.Next(61, 64); smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f); gore = Main.gore[smoke]; gore.velocity *= velocityMult; gore.velocity.X += 1f; gore.velocity.Y -= 1f; type = Main.rand.Next(61, 64); smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f); gore = Main.gore[smoke]; gore.velocity *= velocityMult; gore.velocity.X -= 1f; gore.velocity.Y -= 1f; } } } } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 240); public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), 240); } }