using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { public class BlueExoArrow : ModProjectile { public override void SetStaticDefaults() { DisplayName.SetDefault("Arrow"); } public override void SetDefaults() { projectile.width = 5; projectile.height = 5; projectile.friendly = true; projectile.alpha = 255; projectile.penetrate = 1; projectile.extraUpdates = 2; projectile.timeLeft = 300; projectile.ranged = true; } public override void AI() { if (projectile.alpha > 0) { projectile.alpha -= 25; } if (projectile.alpha < 0) { projectile.alpha = 0; } float num55 = 40f; float num56 = 1.5f; if (projectile.ai[1] == 0f) { projectile.localAI[0] += num56; if (projectile.localAI[0] > num55) { projectile.localAI[0] = num55; } } else { projectile.localAI[0] -= num56; if (projectile.localAI[0] <= 0f) { projectile.Kill(); } } } public override Color? GetAlpha(Color lightColor) { return new Color(0, 0, 250, projectile.alpha); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { Color color25 = Lighting.GetColor((int)((double)projectile.position.X + (double)projectile.width * 0.5) / 16, (int)(((double)projectile.position.Y + (double)projectile.height * 0.5) / 16.0)); int num147 = 0; int num148 = 0; float num149 = (float)(Main.projectileTexture[projectile.type].Width - projectile.width) * 0.5f + (float)projectile.width * 0.5f; SpriteEffects spriteEffects = SpriteEffects.None; if (projectile.spriteDirection == -1) { spriteEffects = SpriteEffects.FlipHorizontally; } Rectangle value6 = new Rectangle((int)Main.screenPosition.X - 500, (int)Main.screenPosition.Y - 500, Main.screenWidth + 1000, Main.screenHeight + 1000); if (projectile.getRect().Intersects(value6)) { Vector2 value7 = new Vector2(projectile.position.X - Main.screenPosition.X + num149 + (float)num148, projectile.position.Y - Main.screenPosition.Y + (float)(projectile.height / 2) + projectile.gfxOffY); float num162 = 40f; float scaleFactor = 1.5f; if (projectile.ai[1] == 1f) { num162 = (float)(int)projectile.localAI[0]; } for (int num163 = 1; num163 <= (int)projectile.localAI[0]; num163++) { Vector2 value8 = Vector2.Normalize(projectile.velocity) * (float)num163 * scaleFactor; Color color29 = projectile.GetAlpha(color25); color29 *= (num162 - (float)num163) / num162; color29.A = 0; Main.spriteBatch.Draw(Main.projectileTexture[projectile.type], value7 - value8, null, color29, projectile.rotation, new Vector2(num149, (float)(projectile.height / 2 + num147)), projectile.scale, spriteEffects, 0f); } } return false; } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(ModContent.BuffType(), 30); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(BuffID.CursedInferno, 120); target.AddBuff(BuffID.Frostburn, 120); target.AddBuff(BuffID.OnFire, 120); target.AddBuff(BuffID.Ichor, 120); for (int x = 0; x < 3; x++) { float xPos = projectile.ai[0] > 0 ? projectile.position.X + 500 : projectile.position.X - 500; Vector2 vector2 = new Vector2(xPos, projectile.position.Y + Main.rand.Next(-500, 501)); float num80 = xPos; float speedX = (float)target.position.X - vector2.X; float speedY = (float)target.position.Y - vector2.Y; float dir = (float)Math.Sqrt((double)(speedX * speedX + speedY * speedY)); dir = 10 / num80; speedX *= dir * 150; speedY *= dir * 150; if (projectile.owner == Main.myPlayer) { Projectile.NewProjectile(vector2.X, vector2.Y, speedX, speedY, ModContent.ProjectileType(), (int)((double)projectile.damage * 0.7), 1f, projectile.owner); } } } } }