using Microsoft.Xna.Framework; using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { public class LuxorsGiftRogue : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Rogue"; public override void SetStaticDefaults() { ProjectileID.Sets.TrailCacheLength[Projectile.type] = 10; ProjectileID.Sets.TrailingMode[Projectile.type] = 1; } public override void SetDefaults() { Projectile.width = 18; Projectile.height = 18; Projectile.friendly = true; Projectile.penetrate = 4; Projectile.aiStyle = ProjAIStyleID.ThrownProjectile; Projectile.alpha = 255; Projectile.timeLeft = 300; AIType = ProjectileID.ThrowingKnife; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 10; Projectile.DamageType = RogueDamageClass.Instance; } public override void AI() { Projectile.rotation = (float)Math.Atan2((double)Projectile.velocity.Y, (double)Projectile.velocity.X) + 1.57f; if (Projectile.localAI[0] == 0f) { Projectile.scale -= 0.01f; Projectile.alpha += 15; if (Projectile.alpha >= 250) { Projectile.alpha = 255; Projectile.localAI[0] = 1f; } } else if (Projectile.localAI[0] == 1f) { Projectile.scale += 0.01f; Projectile.alpha -= 15; if (Projectile.alpha <= 0) { Projectile.alpha = 0; Projectile.localAI[0] = 0f; } } Projectile.localAI[1] += 1f; if (Projectile.localAI[1] == 3f) { 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, 173, 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 Color? GetAlpha(Color lightColor) { if (Projectile.timeLeft < 85) { byte b2 = (byte)(Projectile.timeLeft * 3); byte a2 = (byte)(100f * ((float)b2 / 255f)); return new Color((int)b2, (int)b2, (int)b2, (int)a2); } return new Color(255, 255, 255, 100); } public override bool OnTileCollide(Vector2 oldVelocity) { Projectile.penetrate--; if (Projectile.penetrate <= 0) { Projectile.Kill(); } else { if (Projectile.velocity.X != oldVelocity.X) { Projectile.velocity.X = -oldVelocity.X; } if (Projectile.velocity.Y != oldVelocity.Y) { Projectile.velocity.Y = -oldVelocity.Y; } } return false; } public override bool PreDraw(ref Color lightColor) { CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 2); return false; } } }