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.Ranged { public class BloodfireArrowProj : ModProjectile { public override void SetStaticDefaults() { DisplayName.SetDefault("Bloodfire Arrow"); ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; ProjectileID.Sets.TrailingMode[projectile.type] = 1; } public override void SetDefaults() { projectile.width = 10; projectile.height = 10; projectile.friendly = true; projectile.ranged = true; projectile.arrow = true; projectile.penetrate = 1; projectile.timeLeft = 300; } public override bool OnTileCollide(Vector2 oldVelocity) { Collision.HitTiles(projectile.position, projectile.velocity, projectile.width, projectile.height); Main.PlaySound(0, (int)projectile.position.X, (int)projectile.position.Y, 1, 1f, 0f); return true; } public override void AI() { projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f; projectile.localAI[0] += 1f; if (projectile.localAI[0] == 15f) { projectile.localAI[0] = 0f; for (int l = 0; l < 12; l++) { Vector2 vector3 = Vector2.UnitX * (float)-(float)projectile.width / 2f; vector3 += -Vector2.UnitY.RotatedBy((double)((float)l * 3.14159274f / 6f), default) * new Vector2(8f, 16f); vector3 = vector3.RotatedBy((double)(projectile.rotation - 1.57079637f), default); int num9 = Dust.NewDust(projectile.Center, 0, 0, 235, 0f, 0f, 160, default, 1f); Main.dust[num9].scale = 1.1f; Main.dust[num9].noGravity = true; Main.dust[num9].position = projectile.Center + vector3; Main.dust[num9].velocity = projectile.velocity * 0.1f; Main.dust[num9].velocity = Vector2.Normalize(projectile.Center - projectile.velocity * 3f - Main.dust[num9].position) * 1.25f; } } } public override void Kill(int timeLeft) { projectile.position.X = projectile.position.X + (float)(projectile.width / 2); projectile.position.Y = projectile.position.Y + (float)(projectile.height / 2); projectile.width = 20; projectile.height = 20; projectile.position.X = projectile.position.X - (float)(projectile.width / 2); projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); for (int num621 = 0; num621 < 5; num621++) { int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 235, 0f, 0f, 100, default, 2f); Main.dust[num622].velocity *= 0.5f; if (Main.rand.NextBool(2)) { Main.dust[num622].scale = 0.5f; Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { if (target.type == NPCID.TargetDummy || !target.canGhostHeal) { return; } Player player = Main.player[projectile.owner]; if (Main.rand.NextBool(3)) { player.statLife += 1; player.HealEffect(1); } target.AddBuff(ModContent.BuffType(), 360); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { CalamityGlobalProjectile.DrawCenteredAndAfterimage(projectile, lightColor, ProjectileID.Sets.TrailingMode[projectile.type], 2); return false; } } }