using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { public class Iceberg : ModProjectile { public override void SetStaticDefaults() { DisplayName.SetDefault("Iceberg"); } public override void SetDefaults() { projectile.width = 30; projectile.height = 30; projectile.friendly = true; projectile.melee = true; projectile.penetrate = 1; projectile.timeLeft = 300; ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; ProjectileID.Sets.TrailingMode[projectile.type] = 1; projectile.coldDamage = true; } public override void AI() { projectile.rotation += 0.5f; int dust = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 67, 0f, 0f, 100, default, 1f); Main.dust[dust].noGravity = true; Main.dust[dust].velocity *= 0f; } public override void Kill(int timeLeft) { Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 27); for (int k = 0; k < 5; k++) { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 67, projectile.oldVelocity.X * 0.5f, projectile.oldVelocity.Y * 0.5f); } } public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) { double newDamageMult = 1.0 - ((double)projectile.timeLeft / 300.0); damage = (int)((double)damage * newDamageMult); knockback = 0f; if (crit || target.buffImmune[ModContent.BuffType()]) damage *= 2; } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { int debuffDuration = 300 - projectile.timeLeft; if (projectile.timeLeft < 270) target.AddBuff(ModContent.BuffType(), debuffDuration); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { CalamityGlobalProjectile.DrawCenteredAndAfterimage(projectile, lightColor, ProjectileID.Sets.TrailingMode[projectile.type], 2); return false; } } }