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 SlagRound : ModProjectile { public override void SetStaticDefaults() { DisplayName.SetDefault("Round"); ProjectileID.Sets.TrailCacheLength[projectile.type] = 3; ProjectileID.Sets.TrailingMode[projectile.type] = 0; } public override void SetDefaults() { projectile.width = 4; projectile.height = 4; projectile.friendly = true; projectile.ranged = true; projectile.penetrate = 1; projectile.aiStyle = 1; projectile.extraUpdates = 3; aiType = ProjectileID.Bullet; projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.basePointBlankShotDuration; } public override void AI() { projectile.localAI[0] += 1f; if (projectile.localAI[0] > 4f) { Vector2 dspeed = -projectile.velocity * 0.7f; int num469 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 32, 0f, 0f, 100, default, 1f); Main.dust[num469].noGravity = true; Main.dust[num469].velocity = dspeed; } } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { CalamityUtils.DrawAfterimagesFromEdge(projectile, 0, lightColor); return false; } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(ModContent.BuffType(), 120); } public override void Kill(int timeLeft) { for (int k = 0; k < 5; k++) { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 32, projectile.oldVelocity.X * 0.5f, projectile.oldVelocity.Y * 0.5f); } float spread = 180f * 0.0174f; double startAngle = Math.Atan2(projectile.velocity.X, projectile.velocity.Y) - spread / 2; double deltaAngle = spread / 8f; double offsetAngle; int i; if (projectile.owner == Main.myPlayer) { for (i = 0; i <= 1; i++) { offsetAngle = startAngle + deltaAngle * (i + i * i) / 2f + 32f * i; Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(Math.Sin(offsetAngle) * 5f), (float)(Math.Cos(offsetAngle) * 5f), ModContent.ProjectileType(), (int)(projectile.damage * 0.35), projectile.knockBack, projectile.owner, 0f, 0f); Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(-Math.Sin(offsetAngle) * 5f), (float)(-Math.Cos(offsetAngle) * 5f), ModContent.ProjectileType(), (int)(projectile.damage * 0.35), projectile.knockBack, projectile.owner, 0f, 0f); } } } } }