using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; using Terraria.Audio; namespace CalamityMod.Projectiles.Rogue { public class SnapClamProj : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Rogue"; public override void SetStaticDefaults() { Main.projFrames[Projectile.type] = 2; } public override void SetDefaults() { Projectile.width = 20; Projectile.height = 13; Projectile.friendly = true; Projectile.DamageType = RogueDamageClass.Instance; Projectile.ignoreWater = true; Projectile.penetrate = -1; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 10; } public override void AI() { if (Projectile.ai[2] < 30f && Projectile.ai[0] != 1f) { Projectile.ai[2]++; if (Projectile.ai[2] >= 30f) Projectile.damage = (int)(Projectile.damage * 0.8); } if (Projectile.ai[0] == 0f) { Projectile.velocity.X = Projectile.velocity.X * 0.99f; Projectile.velocity.Y = Projectile.velocity.Y + 0.15f; Projectile.rotation += 0.4f * (float)Projectile.direction; Projectile.spriteDirection = Projectile.direction; } //Sticky Behaviour Projectile.StickyProjAI(15); if (Projectile.ai[2] < 30f && Projectile.ai[0] != 1f) { Projectile.frame = 1; } else { Projectile.frame = 0; } } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { if (Projectile.ai[2] < 30f) Projectile.ModifyHitNPCSticky(2); } public override bool? CanDamage() => Projectile.ai[0] == 1f ? false : base.CanDamage(); public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) { if (targetHitbox.Width > 8 && targetHitbox.Height > 8) { targetHitbox.Inflate(-targetHitbox.Width / 8, -targetHitbox.Height / 8); } return null; } public override void Kill(int timeLeft) { SoundEngine.PlaySound(SoundID.Item10, Projectile.position); Projectile.position.X = Projectile.position.X + (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y + (float)(Projectile.height / 2); Projectile.width = 13; 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 num194 = 0; num194 < 20; num194++) { int num195 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 14, 0f, 0f, 0, new Color(115, 124, 124), 1f); Main.dust[num195].noGravity = true; Main.dust[num195].velocity *= 2f; } } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 240); } }