diff --git a/Buffs/DamageOverTime/ElementalMix.cs b/Buffs/DamageOverTime/ElementalMix.cs index 1113e7b68f..d206bffc57 100644 --- a/Buffs/DamageOverTime/ElementalMix.cs +++ b/Buffs/DamageOverTime/ElementalMix.cs @@ -46,11 +46,11 @@ namespace CalamityMod.Buffs.DamageOverTime GeneralParticleHandler.SpawnParticle(new TechyHoloysquareParticle(player.Calamity().RandomDebuffVisualSpot, speed, Main.rand.NextFloat(1.2f, 1.8f), effectcolor, Main.rand.Next(8, 14))); - int dustType = Main.rand.NextBool() ? 91 : 247; + int dustType = Main.rand.NextBool() ? 66 : 247; Dust dust = Dust.NewDustPerfect(player.Calamity().RandomDebuffVisualSpot, dustType); - dust.scale = (dustType == 91 ? 1.4f : 1.2f); - dust.velocity = (dustType == 247 ? Vector2.Zero : new Vector2(0, Main.rand.NextFloat(-1.5f, 4f)) - player.velocity / 2); - dust.noGravity = Main.rand.NextBool(4) && dustType == 91 ? false : true; + dust.scale = (dustType == 66 ? 1.4f : 1.2f); + dust.velocity = Vector2.Zero + new Vector2(Main.rand.NextFloat(-1, 1), Main.rand.NextFloat(4f, 8f)) - player.velocity / 2; + dust.noGravity = true; dust.alpha = Main.rand.Next(90, 150); dust.color = effectcolor; } @@ -71,12 +71,11 @@ namespace CalamityMod.Buffs.DamageOverTime GeneralParticleHandler.SpawnParticle(new TechyHoloysquareParticle(npcSize, speed, Main.rand.NextFloat(1.2f, 3.1f), effectcolor, Main.rand.Next(8, 14))); - int dustType = Main.rand.NextBool() ? 91 : 247; + int dustType = Main.rand.NextBool() ? 66 : 247; Dust dust = Dust.NewDustPerfect(npcSize, dustType); - dust.scale = (dustType == 91 ? 1.4f : 1.2f); - dust.velocity = (dustType == 247 ? Vector2.Zero : new Vector2(0, Main.rand.NextFloat(-1.5f, 4f)) - npc.velocity / 2); - dust.noGravity = Main.rand.NextBool(4) && dustType == 91 ? false : true; - dust.velocity = Vector2.Zero; + dust.scale = (dustType == 66 ? 1.4f : 1.2f); + dust.noGravity = true; + dust.velocity = Vector2.Zero + new Vector2(Main.rand.NextFloat(-2, 2), Main.rand.NextFloat(2f, 4f)) - npc.velocity / 2; dust.alpha = Main.rand.Next(90, 150); dust.color = effectcolor; } @@ -90,11 +89,11 @@ namespace CalamityMod.Buffs.DamageOverTime _ => Color.Violet, }; Vector2 npcSize = npc.Center + new Vector2(Main.rand.NextFloat(-npc.width / 2, npc.width / 2), Main.rand.NextFloat(-npc.height / 2, npc.height / 2)); - int dustType = Main.rand.NextBool() ? 91 : 247; + int dustType = Main.rand.NextBool() ? 66 : 247; Dust dust = Dust.NewDustPerfect(npcSize, dustType); - dust.scale = (dustType == 91 ? 0.9f : 1.4f); + dust.scale = (dustType == 66 ? 0.9f : 1.4f); dust.noGravity = true; - dust.velocity = Vector2.Zero; + dust.velocity = Vector2.Zero + new Vector2(Main.rand.NextFloat(-2, 2), Main.rand.NextFloat(2f, 4f)); dust.alpha = Main.rand.Next(35, 90); dust.color = effectcolor; } diff --git a/Items/Weapons/Ranged/ElementalEruption.cs b/Items/Weapons/Ranged/ElementalEruption.cs index 8c05014746..9fb00ce050 100644 --- a/Items/Weapons/Ranged/ElementalEruption.cs +++ b/Items/Weapons/Ranged/ElementalEruption.cs @@ -21,65 +21,33 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - Item.damage = 77; + Item.damage = 83; Item.DamageType = DamageClass.Ranged; Item.width = 64; Item.height = 34; - Item.useAnimation = Item.useTime = 30; + Item.useAnimation = Item.useTime = 6; Item.useStyle = ItemUseStyleID.Shoot; + Item.noUseGraphic = true; Item.noMelee = true; Item.knockBack = 3.5f; Item.UseSound = SoundID.Item34; Item.value = CalamityGlobalItem.Rarity11BuyPrice; Item.rare = ItemRarityID.Purple; Item.autoReuse = true; - Item.shoot = ModContent.ProjectileType(); + Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 9f; Item.useAmmo = AmmoID.Gel; - Item.consumeAmmoOnFirstShotOnly = true; + Item.channel = true; } - public override bool AltFunctionUse(Player player) => true; - public override Vector2? HoldoutOffset() => new Vector2(-10, 0); - - // Left click functions as clockwork with bursts of three (adjust for rounding) - public override float UseTimeMultiplier(Player player) => player.altFunctionUse == 2 ? 1f : 0.34f; - + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; + + // Spawning the holdout cannot consume ammo + public override bool CanConsumeAmmo(Item ammo, Player player) => player.ownedProjectileCounts[Item.shoot] > 0; public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - // Right-click: fires a small cluster of 3 sticky, non-homing flares - if (player.altFunctionUse == 2f) - { - Vector2 newPos = position + velocity.SafeNormalize(Vector2.UnitX) * 48f; - for (int i = 0; i < 3; i++) - { - newPos += Main.rand.NextVector2Circular(24f, 24f); - Projectile flare = Projectile.NewProjectileDirect(source, newPos, velocity, ModContent.ProjectileType(), damage, knockback, player.whoAmI, ai2: 1f); - flare.penetrate = -1; - flare.usesLocalNPCImmunity = true; - flare.localNPCHitCooldown = 30; - } - return false; - } - - // Left-click - // Fires a pair of homing rainbow flares - FlareCounter++; - if (FlareCounter >= 3) - { - FlareCounter = 0; - Vector2 newPos = position + velocity.SafeNormalize(Vector2.UnitX) * 36f; - Projectile.NewProjectile(source, newPos, velocity, ModContent.ProjectileType(), damage, knockback, player.whoAmI, velocity.Length(), -1f); - Projectile.NewProjectile(source, newPos, velocity, ModContent.ProjectileType(), damage, knockback, player.whoAmI, velocity.Length(), 1f); - } - - // Fires three flames, random colors and spread - for (int i = 0; i < 3; i++) - { - Vector2 newVel = velocity.RotatedByRandom(MathHelper.ToRadians(8f)); - Projectile.NewProjectile(source, position, newVel, type, damage, knockback, player.whoAmI, Main.rand.NextFloat()); - } + Projectile.NewProjectile(source, position, Vector2.Zero, type, 0, 0f, player.whoAmI); return false; } @@ -87,7 +55,6 @@ namespace CalamityMod.Items.Weapons.Ranged { CreateRecipe(). AddIngredient(). - AddIngredient(). AddIngredient(ItemID.LunarBar, 5). AddIngredient(5). AddIngredient(5). diff --git a/Items/Weapons/Ranged/TerraFlameburster.cs b/Items/Weapons/Ranged/TerraFlameburster.cs index fa044f3619..34b7099f26 100644 --- a/Items/Weapons/Ranged/TerraFlameburster.cs +++ b/Items/Weapons/Ranged/TerraFlameburster.cs @@ -13,51 +13,37 @@ namespace CalamityMod.Items.Weapons.Ranged public new string LocalizationCategory => "Items.Weapons.Ranged"; public int FlareCounter = 0; + public int TerraUseTime = 8; public override void SetDefaults() { - Item.damage = 55; + Item.damage = 58; Item.DamageType = DamageClass.Ranged; Item.width = 68; Item.height = 22; - Item.useTime = 8; - Item.useAnimation = 32; + Item.useTime = TerraUseTime; + Item.useAnimation = TerraUseTime; Item.useStyle = ItemUseStyleID.Shoot; + Item.noUseGraphic = true; Item.noMelee = true; Item.knockBack = 3.25f; - Item.UseSound = SoundID.Item34; Item.value = CalamityGlobalItem.Rarity9BuyPrice; Item.rare = ItemRarityID.Yellow; Item.autoReuse = true; - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 8f; + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 10f; Item.useAmmo = AmmoID.Gel; - Item.consumeAmmoOnFirstShotOnly = true; + Item.channel = true; } public override Vector2? HoldoutOffset() => new Vector2(-10, 0); - + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; + + // Spawning the holdout cannot consume ammo + public override bool CanConsumeAmmo(Item ammo, Player player) => player.ownedProjectileCounts[Item.shoot] > 0; public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - // Fires a pair of homing terra flares - FlareCounter++; - if (FlareCounter >= 4) - { - FlareCounter = 0; - Vector2 newPos = position + velocity.SafeNormalize(Vector2.UnitX) * 36f; - float randAngle = Main.rand.NextFloat(8f, 15f); - Vector2 newVel = velocity.RotatedBy(MathHelper.ToRadians(randAngle)) * 1.5f; - Projectile.NewProjectile(source, newPos, newVel, ModContent.ProjectileType(), damage, knockback, player.whoAmI); - newVel = velocity.RotatedBy(MathHelper.ToRadians(-randAngle)) * 1.5f; - Projectile.NewProjectile(source, newPos, newVel, ModContent.ProjectileType(), damage, knockback, player.whoAmI); - } - - // Fires two flames, green and blue, slightly randomly spread - for (int i = 0; i < 2; i++) - { - Vector2 newVel = velocity.RotatedByRandom(MathHelper.ToRadians(6f)); - Projectile.NewProjectile(source, position, newVel, type, damage, knockback, player.whoAmI, i); - } + Projectile.NewProjectile(source, position, Vector2.Zero, type, 0, 0f, player.whoAmI); return false; } diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson index 36ea78440e..b2c0fa900c 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson @@ -440,9 +440,9 @@ ElementalEruption: { DisplayName: Elemental Eruption Tooltip: ''' - Spews rainbow flames and pairs of high-energy homing flares - Press to fire a dense cluster of sticky flares + Charge and then spew rainbow flames and pairs of high-energy homing flares Uses gel for ammo + 70% chance to save ammo ''' } @@ -1212,8 +1212,9 @@ TerraFlameburster: { DisplayName: Terra Flameburster Tooltip: ''' - Spews high-energy flames and pairs of homing flares + Charge and then spew high-energy flames and pairs of homing flares Uses gel for ammo + 50% chance to save ammo ''' } diff --git a/Projectiles/Ranged/ElementalEruptionHouldout.cs b/Projectiles/Ranged/ElementalEruptionHouldout.cs new file mode 100644 index 0000000000..4ad18da7a5 --- /dev/null +++ b/Projectiles/Ranged/ElementalEruptionHouldout.cs @@ -0,0 +1,141 @@ +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Particles; +using log4net.Core; +using Microsoft.Xna.Framework; +using Mono.Cecil; +using ReLogic.Utilities; +using System; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class ElementalEruptionHoldout : ModProjectile + { + // Take the name and texture from the weapon + public override LocalizedText DisplayName => CalamityUtils.GetItemName(); + public override string Texture => "CalamityMod/Items/Weapons/Ranged/ElementalEruption"; + private Player Owner => Main.player[Projectile.owner]; + private ref float ShotsFired => ref Projectile.ai[1]; + private ref float ShootTimer => ref Projectile.ai[2]; + private ref int ShotDelay => ref Owner.ActiveItem().useTime; // 6 + public int ShotCooldown; + public int FireBlobs = 0; + private bool OwnerCanShoot => Owner.channel && !Owner.noItems && !Owner.CCed; + + public override void SetDefaults() + { + Projectile.width = 64; + Projectile.height = 34; + Projectile.friendly = true; + Projectile.tileCollide = false; + Projectile.DamageType = DamageClass.Ranged; + Projectile.ignoreWater = true; + } + + public override void AI() + { + if (Owner.dead || ShotsFired >= 24) // destroy the holdout if the player dies or is out of shots + { + Projectile.Kill(); + return; + } + + Vector2 armPosition = Owner.RotatedRelativePoint(Owner.MountedCenter, true); + Vector2 tipPosition = armPosition + Projectile.velocity * Projectile.width * 0.8f; + + // Kill if the owner stops channeling or otherwise cannot use the weapon. + if (!OwnerCanShoot) + { + Projectile.Kill(); + } + else + { + var effectcolor = Main.rand.Next(4) switch + { + 0 => Color.DeepSkyBlue, + 1 => Color.MediumSpringGreen, + 2 => Color.DarkOrange, + _ => Color.Violet, + }; + + // While channeled, keep refreshing the projectile lifespan + Projectile.timeLeft = 2; + + ShootTimer++; + if (ShootTimer >= 60) + { + if (ShotCooldown == 0) + { + SoundEngine.PlaySound(SoundID.Item34, Projectile.Center); + Owner.PickAmmo(Owner.ActiveItem(), out _, out float shootSpeed, out int damage, out float knockback, out _, Main.rand.NextFloat() < 0.70f); + for (int i = 0; i < 2; i++) + { + Projectile.NewProjectile(Projectile.GetSource_FromThis(), tipPosition, (Projectile.velocity * 10).RotatedByRandom(0.12f), ModContent.ProjectileType(), damage, knockback, Projectile.owner); + } + ShotsFired++; + ShotCooldown = ShotDelay; + if (FireBlobs == 0) + { + Vector2 newVel = (Projectile.velocity * 9); + Vector2 newPos = tipPosition + Projectile.velocity.SafeNormalize(Vector2.UnitX) * 36f; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), newPos, newVel, ModContent.ProjectileType(), damage, knockback, Projectile.owner, newVel.Length(), -1f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), newPos, newVel, ModContent.ProjectileType(), damage, knockback, Projectile.owner, newVel.Length(), 1f); + FireBlobs = 3; + } + else + FireBlobs--; + } + else + ShotCooldown--; + } + else + { + if (ShootTimer == 1) + SoundEngine.PlaySound(SoundID.Item73 with { Volume = 0.7f}, Projectile.Center); + ShotsFired = 0; + for (int i = 0; i < 2; i++) + { + int dustType = Main.rand.NextBool() ? 66 : 247; + float rotMulti = Main.rand.NextFloat(0.3f, 1f); + Dust dust = Dust.NewDustPerfect(tipPosition, dustType); + dust.scale = Main.rand.NextFloat(1.2f, 1.8f) * (ShootTimer * 0.025f) - rotMulti * 0.1f; + dust.noGravity = true; + dust.velocity = new Vector2(0, -2).RotatedByRandom(rotMulti * 0.3f) * (Main.rand.NextFloat(1f, 3.2f) - rotMulti) * (ShootTimer * 0.025f); + dust.alpha = Main.rand.Next(90, 150); + dust.color = effectcolor; + } + } + + } + UpdateProjectileHeldVariables(armPosition); + ManipulatePlayerVariables(); + } + + private void UpdateProjectileHeldVariables(Vector2 armPosition) + { + if (Main.myPlayer == Projectile.owner) + { + float interpolant = Utils.GetLerpValue(5f, 25f, Projectile.Distance(Main.MouseWorld), true); + Vector2 oldVelocity = Projectile.velocity; + Projectile.velocity = Vector2.Lerp(Projectile.velocity, Projectile.SafeDirectionTo(Main.MouseWorld), interpolant); + } + Projectile.Center = armPosition + Projectile.velocity * 20; + Projectile.rotation = Projectile.velocity.ToRotation() + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f); + Projectile.spriteDirection = Projectile.direction; + } + + private void ManipulatePlayerVariables() + { + Owner.ChangeDir(Projectile.direction); + Owner.heldProj = Projectile.whoAmI; + Owner.itemTime = 2; + Owner.itemAnimation = 2; + Owner.itemRotation = (Projectile.velocity * Projectile.direction).ToRotation(); + } + public override bool? CanDamage() => false; + } +} diff --git a/Projectiles/Ranged/ElementalFire.cs b/Projectiles/Ranged/ElementalFire.cs index c4ea55c70b..3e99af8777 100644 --- a/Projectiles/Ranged/ElementalFire.cs +++ b/Projectiles/Ranged/ElementalFire.cs @@ -23,29 +23,64 @@ namespace CalamityMod.Projectiles.Ranged Projectile.friendly = true; Projectile.ignoreWater = true; Projectile.DamageType = DamageClass.Ranged; - Projectile.penetrate = -1; + Projectile.penetrate = 5; Projectile.MaxUpdates = 4; Projectile.timeLeft = Lifetime; // 24 effectively - Projectile.usesIDStaticNPCImmunity = true; - Projectile.idStaticNPCHitCooldown = 8; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; } public override void AI() { + var effectcolor = Main.rand.Next(4) switch + { + 0 => Color.DeepSkyBlue, + 1 => Color.MediumSpringGreen, + 2 => Color.DarkOrange, + _ => Color.Violet, + }; + Time++; ColorType += 0.02f; // Determines particle size as well as hitbox - if (Time >= 5f) + if (Time >= 1f) Projectile.scale = 1.8f * Utils.GetLerpValue(5f, 30f, Time, true); else return; // Helps position it at the tip + if (Time == 1) + { + for (int i = 0; i < 12; i++) + { + float rotMulti = Main.rand.NextFloat(0.7f, 1.1f); + int dustType = Main.rand.NextBool() ? 66 : 247; + Dust dust = Dust.NewDustPerfect(Projectile.Center, dustType); + dust.scale = Main.rand.NextFloat(1.8f, 2.5f) - rotMulti; + dust.noGravity = true; + dust.velocity = Projectile.velocity.RotatedByRandom(0.5f * rotMulti) * Main.rand.NextFloat(0.5f, 1.8f) * rotMulti; + dust.alpha = Main.rand.Next(90, 150); + dust.color = effectcolor; + } + } + + if (Time > 9) + { + float dustArea = Main.rand.NextFloat(0.1f, 1.7f); + int dustType = Main.rand.NextBool() ? 66 : 247; + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(9, 9) + Projectile.velocity * Main.rand.NextFloat(-1.8f, 1.8f), dustType); + dust.scale = (1.8f - dustArea) * 0.65f; + dust.noGravity = true; + dust.velocity = new Vector2(4, 4).RotatedByRandom(100) * dustArea; + dust.alpha = Main.rand.Next(90, 150); + dust.color = effectcolor; + } + // Rainbow smokes of increasing opacity float smokeRot = MathHelper.ToRadians(3f); // *Rate of rotation per frame, not a constant rotation float hue = 0.5f * (ColorType % 1f) + 0.5f * Utils.GetLerpValue(30f, Lifetime, Time, true) * MathF.Sin(Main.GlobalTimeWrappedHourly * 5f); - Color smokeColor = Main.hslToRgb(hue, 1f, 0.8f); - Particle smoke = new HeavySmokeParticle(Projectile.Center, Projectile.velocity * 0.5f, smokeColor, 12, Projectile.scale * Main.rand.NextFloat(0.6f, 1.2f), 0.3f, smokeRot, true, required: true); + Color smokeColor = Main.hslToRgb(hue, 1f, 0.7f); + Particle smoke = new HeavySmokeParticle(Projectile.Center, Projectile.velocity * 0.5f, smokeColor, 12, Projectile.scale * Main.rand.NextFloat(0.6f, 1.2f), 0.45f, smokeRot, true, required: true); GeneralParticleHandler.SpawnParticle(smoke); // Overlay the glow on top, which is on the brighter side diff --git a/Projectiles/Ranged/ElementalFlare.cs b/Projectiles/Ranged/ElementalFlare.cs index 3e32e4f807..5adc2f48d7 100644 --- a/Projectiles/Ranged/ElementalFlare.cs +++ b/Projectiles/Ranged/ElementalFlare.cs @@ -132,7 +132,7 @@ namespace CalamityMod.Projectiles.Ranged float hue = 0.5f + 0.5f * i / (float)Projectile.oldPos.Length * MathF.Sin(Main.GlobalTimeWrappedHourly * 5f); Color color = Main.hslToRgb(hue, 1f, 0.6f); Vector2 drawPosition = Projectile.oldPos[i] + lightTexture.Size() * 0.5f - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY) + new Vector2(-15f, -15f); - Color outerColor = color; + Color outerColor = color * 2f; Color innerColor = Color.Lerp(color, Color.White, 0.2f) * 0.5f; float intensity = 0.9f + 0.15f * MathF.Cos(Main.GlobalTimeWrappedHourly % 60f * MathHelper.TwoPi); diff --git a/Projectiles/Ranged/TerraFire.cs b/Projectiles/Ranged/TerraFire.cs index 3e8c266019..ea49e162a7 100644 --- a/Projectiles/Ranged/TerraFire.cs +++ b/Projectiles/Ranged/TerraFire.cs @@ -22,19 +22,33 @@ namespace CalamityMod.Projectiles.Ranged Projectile.friendly = true; Projectile.ignoreWater = true; Projectile.DamageType = DamageClass.Ranged; - Projectile.penetrate = -1; - Projectile.MaxUpdates = 4; + Projectile.penetrate = 4; + Projectile.MaxUpdates = 5; Projectile.timeLeft = Lifetime; // 24 effectively - Projectile.usesIDStaticNPCImmunity = true; - Projectile.idStaticNPCHitCooldown = 8; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; } public override void AI() { Time++; + if (Time == 1) + { + MediumMistParticle smoke2 = new MediumMistParticle(Projectile.Center + Main.rand.NextVector2Circular(5, 5), (Projectile.velocity * 1f).RotatedByRandom(0.15f) * Main.rand.NextFloat(0.2f, 2.1f), Color.Lime, Color.Turquoise, Main.rand.NextFloat(0.8f, 1.9f), 180, Main.rand.NextFloat(-3f, 3f)); + GeneralParticleHandler.SpawnParticle(smoke2); + MediumMistParticle smoke3 = new MediumMistParticle(Projectile.Center + Main.rand.NextVector2Circular(5, 5), (Projectile.velocity * 2).RotatedByRandom(0.05f) * Main.rand.NextFloat(0.2f, 2.1f), Color.Lime, Color.Turquoise, Main.rand.NextFloat(0.4f, 1.1f), 180, Main.rand.NextFloat(-3f, 3f)); + GeneralParticleHandler.SpawnParticle(smoke3); + for (int i = 0; i < 9; i++) + { + Dust dust2 = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(5) ? 135 : 107); + dust2.noGravity = true; + dust2.velocity = Projectile.velocity.RotatedByRandom(0.7f) * Main.rand.NextFloat(0.3f, 2.9f); + dust2.scale = Main.rand.NextFloat(1.3f, 2.1f); + } + } // Determines particle size as well as hitbox - if (Time >= 6f) + if (Time >= 1f) Projectile.scale = 1.8f * Utils.GetLerpValue(6f, 30f, Time, true); else return; // Helps position it at the tip @@ -42,9 +56,21 @@ namespace CalamityMod.Projectiles.Ranged // Main smokes shifting between green to green-blue and back float smokeRot = MathHelper.ToRadians(3f); // *Rate of rotation per frame, not a constant rotation float colorValue = CalamityUtils.Convert01To010(Utils.GetLerpValue(30f, Lifetime, Time, true)); - Color smokeColor = BlueFire ? Color.Lerp(Color.Cyan, Color.Aquamarine, colorValue) : Color.Lerp(Color.Lime, Color.SpringGreen, colorValue); - Particle smoke = new HeavySmokeParticle(Projectile.Center, Projectile.velocity * 0.5f, smokeColor, 12, Projectile.scale * Main.rand.NextFloat(0.6f, 1.2f), 0.3f, smokeRot, true, required: true); + Color smokeColor = Color.Lerp(Color.Lime, Color.Turquoise, colorValue); + Particle smoke = new HeavySmokeParticle(Projectile.Center, Projectile.velocity * 0.5f, smokeColor, 18, Projectile.scale * Main.rand.NextFloat(0.6f, 1.2f), 0.4f, smokeRot, true, required: true); GeneralParticleHandler.SpawnParticle(smoke); + + if (Time > 4) + { + for (int i = 0; i < 2; i++) + { + float dustArea = Main.rand.NextFloat(0.1f, 1.7f); + Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(9, 9) + Projectile.velocity * Main.rand.NextFloat(-1.8f, 1.8f), Main.rand.NextBool(5) ? 135 : 107); + dust.noGravity = true; + dust.velocity = new Vector2(6, 6).RotatedByRandom(100) * dustArea; + dust.scale = (1.8f - dustArea) * 0.65f; + } + } // Overlay a gold glow on top if (Main.rand.NextBool(5)) diff --git a/Projectiles/Ranged/TerraFlamebursterHouldout.cs b/Projectiles/Ranged/TerraFlamebursterHouldout.cs new file mode 100644 index 0000000000..68ba520f27 --- /dev/null +++ b/Projectiles/Ranged/TerraFlamebursterHouldout.cs @@ -0,0 +1,128 @@ +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Particles; +using log4net.Core; +using Microsoft.Xna.Framework; +using Mono.Cecil; +using ReLogic.Utilities; +using System; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class TerraFlamebursterHoldout : ModProjectile + { + // Take the name and texture from the weapon + public override LocalizedText DisplayName => CalamityUtils.GetItemName(); + public override string Texture => "CalamityMod/Items/Weapons/Ranged/TerraFlameburster"; + private Player Owner => Main.player[Projectile.owner]; + private ref float ShotsFired => ref Projectile.ai[1]; + private ref float ShootTimer => ref Projectile.ai[2]; + private ref int ShotDelay => ref Owner.ActiveItem().useTime; // 8 + public int ShotCooldown; + public int FireBlobs = 0; + private bool OwnerCanShoot => Owner.channel && !Owner.noItems && !Owner.CCed; + + public override void SetDefaults() + { + Projectile.width = 68; + Projectile.height = 26; + Projectile.friendly = true; + Projectile.tileCollide = false; + Projectile.DamageType = DamageClass.Ranged; + Projectile.ignoreWater = true; + } + + public override void AI() + { + if (Owner.dead || ShotsFired >= 16) // destroy the holdout if the player dies or is out of shots + { + Projectile.Kill(); + return; + } + + Vector2 armPosition = Owner.RotatedRelativePoint(Owner.MountedCenter, true); + Vector2 tipPosition = armPosition + Projectile.velocity * Projectile.width * 0.8f; + + // Kill if the owner stops channeling or otherwise cannot use the weapon. + if (!OwnerCanShoot) + { + Projectile.Kill(); + } + else + { + // While channeled, keep refreshing the projectile lifespan + Projectile.timeLeft = 2; + + ShootTimer++; + if (ShootTimer >= 60) + { + if (ShotCooldown == 0) + { + SoundEngine.PlaySound(SoundID.Item34, Projectile.Center); + Owner.PickAmmo(Owner.ActiveItem(), out _, out float shootSpeed, out int damage, out float knockback, out _, Main.rand.NextBool(2) ? true : false); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), tipPosition, (Projectile.velocity * 9).RotatedByRandom(0.08f), ModContent.ProjectileType(), damage, knockback, Projectile.owner); + ShotsFired++; + ShotCooldown = ShotDelay; + if (FireBlobs == 0) + { + float randAngle = Main.rand.NextFloat(8f, 15f); + Vector2 newVel = (Projectile.velocity * 9).RotatedBy(MathHelper.ToRadians(randAngle)) * 2f; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), tipPosition, newVel, ModContent.ProjectileType(), damage, knockback, Projectile.owner); + newVel = (Projectile.velocity * 9).RotatedBy(MathHelper.ToRadians(-randAngle)) * 2f; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), tipPosition, newVel, ModContent.ProjectileType(), damage, knockback, Projectile.owner); + FireBlobs = 3; + } + else + FireBlobs--; + } + else + ShotCooldown--; + } + else + { + if (ShootTimer == 1) + SoundEngine.PlaySound(SoundID.Item73 with { Volume = 0.7f}, Projectile.Center); + ShotsFired = 0; + for (int i = 0; i < 2; i++) + { + float rotMulti = Main.rand.NextFloat(0.3f, 1f); + Dust dust2 = Dust.NewDustPerfect(tipPosition, Main.rand.NextBool(5) ? 135 : 107); + dust2.noGravity = true; + dust2.velocity = new Vector2(0, -2).RotatedByRandom(rotMulti * 0.3f) * (Main.rand.NextFloat(1f, 2.9f) - rotMulti); + dust2.scale = Main.rand.NextFloat(1.2f, 1.8f) * (ShootTimer * 0.015f); + } + } + + } + UpdateProjectileHeldVariables(armPosition); + ManipulatePlayerVariables(); + } + + private void UpdateProjectileHeldVariables(Vector2 armPosition) + { + if (Main.myPlayer == Projectile.owner) + { + float interpolant = Utils.GetLerpValue(5f, 25f, Projectile.Distance(Main.MouseWorld), true); + Vector2 oldVelocity = Projectile.velocity; + Projectile.velocity = Vector2.Lerp(Projectile.velocity, Projectile.SafeDirectionTo(Main.MouseWorld), interpolant); + } + Projectile.Center = armPosition + Projectile.velocity * 20; + Projectile.rotation = Projectile.velocity.ToRotation() + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f); + Projectile.spriteDirection = Projectile.direction; + } + + private void ManipulatePlayerVariables() + { + Owner.ChangeDir(Projectile.direction); + Owner.heldProj = Projectile.whoAmI; + Owner.itemTime = 2; + Owner.itemAnimation = 2; + Owner.itemRotation = (Projectile.velocity * Projectile.direction).ToRotation(); + } + public override bool? CanDamage() => false; + } +} diff --git a/Projectiles/Ranged/TerraFlare.cs b/Projectiles/Ranged/TerraFlare.cs index ac151cb371..9bbfe20c28 100644 --- a/Projectiles/Ranged/TerraFlare.cs +++ b/Projectiles/Ranged/TerraFlare.cs @@ -29,18 +29,19 @@ namespace CalamityMod.Projectiles.Ranged Projectile.MaxUpdates = 2; Projectile.timeLeft = 90 * Projectile.MaxUpdates; Projectile.DamageType = DamageClass.Ranged; + Projectile.tileCollide = false; } - public override void AI() => CalamityUtils.HomeInOnNPC(Projectile, false, 640f, 15f, 20f); + public override void AI() => CalamityUtils.HomeInOnNPC(Projectile, true, 640f, 15f, 20f); public override void OnKill(int timeLeft) { // Circular spread of clouds for (int i = 0; i < 8; i++) { - Vector2 smokeVel = Main.rand.NextVector2Circular(16f, 16f); - Color smokeColor = Main.rand.NextBool() ? Color.Lime : Color.Cyan; - Particle smoke = new MediumMistParticle(Projectile.Center, smokeVel, smokeColor, Color.Black, Main.rand.NextFloat(0.6f, 1.6f), 200 - Main.rand.Next(60), 0.1f); + Vector2 smokeVel = Main.rand.NextVector2Circular(8f, 8f); + Color smokeColor = Main.rand.NextBool() ? Color.Lime : Color.Turquoise; + Particle smoke = new MediumMistParticle(Projectile.Center, smokeVel, smokeColor, Color.Black, Main.rand.NextFloat(0.4f, 0.8f), 200 - Main.rand.Next(60), 0.1f); GeneralParticleHandler.SpawnParticle(smoke); } } @@ -51,7 +52,7 @@ namespace CalamityMod.Projectiles.Ranged for (int i = 0; i < Projectile.oldPos.Length; i++) { float colorInterpolation = MathF.Cos(Projectile.timeLeft / 16f + Main.GlobalTimeWrappedHourly / 20f + i / (float)Projectile.oldPos.Length * MathHelper.Pi) * 0.5f + 0.5f; - Color color = Color.Lerp(Color.Lime, Color.Cyan, colorInterpolation); + Color color = Color.Lerp(Color.Lime, Color.Turquoise, colorInterpolation); Vector2 drawPosition = Projectile.oldPos[i] + lightTexture.Size() * 0.5f - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY) + new Vector2(-15f, -15f); Color outerColor = color; Color innerColor = Color.Lerp(color, Color.Gold, 0.8f) * 0.5f;