diff --git a/Items/Weapons/Magic/FlareBolt.cs b/Items/Weapons/Magic/FlareBolt.cs index 481eb7aab1..32816be5a7 100644 --- a/Items/Weapons/Magic/FlareBolt.cs +++ b/Items/Weapons/Magic/FlareBolt.cs @@ -1,4 +1,6 @@ -using CalamityMod.Projectiles.Magic; +using System; +using CalamityMod.Projectiles.Magic; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -12,28 +14,53 @@ namespace CalamityMod.Items.Weapons.Magic { Item.width = 34; Item.height = 38; - Item.damage = 36; + Item.damage = 50; Item.DamageType = DamageClass.Magic; - Item.mana = 12; - Item.useTime = 30; - Item.useAnimation = 30; + Item.mana = 22; + Item.useTime = 80; + Item.useAnimation = 80; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; - Item.knockBack = 5.5f; + Item.knockBack = 5f; Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; Item.rare = ItemRarityID.Orange; - Item.UseSound = SoundID.Item20; Item.autoReuse = true; Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 7.5f; + Item.shootSpeed = 6.5f; } + public override void HoldItem(Player player) + { + player.Calamity().mouseWorldListener = true; + } + public override void UseStyle(Player player, Rectangle heldItemFrame) + { + player.ChangeDir(Math.Sign((player.Calamity().mouseWorld - player.Center).X)); + float itemRotation = player.compositeFrontArm.rotation + MathHelper.PiOver2 * player.gravDir; + Vector2 itemPosition = player.MountedCenter + itemRotation.ToRotationVector2() * 4f; + Vector2 itemSize = new Vector2(34, 38); + Vector2 itemOrigin = new Vector2(-24, 4); + + CalamityUtils.CleanHoldStyle(player, itemRotation, itemPosition, itemSize, itemOrigin); + + base.UseStyle(player, heldItemFrame); + } + public override void UseItemFrame(Player player) + { + player.ChangeDir(Math.Sign((player.Calamity().mouseWorld - player.Center).X)); + + float animProgress = 0.5f - player.itemTime / (float)player.itemTimeMax; + float rotation = (player.Center - player.Calamity().mouseWorld).ToRotation() * player.gravDir + MathHelper.PiOver2; + + player.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, rotation); + } public override void AddRecipes() { CreateRecipe(). AddIngredient(ItemID.HellstoneBar, 6). AddIngredient(ItemID.Obsidian, 9). AddIngredient(ItemID.Fireblossom, 2). + AddIngredient(ItemID.Ruby). AddTile(TileID.Bookcases). Register(); } diff --git a/Items/Weapons/Magic/FrostBolt.cs b/Items/Weapons/Magic/FrostBolt.cs index 489a233792..f4998f62aa 100644 --- a/Items/Weapons/Magic/FrostBolt.cs +++ b/Items/Weapons/Magic/FrostBolt.cs @@ -1,4 +1,7 @@ -using CalamityMod.Projectiles.Magic; +using System; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Projectiles.Magic; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -14,26 +17,51 @@ namespace CalamityMod.Items.Weapons.Magic Item.height = 38; Item.damage = 14; Item.DamageType = DamageClass.Magic; - Item.mana = 6; - Item.useTime = 20; - Item.useAnimation = 20; + Item.mana = 9; + Item.useTime = 35; + Item.useAnimation = 35; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 3.5f; Item.value = CalamityGlobalItem.RarityGreenBuyPrice; Item.rare = ItemRarityID.Green; - Item.UseSound = SoundID.Item8; Item.autoReuse = true; Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 6f; + Item.shootSpeed = 8f; } + public override void HoldItem(Player player) + { + player.Calamity().mouseWorldListener = true; + } + public override void UseStyle(Player player, Rectangle heldItemFrame) + { + player.ChangeDir(Math.Sign((player.Calamity().mouseWorld - player.Center).X)); + float itemRotation = player.compositeFrontArm.rotation + MathHelper.PiOver2 * player.gravDir; + Vector2 itemPosition = player.MountedCenter + itemRotation.ToRotationVector2() * 4f; + Vector2 itemSize = new Vector2(34, 38); + Vector2 itemOrigin = new Vector2(-24, 4); + + CalamityUtils.CleanHoldStyle(player, itemRotation, itemPosition, itemSize, itemOrigin); + + base.UseStyle(player, heldItemFrame); + } + public override void UseItemFrame(Player player) + { + player.ChangeDir(Math.Sign((player.Calamity().mouseWorld - player.Center).X)); + + float animProgress = 0.5f - player.itemTime / (float)player.itemTimeMax; + float rotation = (player.Center - player.Calamity().mouseWorld).ToRotation() * player.gravDir + MathHelper.PiOver2; + + player.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, rotation); + } public override void AddRecipes() { CreateRecipe(). AddRecipeGroup("AnyIceBlock", 20). AddRecipeGroup("AnySnowBlock", 10). AddIngredient(ItemID.Shiverthorn, 2). + AddIngredient(ItemID.Sapphire). AddTile(TileID.Bookcases). Register(); } diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson index 792d598ed3..c2ffc31a7a 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson @@ -359,7 +359,12 @@ FrigidflashBolt: { FrostBolt: { DisplayName: Frost Bolt - Tooltip: Casts a slow-moving ball of frost + Tooltip: + ''' + Casts a ball of frost that bounces off tiles + When hitting a tile, a small frost burst is produced + Frost projectiles will fall to the ground after enough time has passed + ''' } Genesis: { diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Magic.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Magic.hjson index c6bb9aca0d..57c8c3d178 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Magic.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Magic.hjson @@ -263,3 +263,4 @@ WyvernProjectile.DisplayName: Wyvern YharimsCrystalBeam.DisplayName: Yharim's Beam YharimsCrystalPrism.DisplayName: Yermes Christal VehemenceBolt.DisplayName: Vehemence Bolt +FireImplosion.DisplayName: Fire Implosion diff --git a/Particles/FireTypeParticle.png b/Particles/FireTypeParticle.png new file mode 100644 index 0000000000..fe146693be Binary files /dev/null and b/Particles/FireTypeParticle.png differ diff --git a/Particles/IceTypeParticle.png b/Particles/IceTypeParticle.png new file mode 100644 index 0000000000..5cf40d79e4 Binary files /dev/null and b/Particles/IceTypeParticle.png differ diff --git a/Projectiles/Magic/FireImplosion.cs b/Projectiles/Magic/FireImplosion.cs new file mode 100644 index 0000000000..cfdd746d6b --- /dev/null +++ b/Projectiles/Magic/FireImplosion.cs @@ -0,0 +1,127 @@ +using System; +using System.IO; +using CalamityMod.Dusts; +using CalamityMod.Particles; +using Microsoft.Build.Construction; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class FireImplosion : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Magic"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public Vector2 pushVelocity; + public float customKnockback = 0; + public int time = 0; + public int boomTime = 0; + public override void SetDefaults() + { + Projectile.width = 10; + Projectile.height = 10; + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.alpha = 255; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + Projectile.timeLeft = 55; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 10; + Projectile.ArmorPenetration = 9; + } + public override void AI() + { + if (customKnockback == 0) + { + Projectile.scale = 0; + Projectile.alpha = 0; + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/OpalChargedFire") with { Volume = 0.35f, Pitch = 0.7f }, Projectile.Center); + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/FireImplosion") with { Volume = 0.45f, Pitch = Main.rand.NextFloat(0.2f, 0.35f) }, Projectile.Center); + customKnockback = Math.Abs(Projectile.knockBack); + Projectile.knockBack = 0; + + for (int i = 0; i < 3; i++) + { + Particle orb1 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.OrangeRed, "CalamityMod/Particles/BloomRing", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 0, 1.1f + i * 0.1f, 18); + GeneralParticleHandler.SpawnParticle(orb1); + } + float rot = Main.rand.NextFloat(-2, 2); + for (int i = 0; i < 8; i++) + { + Vector2 velocity = (MathHelper.TwoPi * i / 8f).ToRotationVector2().RotatedBy(rot) * 13f; + Particle trail = new CustomSpark(Projectile.Center + velocity * 3, velocity * 0.5f, "CalamityMod/Particles/FireTypeParticle", false, 35, 1.5f, Color.OrangeRed, new Vector2(1, 1.3f), true, false, shrinkSpeed: 0.15f); + GeneralParticleHandler.SpawnParticle(trail); + } + } + if (boomTime >= 15) + { + Projectile.scale = 0.95f * Utils.GetLerpValue(42, 0, time, true) * Utils.GetLerpValue(40, 25, time, true); + time++; + } + else + { + Projectile.scale = 0.95f * Utils.GetLerpValue(0, 15, boomTime, true); + boomTime++; + } + if (Projectile.timeLeft <= 20) + { + Particle fx = new CustomSpark(Projectile.Center, Vector2.One.RotatedByRandom(100) * Main.rand.NextFloat(0.3f, 6), "CalamityMod/Particles/FireTypeParticle", false, 22, Main.rand.NextFloat(0.7f, 1.2f), Color.OrangeRed, new Vector2(0.8f, 1f), true, false); + GeneralParticleHandler.SpawnParticle(fx); + } + else if (boomTime > 5) + { + for (int i = 0; i < 2; i++) + { + Vector2 vel = Vector2.One.RotatedByRandom(100) * Main.rand.NextFloat(7f, 14) * Projectile.scale; + Dust dust = Dust.NewDustPerfect(Projectile.Center + vel * 3, ModContent.DustType(), vel); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(0.75f, 1.1f); + dust.color = Color.OrangeRed; + dust.noLightEmittence = true; + } + } + Lighting.AddLight(Projectile.Center, Color.Orange.ToVector3() * 2 * Projectile.scale); + Projectile.rotation += 0.4f; + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + target.AddBuff(BuffID.OnFire, 180); + + pushVelocity = Utils.DirectionTo(Projectile.Center, target.Center) * customKnockback; + float minMult = 0.5f; + int hitsToMinMult = 15; + float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true); + modifiers.SourceDamage *= damageMult; + + if (target.CanBeMoved(false)) + { + target.velocity = (-pushVelocity); + } + } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + return CalamityUtils.CircularHitboxCollision(Projectile.Center, (110 * Projectile.scale) + 15, targetHitbox); + } + public override bool PreDraw(ref Color lightColor) + { + if (boomTime < 1) + return false; + float fade = Utils.GetLerpValue(0, 20, Projectile.timeLeft, true); + Texture2D texture = ModContent.Request("CalamityMod/Particles/BloomRing").Value; + + for (int i = 0; i < 15; i++) + { + Color auraColor = Color.OrangeRed with { A = 0 } * 0.4f; + Vector2 drawOffset = (MathHelper.TwoPi * i / 15f).ToRotationVector2().RotatedBy(Main.GlobalTimeWrappedHourly * 28 - fade * 10) * 7 * fade; + Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition + drawOffset, null, auraColor, Projectile.rotation + i * 2.5f, texture.Size() * 0.5f, new Vector2(1 * fade, 1 + (1 - fade)) * MathHelper.Clamp((Projectile.scale - (i * 0.02f)), 0, 10), SpriteEffects.None); + } + + return false; + } + } +} diff --git a/Projectiles/Magic/FlareBoltProjectile.cs b/Projectiles/Magic/FlareBoltProjectile.cs index d07901184d..bb9cf5772b 100644 --- a/Projectiles/Magic/FlareBoltProjectile.cs +++ b/Projectiles/Magic/FlareBoltProjectile.cs @@ -1,4 +1,9 @@ -using Microsoft.Xna.Framework; +using System; +using CalamityMod.Dusts; +using CalamityMod.Particles; +using CalamityMod.Projectiles.Typeless; +using Microsoft.Build.Construction; +using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -8,98 +13,111 @@ namespace CalamityMod.Projectiles.Magic { public class FlareBoltProjectile : ModProjectile, ILocalizedModType { + public ref float time => ref Projectile.ai[0]; + public int wallBounces = 0; + public float fadeIn = 0; + public bool launch = true; + public Color bColor = Color.OrangeRed; public new string LocalizationCategory => "Projectiles.Magic"; - public override void SetStaticDefaults() - { - ProjectileID.Sets.TrailCacheLength[Type] = 2; - ProjectileID.Sets.TrailingMode[Type] = 0; - } - public override void SetDefaults() { Projectile.width = 16; Projectile.height = 16; Projectile.friendly = true; - Projectile.alpha = 255; - Projectile.penetrate = 4; - Projectile.timeLeft = 480; + Projectile.penetrate = 5; + Projectile.timeLeft = 240; + Projectile.extraUpdates = 2; + Projectile.tileCollide = false; Projectile.DamageType = DamageClass.Magic; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 20; + Projectile.localNPCHitCooldown = -1; } - public override void AI() { - if (Projectile.alpha > 0) + Player Owner = Main.player[Projectile.owner]; + Lighting.AddLight(Projectile.Center, bColor.ToVector3()); + fadeIn = Utils.GetLerpValue(0, Owner.itemAnimationMax * 0.5f * Projectile.MaxUpdates, time, true); + float velFade = Utils.GetLerpValue(1.5f, 6.5f, Projectile.velocity.Length(), true); + Vector2 velocity = Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld) * Owner.HeldItem.shootSpeed; + Projectile.scale = fadeIn * 1.5f; + if (fadeIn < 1) // Hold the projectile in front of the player while they case the spell { - Projectile.alpha -= 25; - if (Projectile.alpha < 0) - Projectile.alpha = 0; - } - Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.45f / 255f, (255 - Projectile.alpha) * 0.2f / 255f, (255 - Projectile.alpha) * 0.1f / 255f); - for (int i = 0; i < 2; i++) - { - float shortXVel = Projectile.velocity.X / 3f * (float)i; - float shortYVel = Projectile.velocity.Y / 3f * (float)i; - int fourConst = 4; - int fireDust = Dust.NewDust(new Vector2(Projectile.position.X + (float)fourConst, Projectile.position.Y + (float)fourConst), Projectile.width - fourConst * 2, Projectile.height - fourConst * 2, DustID.InfernoFork, 0f, 0f, 100, default, 1.2f); - Dust dust = Main.dust[fireDust]; - dust.noGravity = true; - dust.velocity *= 0.1f; - dust.velocity += Projectile.velocity * 0.1f; - dust.position.X -= shortXVel; - dust.position.Y -= shortYVel; - } - if (Main.rand.NextBool(10)) - { - int otherFourConst = 4; - int fireDustSmol = Dust.NewDust(new Vector2(Projectile.position.X + (float)otherFourConst, Projectile.position.Y + (float)otherFourConst), Projectile.width - otherFourConst * 2, Projectile.height - otherFourConst * 2, DustID.InfernoFork, 0f, 0f, 100, default, 0.6f); - Main.dust[fireDustSmol].velocity *= 0.25f; - Main.dust[fireDustSmol].velocity += Projectile.velocity * 0.5f; - } - Projectile.rotation += 0.3f * (float)Projectile.direction; - } - - public override bool PreDraw(ref Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); - return false; - } - - public override bool OnTileCollide(Vector2 oldVelocity) - { - Projectile.penetrate--; - if (Projectile.penetrate <= 0) - { - Projectile.Kill(); + Projectile.Center = Owner.Center + velocity.SafeNormalize(Vector2.UnitX) * 48; } else { - if (Projectile.velocity.X != oldVelocity.X) + if (launch) // On launch, spawns some effects and launch the projectile at the mouse { - Projectile.velocity.X = -oldVelocity.X; + Projectile.tileCollide = true; + Projectile.velocity = velocity; + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/HalleysInfernoShoot") with { Volume = 0.45f, Pitch = 0.3f }, Projectile.Center); + for (int i = 0; i < 20; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType(), Vector2.One.RotatedByRandom(100) * Main.rand.NextFloat(1.5f, 3.5f)); + dust.noGravity = false; + dust.scale = Main.rand.NextFloat(0.85f, 1.4f); + dust.color = bColor; + dust.noLightEmittence = true; + if (i % 3 == 0) + { + float variance = Main.rand.NextFloat(-0.6f, 0.6f); + float fxScale = Main.rand.NextFloat(1.5f, 1.7f) - Math.Abs(variance); + Vector2 fxVelocity = Projectile.velocity.RotatedBy(variance) * Main.rand.NextFloat(0.6f, 1f) * (1 - Math.Abs(variance)); + + Particle fx = new CustomSpark(Projectile.Center, fxVelocity * 1.3f, "CalamityMod/Particles/FireTypeParticle", false, 22, fxScale, Color.Lerp(bColor, Color.Red, 0.5f), new Vector2(1.8f, 1f), true, false, shrinkSpeed: 0.2f); + GeneralParticleHandler.SpawnParticle(fx); + } + } + launch = false; } - if (Projectile.velocity.Y != oldVelocity.Y) + + if (Main.rand.NextBool(10) && velFade > 0.1f) { - Projectile.velocity.Y = -oldVelocity.Y; + Particle fx = new CustomSpark(Projectile.Center + Main.rand.NextVector2Circular(8, 8), -Projectile.velocity * 0.9f, "CalamityMod/Particles/FireTypeParticle", false, 32, 1.15f, Color.Lerp(bColor, Color.Red, 0.5f), new Vector2(0.8f, 1f), true, false); + GeneralParticleHandler.SpawnParticle(fx); } - SoundEngine.PlaySound(SoundID.Item10, Projectile.Center); + if (Main.rand.NextBool(6)) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(8, 8), ModContent.DustType(), -Projectile.velocity * 0.5f); + dust.noGravity = false; + dust.scale = Main.rand.NextFloat(0.85f, 1.4f); + dust.color = bColor; + dust.noLightEmittence = true; + } + + Particle trail = new CustomSpark(Projectile.Center, -Projectile.velocity * 0.3f, "CalamityMod/Particles/BloomCircle", false, 11, 0.3f, bColor * 0.9f, new Vector2(1, 1f), true, false, shrinkSpeed: 0.7f * velFade); + GeneralParticleHandler.SpawnParticle(trail); } + // Gain gravity after a while + // This makes it more useful on the surface where you otherwise have less tiles to work with + if (Projectile.timeLeft < 120) + { + Projectile.velocity *= 0.98f; + } + else if (wallBounces > 1) // If you only have one bounce before death, reduce lifetime to start falling faster + Projectile.timeLeft--; + Projectile.rotation += 0.3f * Projectile.direction; + time++; + } + public override bool OnTileCollide(Vector2 oldVelocity) + { return false; } - - public override void OnKill(int timeLeft) - { - SoundEngine.PlaySound(SoundID.Item10, Projectile.Center); - for (int k = 0; k < 5; k++) - { - Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.InfernoFork, Projectile.oldVelocity.X * 0.5f, Projectile.oldVelocity.Y * 0.5f); - } - } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - target.AddBuff(BuffID.OnFire, 180); + target.AddBuff(BuffID.OnFire, 90); + if (Projectile.damage > 1) + Projectile.damage = (int)(Projectile.damage * 0.85f); + } + public override void OnKill(int timeLeft) + { + if (Projectile.numHits < 4) + Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 0.5f), Projectile.knockBack, Projectile.owner); + } + public override bool PreDraw(ref Color lightColor) + { + Projectile.DrawProjectileWithBackglow(bColor with { A = 0 }, Color.White, 2f * fadeIn); + return false; } } } diff --git a/Projectiles/Magic/FrostBoltProjectile.cs b/Projectiles/Magic/FrostBoltProjectile.cs index d906f20215..30855c9d2c 100644 --- a/Projectiles/Magic/FrostBoltProjectile.cs +++ b/Projectiles/Magic/FrostBoltProjectile.cs @@ -1,4 +1,9 @@ -using Microsoft.Xna.Framework; +using System; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Dusts; +using CalamityMod.Particles; +using CalamityMod.Projectiles.Typeless; +using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -8,99 +13,138 @@ namespace CalamityMod.Projectiles.Magic { public class FrostBoltProjectile : ModProjectile, ILocalizedModType { + public ref float time => ref Projectile.ai[0]; + public int wallBounces = 0; + public float fadeIn = 0; + public bool launch = true; + public Color bColor = Color.DeepSkyBlue; public new string LocalizationCategory => "Projectiles.Magic"; - public override void SetStaticDefaults() - { - ProjectileID.Sets.TrailCacheLength[Type] = 2; - ProjectileID.Sets.TrailingMode[Type] = 0; - } - public override void SetDefaults() { Projectile.width = 16; Projectile.height = 16; Projectile.friendly = true; - Projectile.alpha = 255; - Projectile.penetrate = 2; + Projectile.penetrate = 3; Projectile.timeLeft = 480; + Projectile.tileCollide = false; Projectile.DamageType = DamageClass.Magic; Projectile.coldDamage = true; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 10; + Projectile.localNPCHitCooldown = -1; } - public override void AI() { - if (Projectile.alpha > 0) + Player Owner = Main.player[Projectile.owner]; + Lighting.AddLight(Projectile.Center, bColor.ToVector3()); + fadeIn = Utils.GetLerpValue(0, Owner.itemAnimationMax * 0.5f, time, true); + Vector2 velocity = Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld) * Owner.HeldItem.shootSpeed; + Projectile.scale = fadeIn; + if (fadeIn < 1) // Hold the projectile in front of the player while they case the spell { - Projectile.alpha -= 25; - if (Projectile.alpha < 0) - Projectile.alpha = 0; - } - Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.01f / 255f, (255 - Projectile.alpha) * 0.3f / 255f, (255 - Projectile.alpha) * 0.45f / 255f); - for (int i = 0; i < 2; i++) - { - float shortXVel = Projectile.velocity.X / 3f * (float)i; - float shortYVel = Projectile.velocity.Y / 3f * (float)i; - int fourConst = 4; - int frostDust = Dust.NewDust(new Vector2(Projectile.position.X + (float)fourConst, Projectile.position.Y + (float)fourConst), Projectile.width - fourConst * 2, Projectile.height - fourConst * 2, DustID.Frost, 0f, 0f, 100, default, 1.2f); - Dust dust = Main.dust[frostDust]; - dust.noGravity = true; - dust.velocity *= 0.1f; - dust.velocity += Projectile.velocity * 0.1f; - dust.position.X -= shortXVel; - dust.position.Y -= shortYVel; - } - if (Main.rand.NextBool(10)) - { - int otherFourConst = 4; - int frostDustSmol = Dust.NewDust(new Vector2(Projectile.position.X + (float)otherFourConst, Projectile.position.Y + (float)otherFourConst), Projectile.width - otherFourConst * 2, Projectile.height - otherFourConst * 2, DustID.Frost, 0f, 0f, 100, default, 0.6f); - Main.dust[frostDustSmol].velocity *= 0.25f; - Main.dust[frostDustSmol].velocity += Projectile.velocity * 0.5f; - } - Projectile.rotation += 0.3f * (float)Projectile.direction; - } - - public override bool PreDraw(ref Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); - return false; - } - - public override bool OnTileCollide(Vector2 oldVelocity) - { - Projectile.penetrate--; - if (Projectile.penetrate <= 0) - { - Projectile.Kill(); + Projectile.Center = Owner.Center + velocity.SafeNormalize(Vector2.UnitX) * 48; } else { - if (Projectile.velocity.X != oldVelocity.X) + if (launch) // On launch, spawns some effects and launch the projectile at the mouse { - Projectile.velocity.X = -oldVelocity.X; + Projectile.tileCollide = true; + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/NPCHit/CryogenHit", 3) with { Volume = 0.45f, Pitch = 0.3f }, Projectile.Center); + for (int i = 0; i < 8; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType(), Vector2.One.RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1.5f)); + dust.noGravity = false; + dust.scale = Main.rand.NextFloat(0.65f, 1f); + dust.color = bColor; + dust.noLightEmittence = true; + } + Projectile.velocity = velocity; + launch = false; } - if (Projectile.velocity.Y != oldVelocity.Y) + + if (Main.rand.NextBool(15)) { - Projectile.velocity.Y = -oldVelocity.Y; + Particle fx = new CustomSpark(Projectile.Center + Main.rand.NextVector2Circular(8, 8), -Projectile.velocity * 0.3f, "CalamityMod/Particles/IceTypeParticle", false, 32, 0.9f, Color.Lerp(bColor, Color.White, 0.5f), new Vector2(0.8f, 1f), true, false); + GeneralParticleHandler.SpawnParticle(fx); } - SoundEngine.PlaySound(SoundID.Item10, Projectile.Center); + + Particle trail = new CustomSpark(Projectile.Center, -Projectile.velocity * 0.3f, "CalamityMod/Particles/BloomCircle", false, 7, 0.2f, bColor * 0.9f, new Vector2(1, 1f), true, false, shrinkSpeed: 0.8f); + GeneralParticleHandler.SpawnParticle(trail); } + // Gain gravity after a while + // This makes it more useful on the surface where you otherwise have less tiles to work with + if (Projectile.timeLeft < 260) + { + Projectile.velocity.X *= 0.9711f; + if (Projectile.velocity.Y < 15) + Projectile.velocity.Y += 0.19f; + if (Projectile.velocity.Y < 5) + Projectile.velocity.Y *= 0.977f; + wallBounces = 2; // Will always expire on the next tile collide + } + else if (wallBounces > 1) // If you only have one bounce before death, reduce lifetime to start falling faster + Projectile.timeLeft--; + Projectile.rotation += 0.3f * Projectile.direction; + time++; + } + public override bool OnTileCollide(Vector2 oldVelocity) + { + // Allow bounced bolts to hit enemies already hit before the bounce + for (int i = 0; i < Main.maxNPCs; i++) + Projectile.localNPCImmunity[i] = 0; + + if (Projectile.velocity.X != oldVelocity.X) + { + Projectile.velocity.X = -oldVelocity.X; + } + if (Projectile.velocity.Y != oldVelocity.Y) + { + Projectile.velocity.Y = -oldVelocity.Y; + } + SoundEngine.PlaySound(SoundID.Item10, Projectile.Center); + + // Create Blast + Projectile blast = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 0.5f), Projectile.knockBack, Projectile.owner, 80, 0.35f, 5); + blast.localAI[0] = BuffID.Frostburn; + blast.localAI[1] = 120; + blast.timeLeft = 15; + blast.DamageType = DamageClass.Magic; + + SoundEngine.PlaySound(SoundID.Item27 with { Volume = 0.5f, Pitch = 0.3f, MaxInstances = -1 }, Projectile.Center); + SoundEngine.PlaySound(SoundID.Item27 with { Volume = 0.5f, Pitch = -0.3f, MaxInstances = -1 }, Projectile.Center); + + // "Snowflake" visual effect + float rot = Main.rand.NextFloat(-2, 2); + for (int i = 0; i < 6; i++) + { + Vector2 velocity = (MathHelper.TwoPi * i / 6f).ToRotationVector2().RotatedBy(rot) * 6f; + Particle trail = new CustomSpark(Projectile.Center + velocity * 3, velocity * 0.5f, "CalamityMod/Particles/IceTypeParticle", false, 25, 1.3f, Color.Lerp(bColor, Color.White, 0.5f), new Vector2(1, 1.8f), true, false, shrinkSpeed: -0.45f); + GeneralParticleHandler.SpawnParticle(trail); + + Dust dust = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType(), velocity * 1.5f); + dust.noGravity = true; + dust.scale = 1.3f; + dust.color = bColor; + dust.noLightEmittence = true; + } + + if (wallBounces >= 2) + { + Projectile.Kill(); + } + wallBounces++; + return false; } - - public override void OnKill(int timeLeft) - { - SoundEngine.PlaySound(SoundID.Item27, Projectile.Center); - for (int k = 0; k < 5; k++) - { - Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.Frost, Projectile.oldVelocity.X * 0.5f, Projectile.oldVelocity.Y * 0.5f); - } - } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { target.AddBuff(BuffID.Frostburn, 60); + if (Projectile.damage > 1) + Projectile.damage = (int)(Projectile.damage * 0.85f); + } + public override bool PreDraw(ref Color lightColor) + { + Projectile.DrawProjectileWithBackglow(bColor with { A = 0 }, Color.White, 2f * fadeIn); + return false; } } } diff --git a/Sounds/Item/FireImplosion.ogg b/Sounds/Item/FireImplosion.ogg new file mode 100644 index 0000000000..ef5da14382 Binary files /dev/null and b/Sounds/Item/FireImplosion.ogg differ