diff --git a/Balancing/BalancingChangesManager.cs b/Balancing/BalancingChangesManager.cs index fa67d3f1e5..23b231907c 100644 --- a/Balancing/BalancingChangesManager.cs +++ b/Balancing/BalancingChangesManager.cs @@ -204,12 +204,12 @@ namespace CalamityMod.Balancing // 50% resist to true melee. NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.AstrumDeus, Do(ResistTrueMelee(0.5f)))); - // 50% resist to Charged Blaster Cannon. - NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.AstrumDeus, Do(new ProjectileResistBalancingRule(0.5f, ProjectileID.ChargedBlasterLaser)))); - // 50% resist to Atlantis (Atlantis gaming!). NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.AstrumDeus, Do(new ProjectileResistBalancingRule(0.5f, ProjectileType())))); + // 50% resist to Charged Blaster Cannon. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.AstrumDeus, Do(new ProjectileResistBalancingRule(0.5f, ProjectileID.ChargedBlasterLaser)))); + // 35% resist to Aerial Bane. NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.AstrumDeus, Do(new ProjectileResistBalancingRule(0.65f, ProjectileID.DD2BetsyArrow)))); @@ -293,11 +293,11 @@ namespace CalamityMod.Balancing // 65% resist to Wave Pounder. NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.DevourerOfGods, Do(new ProjectileResistBalancingRule(0.35f, ProjectileType())))); - // 35% resist to Sulphuric Acid Cannon's explosions. - NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.DevourerOfGods, Do(new ProjectileResistBalancingRule(0.65f, ProjectileType())))); - // 60% resist to Corinth Prime's grenades. NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.DevourerOfGods, Do(new ProjectileResistBalancingRule(0.4f, ProjectileType())))); + + // 35% resist to Sulphuric Acid Cannon's explosions. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.DevourerOfGods, Do(new ProjectileResistBalancingRule(0.65f, ProjectileType())))); // 20% resist to Valediction's typhoons; will catch Nuclear Fury as well but that doesn't matter. NPCSpecificBalancingChanges.AddRange(Bundle(CalamityNPCTypeSets.DevourerOfGods, Do(new ProjectileResistBalancingRule(0.8f, ProjectileType())))); diff --git a/Buffs/DamageOverTime/HeavyBleeding.cs b/Buffs/DamageOverTime/HeavyBleeding.cs index 48bc271513..49782c6cb6 100644 --- a/Buffs/DamageOverTime/HeavyBleeding.cs +++ b/Buffs/DamageOverTime/HeavyBleeding.cs @@ -3,6 +3,7 @@ using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; +using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; @@ -40,14 +41,14 @@ namespace CalamityMod.Buffs.DamageOverTime if (Main.rand.NextBool(3)) { Vector2 randVel = new Vector2(5, 5).RotatedByRandom(100) * Main.rand.NextFloat(0.3f, 1f); - Dust dust = Dust.NewDustPerfect(modPlayer.RandomDebuffVisualSpot, DustID.Blood, randVel * Main.rand.NextFloat(0.1f, 0.8f), 100, default, Main.rand.NextFloat(0.6f, 0.9f)); + Dust dust = Dust.NewDustPerfect(modPlayer.RandomDebuffVisualSpot, (!ChildSafety.Disabled ? DustID.Cloud : DustID.Blood), randVel * Main.rand.NextFloat(0.1f, 0.8f), 100, default, Main.rand.NextFloat(0.6f, 0.9f)); dust.noGravity = false; - Particle spark = new AltSparkParticle(modPlayer.RandomDebuffVisualSpot, randVel + new Vector2(0, -4), true, 12, Main.rand.NextFloat(0.25f, 0.6f), Color.DarkRed * 0.5f); + Particle spark = new AltSparkParticle(modPlayer.RandomDebuffVisualSpot, randVel + new Vector2(0, -4), true, 12, Main.rand.NextFloat(0.25f, 0.6f), (!ChildSafety.Disabled ? Color.CornflowerBlue : Color.DarkRed) * 0.5f); GeneralParticleHandler.SpawnParticle(spark); } if (Main.rand.NextBool(8)) { - Particle spark = new GlowOrbParticle(modPlayer.RandomDebuffVisualSpot, new Vector2(0, 4) * Main.rand.NextFloat(0.5f, 0.7f), true, 16, Main.rand.NextFloat(0.55f, 0.8f), Color.DarkRed * 0.8f, false, false, false); + Particle spark = new GlowOrbParticle(modPlayer.RandomDebuffVisualSpot, new Vector2(0, 4) * Main.rand.NextFloat(0.5f, 0.7f), true, 16, Main.rand.NextFloat(0.55f, 0.8f), (!ChildSafety.Disabled ? Color.CornflowerBlue : Color.DarkRed) * 0.8f, false, false, false); GeneralParticleHandler.SpawnParticle(spark); } } @@ -58,17 +59,17 @@ namespace CalamityMod.Buffs.DamageOverTime Vector2 randVel = new Vector2(5, 5).RotatedByRandom(100) * Main.rand.NextFloat(0.3f, 1f); if (Main.rand.NextBool(5)) { - Particle spark = new AltSparkParticle(npcSize, randVel + new Vector2(0, -4), true, 12, Main.rand.NextFloat(0.25f, 0.6f), Color.DarkRed * 0.5f); + Particle spark = new AltSparkParticle(npcSize, randVel + new Vector2(0, -4), true, 12, Main.rand.NextFloat(0.25f, 0.6f), (!ChildSafety.Disabled ? Color.CornflowerBlue : Color.DarkRed) * 0.5f); GeneralParticleHandler.SpawnParticle(spark); } else { - Dust dust = Dust.NewDustPerfect(npcSize, DustID.Blood, randVel * Main.rand.NextFloat(0.1f, 0.8f), 100, default, Main.rand.NextFloat(0.2f, 0.6f)); + Dust dust = Dust.NewDustPerfect(npcSize, (!ChildSafety.Disabled ? DustID.Cloud : DustID.Blood), randVel * Main.rand.NextFloat(0.1f, 0.8f), 100, default, Main.rand.NextFloat(0.2f, 0.6f)); dust.noGravity = false; } if (Main.rand.NextBool(8)) { - Particle spark = new GlowOrbParticle(npcSize, new Vector2(0, 4) * Main.rand.NextFloat(0.5f, 0.7f), true, 16, Main.rand.NextFloat(0.55f, 0.8f), Color.DarkRed * 0.8f, false, false, false); + Particle spark = new GlowOrbParticle(npcSize, new Vector2(0, 4) * Main.rand.NextFloat(0.5f, 0.7f), true, 16, Main.rand.NextFloat(0.55f, 0.8f), (!ChildSafety.Disabled ? Color.CornflowerBlue : Color.DarkRed) * 0.8f, false, false, false); GeneralParticleHandler.SpawnParticle(spark); } } diff --git a/Buffs/DamageOverTime/Laceration.cs b/Buffs/DamageOverTime/Laceration.cs index 2f77bebe8f..8e50c0422d 100644 --- a/Buffs/DamageOverTime/Laceration.cs +++ b/Buffs/DamageOverTime/Laceration.cs @@ -3,6 +3,7 @@ using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; +using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; @@ -40,14 +41,14 @@ namespace CalamityMod.Buffs.DamageOverTime if (Main.rand.NextBool()) { Vector2 randVel = new Vector2(6, 6).RotatedByRandom(100) * Main.rand.NextFloat(0.3f, 1f); - Dust dust = Dust.NewDustPerfect(modPlayer.RandomDebuffVisualSpot, DustID.Blood, randVel * Main.rand.NextFloat(0.1f, 0.8f), 100, default, Main.rand.NextFloat(0.6f, 0.9f)); + Dust dust = Dust.NewDustPerfect(modPlayer.RandomDebuffVisualSpot, (!ChildSafety.Disabled ? DustID.Cloud : DustID.Blood), randVel * Main.rand.NextFloat(0.1f, 0.8f), 100, default, Main.rand.NextFloat(0.6f, 0.9f)); dust.noGravity = false; - Particle spark = new AltSparkParticle(modPlayer.RandomDebuffVisualSpot, randVel + new Vector2(0, -4), true, 12, Main.rand.NextFloat(0.25f, 0.6f), Color.DarkRed * 0.5f); + Particle spark = new AltSparkParticle(modPlayer.RandomDebuffVisualSpot, randVel + new Vector2(0, -4), true, 12, Main.rand.NextFloat(0.25f, 0.6f), (!ChildSafety.Disabled ? Color.CornflowerBlue : Color.DarkRed) * 0.5f); GeneralParticleHandler.SpawnParticle(spark); } if (Main.rand.NextBool(8)) { - Particle spark = new GlowOrbParticle(modPlayer.RandomDebuffVisualSpot, new Vector2(0, 4) * Main.rand.NextFloat(0.5f, 0.7f), true, 16, Main.rand.NextFloat(0.55f, 0.8f), Color.DarkRed * 0.8f, false, false, false); + Particle spark = new GlowOrbParticle(modPlayer.RandomDebuffVisualSpot, new Vector2(0, 4) * Main.rand.NextFloat(0.5f, 0.7f), true, 16, Main.rand.NextFloat(0.55f, 0.8f), (!ChildSafety.Disabled ? Color.CornflowerBlue : Color.DarkRed) * 0.8f, false, false, false); GeneralParticleHandler.SpawnParticle(spark); } } @@ -58,17 +59,17 @@ namespace CalamityMod.Buffs.DamageOverTime Vector2 randVel = new Vector2(6, 6).RotatedByRandom(100) * Main.rand.NextFloat(0.3f, 1f); if (Main.rand.NextBool(3)) { - Particle spark = new AltSparkParticle(npcSize, randVel + new Vector2(0, -4), true, 12, Main.rand.NextFloat(0.25f, 0.6f), Color.DarkRed * 0.5f); + Particle spark = new AltSparkParticle(npcSize, randVel + new Vector2(0, -4), true, 12, Main.rand.NextFloat(0.25f, 0.6f), (!ChildSafety.Disabled ? Color.CornflowerBlue : Color.DarkRed) * 0.5f); GeneralParticleHandler.SpawnParticle(spark); } else { - Dust dust = Dust.NewDustPerfect(npcSize, DustID.Blood, randVel * Main.rand.NextFloat(0.1f, 0.8f), 100, default, Main.rand.NextFloat(0.2f, 0.6f)); + Dust dust = Dust.NewDustPerfect(npcSize, (!ChildSafety.Disabled ? DustID.Cloud : DustID.Blood), randVel * Main.rand.NextFloat(0.1f, 0.8f), 100, default, Main.rand.NextFloat(0.2f, 0.6f)); dust.noGravity = false; } if (Main.rand.NextBool(8)) { - Particle spark = new GlowOrbParticle(npcSize, new Vector2(0, 4) * Main.rand.NextFloat(0.5f, 0.7f), true, 16, Main.rand.NextFloat(0.55f, 0.8f), Color.DarkRed * 0.8f, false, false, false); + Particle spark = new GlowOrbParticle(npcSize, new Vector2(0, 4) * Main.rand.NextFloat(0.5f, 0.7f), true, 16, Main.rand.NextFloat(0.55f, 0.8f), (!ChildSafety.Disabled ? Color.CornflowerBlue : Color.DarkRed) * 0.8f, false, false, false); GeneralParticleHandler.SpawnParticle(spark); } } diff --git a/Buffs/DamageOverTime/SearingLava.cs b/Buffs/DamageOverTime/SearingLava.cs index ca5641a4ba..708af57feb 100644 --- a/Buffs/DamageOverTime/SearingLava.cs +++ b/Buffs/DamageOverTime/SearingLava.cs @@ -1,4 +1,5 @@ -using CalamityMod.DataStructures; +using System; +using CalamityMod.DataStructures; using Terraria; using Terraria.ModLoader; @@ -10,8 +11,22 @@ namespace CalamityMod.Buffs.DamageOverTime public static DebuffData debuffData = new DebuffData() { EnemyLostRegen = 40, - HeatDebuffScaling = 2 + HeatDebuffScaling = 2, + NPCLifeRegenMethod = CragsLavaScaling }; + + public static void CragsLavaScaling(NPC npc, int buffType, ref int buffIndex, ref int damage) + { + //Applies the double Heat scaling but completely ignores NPC weakness/resistance to heat. + + //We need to apply slimed as that isn't included in HeatDebuffMultiplier due to needing to dynamically update if slimed is applied + StatModifier multiplier = npc.Calamity().HeatDebuffMultiplier; + if (npc.drippingSlime || npc.drippingSparkleSlime) + multiplier += 1f; + + int dotValue = (int)DebuffData.ApplyScalingToStatModifer(multiplier, debuffData.HeatDebuffScaling).ApplyTo(debuffData.EnemyLostRegen); + npc.Calamity().ApplyDPSDebuff(dotValue, (int)Math.Max(dotValue * debuffData.MultiplierDamageTickSize, debuffData.MinimumDamageTickSize), ref npc.lifeRegen, ref damage); + } public override void SetStaticDefaults() { Main.buffNoTimeDisplay[Type] = true; diff --git a/Buffs/DamageOverTime/Shred.cs b/Buffs/DamageOverTime/Shred.cs index bd168fd492..de47a1c423 100644 --- a/Buffs/DamageOverTime/Shred.cs +++ b/Buffs/DamageOverTime/Shred.cs @@ -5,6 +5,7 @@ using CalamityMod.Projectiles; using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Terraria; +using Terraria.GameContent; using Terraria.ModLoader; namespace CalamityMod.Buffs.DamageOverTime @@ -100,7 +101,7 @@ namespace CalamityMod.Buffs.DamageOverTime int bloodLifetime = Main.rand.Next(22, 36); float bloodScale = Main.rand.NextFloat(0.6f, 0.8f); Color bloodColor = Color.Lerp(Color.Red, Color.DarkRed, Main.rand.NextFloat()); - bloodColor = Color.Lerp(bloodColor, new Color(51, 22, 94), Main.rand.NextFloat(0.65f)); + bloodColor = (!ChildSafety.Disabled ? Color.CornflowerBlue : Color.Lerp(bloodColor, new Color(51, 22, 94), Main.rand.NextFloat(0.65f))); if (Main.rand.NextBool(20)) bloodScale *= 2f; @@ -114,7 +115,7 @@ namespace CalamityMod.Buffs.DamageOverTime for (int i = 0; i < exactBloodCount / 3; ++i) { float bloodScale = Main.rand.NextFloat(0.2f, 0.33f); - Color bloodColor = Color.Lerp(Color.Red, Color.DarkRed, Main.rand.NextFloat(0.5f, 1f)); + Color bloodColor = (!ChildSafety.Disabled ? Color.CornflowerBlue : Color.Lerp(Color.Red, Color.DarkRed, Main.rand.NextFloat(0.5f, 1f))); Vector2 bloodVelocity = Main.rand.NextVector2Unit() * velStackMult * Main.rand.NextFloat(1f, 2f); bloodVelocity.Y -= 2.3f; BloodParticle2 blood = new BloodParticle2(npc.Center, bloodVelocity, 20, bloodScale, bloodColor); diff --git a/Buffs/StatDebuffs/Irradiated.cs b/Buffs/StatDebuffs/Irradiated.cs index 8244acd871..21166569fe 100644 --- a/Buffs/StatDebuffs/Irradiated.cs +++ b/Buffs/StatDebuffs/Irradiated.cs @@ -1,4 +1,5 @@ -using CalamityMod.DataStructures; +using System; +using CalamityMod.DataStructures; using CalamityMod.Projectiles.Magic; using Terraria; using Terraria.ID; @@ -33,10 +34,9 @@ namespace CalamityMod.Buffs.StatDebuffs Player player = Main.player[playerIndex]; if (player.active) { - float playerRangedDamage = player.GetTotalDamage(DamageClass.Ranged).ApplyTo(baseIrradiatedDoTValue * (1 + player.GetTotalCritChance(DamageClass.Ranged) * 0.01f)); - if (playerRangedDamage > baseIrradiatedDoTValue && player.Calamity().scionsCurio) + if (player.Calamity().scionsCurioDebuffDamage > baseIrradiatedDoTValue && player.Calamity().scionsCurio) { - baseIrradiatedDoTValue = (int)playerRangedDamage; + baseIrradiatedDoTValue = (int)player.Calamity().scionsCurioDebuffDamage; } } } @@ -44,7 +44,7 @@ namespace CalamityMod.Buffs.StatDebuffs if (projectileCount > 0) cnpc.ApplyDPSDebuff(projectileCount * baseIrradiatedDoTValue, projectileCount * 4, ref npc.lifeRegen, ref damage); else - cnpc.ApplyDPSDebuff(baseIrradiatedDoTValue, baseIrradiatedDoTValue / 20, ref npc.lifeRegen, ref damage); + cnpc.ApplyDPSDebuff(baseIrradiatedDoTValue, Math.Max((int)(baseIrradiatedDoTValue * debuffData.MultiplierDamageTickSize),debuffData.MinimumDamageTickSize), ref npc.lifeRegen, ref damage); } public override void SetStaticDefaults() { diff --git a/Buffs/Summon/BaseSummonBuff.cs b/Buffs/Summon/BaseSummonBuff.cs index 9fede4e1a2..de0d355b89 100644 --- a/Buffs/Summon/BaseSummonBuff.cs +++ b/Buffs/Summon/BaseSummonBuff.cs @@ -37,8 +37,8 @@ namespace CalamityMod.Buffs.Summon public override void Update(Player player, ref int buffIndex) { - BuffOwner ??= player; - BuffModdedOwner ??= player.Calamity(); + BuffOwner = player; + BuffModdedOwner = player.Calamity(); if (player.ownedProjectileCounts[MinionProjectileType] > 0) MinionBool = true; diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index c495db6dc1..205a0eea3a 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -194,7 +194,7 @@ namespace CalamityMod.CalPlayer DevourerofCods //Not a fishing minigame but uses the same code as the rest } public FishingMinigames SelectedFishingMinigame = FishingMinigames.None; - public bool countsAsAnyWet => (Player.armor[0].type == ItemID.FishBowl || (Main.raining && Player.Center.Y < Main.worldSurface * 16.0) || Player.dripping || Player.wetCount > 0 || Player.wet || Player.honeyWet || Player.lavaWet); + public bool countsAsAnyWet => (Player.armor[0].type == ItemID.FishBowl || (Main.IsItRaining && Player.Center.Y < Main.worldSurface * 16.0) || Player.dripping || Player.wetCount > 0 || Player.wet || Player.honeyWet || Player.lavaWet); /// /// How many Starbursts the player has @@ -544,6 +544,8 @@ namespace CalamityMod.CalPlayer /// An additional damage multiplier applied to rogue stealth strikes. Used by Filthy Glove, Rotten Dogtooth and their upgrades. public double bonusStealthDamage = 0; public float rogueVelocity = 1f; + + public int focusFlurryAttackCount = 0; #endregion #region Mount @@ -1113,6 +1115,7 @@ namespace CalamityMod.CalPlayer public bool scionsCurio = false; public bool scionsCurioGotHit = false; public bool scionsCurioVisuals = false; + public float scionsCurioDebuffDamage = 0; public bool miniOldDuke = false; public bool miniOldDukeVanity = false; public bool starbusterCore = false; @@ -1448,7 +1451,6 @@ namespace CalamityMod.CalPlayer public bool redWine = false; public float redWineStoredY = 0; public bool grapeBeer = false; - public int grapeBeerTimer = 0; public bool moonshine = false; public bool rum = false; public bool whiskey = false; @@ -2527,6 +2529,7 @@ namespace CalamityMod.CalPlayer fairyBoots = false; flameWakerBoots = false; hellfireTreads = false; + bootLevel = 0; sSpiritAmulet = false; dOfTheDeep = false; oceanCrest = false; @@ -2730,8 +2733,6 @@ namespace CalamityMod.CalPlayer vodka = false; redWine = false; grapeBeer = false; - if (grapeBeerTimer > 0) - grapeBeerTimer--; moonshine = false; rum = false; whiskey = false; @@ -3783,6 +3784,14 @@ namespace CalamityMod.CalPlayer if (godSlayer && !Player.pulley && Player.grappling[0] == -1 && !Player.tongued && !Player.mount.Active && !Player.HasCooldown(GodSlayerDash.ID) && Player.dashDelay == 0) { godSlayerDashHotKeyPressed = true; + foreach (Projectile p in Main.ActiveProjectiles) + { + if (p.type == ProjectileType() && Player.whoAmI == p.owner) + { + (p.ModProjectile as RelicOfDeliveranceSpear).KillProj(); + return; + } + } } } @@ -4927,6 +4936,13 @@ namespace CalamityMod.CalPlayer } } + if (scionsCurio) + { + scionsCurioDebuffDamage = Player.GetTotalDamage(DamageClass.Ranged).ApplyTo(Irradiated.debuffData.EnemyLostRegen * (1 + Player.GetTotalCritChance(DamageClass.Ranged) * 0.01f)); + } + else + scionsCurioDebuffDamage = 0; + // True melee damage from various vanilla equipment placed here. // Titan Glove and ALL upgrades. diff --git a/CalPlayer/CalamityPlayerFishing.cs b/CalPlayer/CalamityPlayerFishing.cs index 1aaf851c35..8fa30268a7 100644 --- a/CalPlayer/CalamityPlayerFishing.cs +++ b/CalPlayer/CalamityPlayerFishing.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using CalamityMod.Events; using CalamityMod.Items.Accessories; using CalamityMod.Items.Accessories.Vanity; @@ -30,7 +31,6 @@ using Terraria.DataStructures; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; -using Terraria.UI; namespace CalamityMod.CalPlayer { @@ -49,15 +49,15 @@ namespace CalamityMod.CalPlayer // If the player does get a crate (can be from the reroll above), give it increased chances of being rarer if (attempt.crate) { - int uncommonRate = Math.Clamp(240 / attempt.fishingLevel, 3, 240); // Iron/Mythril (originally 300) + int uncommonRate = Math.Clamp(240 / attempt.fishingLevel, 3, 240); // Iron/Mythril (originally 300) attempt.uncommon = Main.rand.NextBool(uncommonRate); // These roll result bools are individually stored for the rarifying visuals - int rareRate = Math.Clamp(840 / attempt.fishingLevel, 4, 840); // Biome (originally 1050) + int rareRate = Math.Clamp(840 / attempt.fishingLevel, 4, 840); // Biome (originally 1050) bool rareRoll = Main.rand.NextBool(rareRate); attempt.rare = rareRoll; - int veryRareRate = Math.Clamp(1800 / attempt.fishingLevel, 5, 1800); // Golden/Titanium (originally 2250) + int veryRareRate = Math.Clamp(1800 / attempt.fishingLevel, 5, 1800); // Golden/Titanium (originally 2250) bool veryRareRoll = Main.rand.NextBool(veryRareRate); attempt.veryrare = veryRareRoll; @@ -86,6 +86,13 @@ namespace CalamityMod.CalPlayer } #endregion + public override bool? CanConsumeBait(Item bait) + { + if (bait.type == ModContent.ItemType()) + return true; + return null; + } + #region Catch Fish public override void CatchFish(FishingAttempt attempt, ref int itemDrop, ref int npcSpawn, ref AdvancedPopupRequest sonar, ref Vector2 sonarPosition) { @@ -128,7 +135,7 @@ namespace CalamityMod.CalPlayer // Fishing in lava overrides the rest of logic if (lava) { - // Don't do anything if you can't fish in lava + // Don't do anything if you can't fish in lava if (!attempt.CanFishInLava) return; @@ -173,8 +180,10 @@ namespace CalamityMod.CalPlayer // Old Duke spawn if (canSulphurFish && bait == ModContent.ItemType() && !BossRushEvent.BossRushActive) { - CalamityGlobalNPC.OldDukeSpawn(Player.whoAmI, ModContent.NPCType(), bait); + if (!Main.projectile.Any(x => x.active && x.aiStyle == ProjAIStyleID.Bobber && x.ai[1] != 0 && x.localAI[1] == ModContent.NPCType() * -1)) + npcSpawn = ModContent.NPCType(); itemDrop = -1; + sonar.Text = ""; return; } @@ -242,7 +251,7 @@ namespace CalamityMod.CalPlayer return; // Add top priorities of our own - if (DownedBossSystem.downedLeviathan && attempt.legendary && poolSize > 1000) + if (DownedBossSystem.downedLeviathan && attempt.legendary && poolSize > 1000 && !Main.rand.NextBool(3)) { itemDrop = ModContent.ItemType(); return; diff --git a/CalPlayer/CalamityPlayerHitHurt.cs b/CalPlayer/CalamityPlayerHitHurt.cs index ccf037f590..b2c2b82d7c 100644 --- a/CalPlayer/CalamityPlayerHitHurt.cs +++ b/CalPlayer/CalamityPlayerHitHurt.cs @@ -174,7 +174,7 @@ namespace CalamityMod.CalPlayer // Xyk vanity death animation if (XykVisualsBlue || XykVisualsOrange) { - Projectile.NewProjectile(Player.GetSource_FromThis(), Player.Center, Vector2.Zero, ModContent.ProjectileType(), Main.zenithWorld ? Main.rand.Next(5000, 50000 + 1) : 0, 0, Player.whoAmI); + Projectile.NewProjectile(Player.GetSource_FromThis(), Player.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0, Player.whoAmI); } if (holyInferno) @@ -857,7 +857,7 @@ namespace CalamityMod.CalPlayer int mirrorDamage = (int)MathHelper.Min(actualProjDamage, 1000) * 50; for (var i = 0; i < 5; i++) { - Projectile.NewProjectile(source, Player.Center + Vector2.UnitX.RotatedBy(MathHelper.TwoPi * (i / 10f)), Vector2.Zero, ModContent.ProjectileType(), mirrorDamage, 5, Main.myPlayer, 1); + Projectile.NewProjectile(source, Player.Center + Vector2.UnitX.RotatedBy(MathHelper.TwoPi * (i / 5f)), Vector2.Zero, ModContent.ProjectileType(), mirrorDamage, 5, Main.myPlayer, 1); } } projTypeJustHitBy = proj.type; @@ -1308,7 +1308,7 @@ namespace CalamityMod.CalPlayer if (alchFlask) { - for (int i = 0; i < 9; i++) + for (int i = 0; i < (Player.strongBees ? 12 : 9); i++) { int seekerDamage = (int)Player.GetBestClassDamage().ApplyTo(15); @@ -1675,6 +1675,10 @@ namespace CalamityMod.CalPlayer private void ModifyHurtInfo_Calamity(ref Player.HurtInfo info) { + // Don't run any of this code if the hit was cancelled. + if (info.Cancelled) + return; + // Boss Rush's damage floor is implemented as a dirty modifier // TODO -- implementing this correctly would require fully reimplementing all of DR and ADR if (BossRushEvent.BossRushActive) @@ -1987,7 +1991,7 @@ namespace CalamityMod.CalPlayer double halfDefense = Player.statDefense / 2.0; if (bloodflareCore) specialDefenseDmgMinimum += halfDefense; - if (moonshine) //Moonshine also halves defense damage recovery alongside forcing 50% of defense as defense damage + if (moonshine) //Moonshine also reduces defense damage recovery by 2/3 alongside forcing 50% of defense as defense damage specialDefenseDmgMinimum += halfDefense; int netMitigation = hurtInfo.SourceDamage - hurtInfo.Damage; double standardDefenseDamage = netMitigation * defenseDamageRatio; @@ -2806,7 +2810,8 @@ namespace CalamityMod.CalPlayer defenseDamageRecoveryFrames = 0; // Directly add the base defense damage recovery time to whatever recovery time the player already has. - totalDefenseDamageRecoveryFrames = defenseDamageRecoveryFrames + DefenseDamageBaseRecoveryTime; + int baseTime = DefenseDamageBaseRecoveryTime * (moonshine ? 3 : 1); + totalDefenseDamageRecoveryFrames = defenseDamageRecoveryFrames + baseTime; if (totalDefenseDamageRecoveryFrames > DefenseDamageMaxRecoveryTime) totalDefenseDamageRecoveryFrames = DefenseDamageMaxRecoveryTime; diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index 20dae2332e..22393e1055 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -49,6 +49,7 @@ using CalamityMod.NPCs; using CalamityMod.NPCs.AcidRain; using CalamityMod.NPCs.Astral; using CalamityMod.NPCs.Crags; +using CalamityMod.NPCs.DevourerofGods; using CalamityMod.NPCs.NormalNPCs; using CalamityMod.NPCs.Other; using CalamityMod.NPCs.PlagueEnemies; @@ -634,7 +635,7 @@ namespace CalamityMod.CalPlayer } - if (cinnamonRoll) + if (cinnamonRoll && !(Main.getGoodWorld && Main.npc.Any(x=> x.active && x.type == ModContent.NPCType()))) { if (dashStart) Player.velocity.X *= 3; @@ -1398,6 +1399,9 @@ namespace CalamityMod.CalPlayer Player.lavaTime++; } } + // Extra DoT in the lava of the crags. Negated by Flame-licked Shell. + else if (ZoneCalamity && !flameLickedShell) + Player.AddBuff(ModContent.BuffType(), 2, false); // Release irradiated slimes from the sky during the Acid Rain event. if (Player.whoAmI == Main.myPlayer) @@ -1688,10 +1692,9 @@ namespace CalamityMod.CalPlayer } // The fire boots debuff boosts - if (hellfireTreads) - HeatDebuffMultiplier += 0.5f; - else if (flameWakerBoots) - HeatDebuffMultiplier += 0.25f; + // bootLevel exists SO THAT THEY DO NOT STACK. Please help me maintain my sanity so we're not "fixing" this issue seventy times + if (bootLevel > 0) + HeatDebuffMultiplier += 0.25f * bootLevel; if (rOfResilienceEffect > 0) rOfResilienceEffect--; @@ -1859,7 +1862,7 @@ namespace CalamityMod.CalPlayer if (sSpiritAmulet) { - int spawnTime = 65; // Time between energy spawns + int spawnTime = 75; // Time between energy spawns int energyCap = 8; // Max number of energies that can be alive at a time Projectile projectile = null; @@ -1876,7 +1879,7 @@ namespace CalamityMod.CalPlayer } } if (energyCount > 0) - sSpiritAmuletTimer = -spawnTime; // The spawn cooldown after launching energies is twice as long + sSpiritAmuletTimer = -spawnTime * 3; // The spawn cooldown after launching energies is much longer } int numOfEnergy = 0; for (int x = 0; x < Main.maxProjectiles; x++) // Get a count of energies in idle mode @@ -1889,7 +1892,7 @@ namespace CalamityMod.CalPlayer { if (numOfEnergy < energyCap) { - int energyDamage = (int)Player.GetBestClassDamage().ApplyTo(22); + int energyDamage = (int)Player.GetBestClassDamage().ApplyTo(8); Projectile energy = Projectile.NewProjectileDirect(Player.GetSource_FromThis(), Player.Center, (Vector2.One * 4).RotatedByRandom(MathHelper.TwoPi), ModContent.ProjectileType(), energyDamage, 0f, Player.whoAmI, 0, numOfEnergy); if (numOfEnergy + 1 == energyCap && Player.Calamity().sSpiritAmuletVisual) { @@ -2072,29 +2075,26 @@ namespace CalamityMod.CalPlayer zapActivity += 1; if (zapActivity <= 300 && zapActivity % 30 == 0) { - for (int arcProjCount = 0; arcProjCount < 3; arcProjCount++) + float maxDistance = 300f; + int target = -1; + foreach (NPC npc in Main.ActiveNPCs) { - float maxDistance = 300f; - int target = -1; - foreach (NPC npc in Main.ActiveNPCs) + float targetDist = Vector2.Distance(npc.Center, Player.Center); + if (targetDist < maxDistance && npc.Calamity().arcZapCooldown == 0 && npc.CanBeChasedBy()) { - float targetDist = Vector2.Distance(npc.Center, Player.Center); - if (targetDist < maxDistance && npc.Calamity().arcZapCooldown == 0 && npc.CanBeChasedBy()) - { - maxDistance = targetDist; - target = npc.whoAmI; - } + maxDistance = targetDist; + target = npc.whoAmI; } + } - if (target > 0) - { - unstableSelectedTarget = Main.npc[target]; - unstableSelectedTarget.Calamity().arcZapCooldown = 18; - int damage = (int)Player.GetBestClassDamage().ApplyTo(18); + if (target > 0) + { + unstableSelectedTarget = Main.npc[target]; + unstableSelectedTarget.Calamity().arcZapCooldown = 25; + int damage = (int)Player.GetBestClassDamage().ApplyTo(15); - Projectile.NewProjectile(Player.GetSource_FromThis(), new Vector2(Player.Center.X, Player.Center.Y - 20f), new Vector2(0f, -2f), ModContent.ProjectileType(), damage, 0f, Player.whoAmI, target, 3f); - target = -1; - } + Projectile.NewProjectile(Player.GetSource_FromThis(), new Vector2(Player.Center.X, Player.Center.Y - 20f), new Vector2(0f, -2f), ModContent.ProjectileType(), damage, 0f, Player.whoAmI, target, 5f); + target = -1; } } else if (zapActivity > 600) @@ -2201,8 +2201,6 @@ namespace CalamityMod.CalPlayer if (arsenalCooldown > 0) arsenalCooldown--; - if (Main.zenithWorld) - arsenalCooldown = 0; if (killModeCooldown > 0) killModeCooldown--; if (ascendantInsigniaCooldown > 0 && ascendantInsigniaBuffTime <= 0) @@ -2243,6 +2241,8 @@ namespace CalamityMod.CalPlayer raiderSoundCooldown--; if (astralStarRainCooldown > 0) astralStarRainCooldown--; + if (AbaddonCooldown > 0) + AbaddonCooldown--; if (VoidCooldown > 0) VoidCooldown--; if (ursaSergeantCooldown > 0) @@ -4778,7 +4778,7 @@ namespace CalamityMod.CalPlayer { totalDefenseDamage = 0; defenseDamageRecoveryFrames = 0; - totalDefenseDamageRecoveryFrames = DefenseDamageBaseRecoveryTime * (moonshine ? 2 : 1); + totalDefenseDamageRecoveryFrames = DefenseDamageBaseRecoveryTime; defenseDamageDelayFrames = 0; } } diff --git a/CalPlayer/CalamityPlayerOnHit.cs b/CalPlayer/CalamityPlayerOnHit.cs index fcb105800f..9468c24372 100644 --- a/CalPlayer/CalamityPlayerOnHit.cs +++ b/CalPlayer/CalamityPlayerOnHit.cs @@ -205,7 +205,7 @@ namespace CalamityMod.CalPlayer bool spawnChance = (Main.rand.Next(100) < ArcFlashRing.LightningSpawnPercent); if (arcFlashRing && spawnChance) { - int damage = (int)(hit.Damage * ArcFlashRing.LightningDamageMult * (hit.Crit ? 0.5f : 1) / (Player.Calamity().adrenalineModeActive ? Player.Calamity().GetAdrenalineDamage() + 1 : 1)); // 400% damage (uneffected by crits and adrenaline) + int damage = (int)(hit.Damage * ArcFlashRing.LightningDamageMult * (hit.Crit ? (1 / (Player.Calamity().critDamage + 2)) : 1) / (Player.Calamity().adrenalineModeActive ? Player.Calamity().GetAdrenalineDamage() + 1 : 1)); // 400% damage (uneffected by crits and adrenaline) Projectile bolt = Projectile.NewProjectileDirect(source, target.Center, Vector2.Zero, ProjectileType(), damage, 0f, Player.whoAmI, target.whoAmI); bolt.DamageType = hit.DamageType; @@ -411,7 +411,7 @@ namespace CalamityMod.CalPlayer { proj.active = true; // Okay so if a projectile manually kills itself on hit, it totally breaks the bolts. to prevent this we set them to active - int damage = (int)(hit.Damage * ArcFlashRing.LightningDamageMult * (hit.Crit ? 0.5f : 1) / (Player.Calamity().adrenalineModeActive ? Player.Calamity().GetAdrenalineDamage() + 1 : 1)); // 400% damage (uneffected by crits and adrenaline) + int damage = (int)(hit.Damage * ArcFlashRing.LightningDamageMult * (hit.Crit ? (1 / (Player.Calamity().critDamage + 2)) : 1) / (Player.Calamity().adrenalineModeActive ? Player.Calamity().GetAdrenalineDamage() + 1 : 1)); // 400% damage (uneffected by crits and adrenaline) Projectile bolt = Projectile.NewProjectileDirect(source, target.Center, Vector2.Zero, ProjectileType(), damage, 0f, Player.whoAmI, target.whoAmI, (globalProj.showArcFlash ? 0 : 1)); bolt.DamageType = hit.DamageType; @@ -702,7 +702,7 @@ namespace CalamityMod.CalPlayer bee.ArmorPenetration = 20; bee.penetrate = 2; bee.extraUpdates = 1; - AlchFlaskCooldown = 7; + AlchFlaskCooldown = Player.strongBees ? 6 : 7; } bool lifeAndShieldCondition = Player.statLife >= Player.statLifeMax2 && (!HasAnyEnergyShield || TotalEnergyShielding >= TotalMaxShieldDurability); @@ -1344,7 +1344,7 @@ namespace CalamityMod.CalPlayer if (manaOverloader) { double healMult = 0.1D - proj.numHits * 0.025D; - Player.SpawnLifeStealProjectile(target, proj, ProjectileType(), (int)Math.Round(damage * healMult), 1.5f); + Player.SpawnLifeStealProjectile(target, proj, ProjectileType(), (int)Math.Round(damage * healMult), 1.75f); } if (ataxiaMage) diff --git a/CalamityConfig.cs b/CalamityConfig.cs index 3935c1af0a..af43e1923a 100644 --- a/CalamityConfig.cs +++ b/CalamityConfig.cs @@ -300,12 +300,8 @@ namespace CalamityMod BossHealthBoost = Utils.Clamp(BossHealthBoost, MinBossHealthBoost, MaxBossHealthBoost); } - [Header("Gameplay")] #region General Gameplay Changes - - [BackgroundColor(192, 54, 64, 192)] - [DefaultValue(true)] - public bool SimplifyAccessoryReforge { get; set; } + [Header("Gameplay")] [BackgroundColor(192, 54, 64, 192)] [DefaultValue(true)] diff --git a/Effects/CalamityShaders.cs b/Effects/CalamityShaders.cs index 5dd18a0419..0e06aeef01 100644 --- a/Effects/CalamityShaders.cs +++ b/Effects/CalamityShaders.cs @@ -8,6 +8,8 @@ using Terraria.ModLoader; namespace CalamityMod.Effects { // TODO -- This can be made into a ModSystem with simple OnModLoad and Unload hooks. + // TODO: SOURCEGEN: Get rid of this loader and replace references with sourcegenned references + [Autoload(Side = ModSide.Client)] public sealed class CalamityShaders : ModSystem { @@ -262,6 +264,14 @@ namespace CalamityMod.Effects internal static Asset BrainOfCthulhuForcefield; #endregion + + #region jasper's shaders + internal static Asset NanoblackSlashShader; + + // static gaussian bloom, cannot change parameters. do not reuse this if that binds you. + internal static Asset GaussianBloomShader; + #endregion + internal static Asset SunkenSeaMenuLogoWater; @@ -519,6 +529,12 @@ namespace CalamityMod.Effects RegisterScreenShader(BrainOfCthulhuForcefield, "BoCShieldPass", "BrainOfCthulhuForcefield"); #endregion + NanoblackSlashShader = LoadShader("SlashEffects/NanoblackSlash"); + RegisterMiscShader(NanoblackSlashShader, "SlashPass", "NanoblackSlash"); + + GaussianBloomShader = LoadShader("SlashEffects/GaussianBloom"); + RegisterMiscShader(GaussianBloomShader, "BloomShader", "GaussianBloom"); + SunkenSeaMenuLogoWater = LoadShader("UI/SunkenSeaMenuLogoWater"); } diff --git a/Effects/Compiler/d3dcompiler_47.dll b/Effects/Compiler/d3dcompiler_47.dll new file mode 100644 index 0000000000..0439b1c68f Binary files /dev/null and b/Effects/Compiler/d3dcompiler_47.dll differ diff --git a/Effects/Compiler/fxc.exe b/Effects/Compiler/fxc.exe new file mode 100644 index 0000000000..b71eaaa87c Binary files /dev/null and b/Effects/Compiler/fxc.exe differ diff --git a/Effects/SlashEffects/GaussianBloom.fx b/Effects/SlashEffects/GaussianBloom.fx new file mode 100644 index 0000000000..b051e47be5 --- /dev/null +++ b/Effects/SlashEffects/GaussianBloom.fx @@ -0,0 +1,75 @@ +sampler uImage0 : register(s0); +float uTime; +float uHoverIntensity; +float uPixel; +float uColorResolution; +float uGrayness; +float uSpeed; +float4 uSource; +float3 uInColor; + +// variations of this need to be purpose built because of hlsl limitations +// this one only does a basic gaussian bloom at fixed parameters + +float gaussian(float2 i, float sigma2, float pisigma2) { + float top = exp(-((i.x * i.x) + (i.y * i.y)) / sigma2); + float bot = pisigma2; + return top / bot; +} + +float2 AspectCorrectedGBlurScale(float2 resolution, float blurIntensity) { + return (1.0f.xx / resolution) * blurIntensity; +} + +float4 gauss_blur(sampler sp, float2 uv, float2 scale, int samples) { + const float pi = radians(180.); + const float sigma = float(samples) * 0.25; + const float sigma2 = 2. * sigma * sigma; + const float pisigma2 = pi * sigma2; + + float2 offset = float2(0, 0); + float weight = gaussian(offset, sigma2, pisigma2); + float4 color_av = tex2D(sp, uv) * weight; + float accum = weight; + + for (int x = 0; x <= samples / 2; ++x) { + for (int y = 1; y <= samples / 2; ++y) { + offset = float2(x, y); + weight = gaussian(offset, sigma2, pisigma2); + color_av += tex2D(sp, uv + scale * offset) * weight; + accum += weight; + + color_av += tex2D(sp, uv - scale * offset) * weight; + accum += weight; + + offset = float2(-y, x); + color_av += tex2D(sp, uv + scale * offset) * weight; + accum += weight; + + color_av += tex2D(sp, uv - scale * offset) * weight; + accum += weight; + } + } + float4 final = color_av / accum; + // gamma correction + final = pow(final, (1.0 / 2.2).xxxx); + return final; +} + +float4 gauss_bloom(sampler sp, float2 uv, float2 scale, int samples, float4 exposure, float thresh) { + float4 bright = clamp(gauss_blur(sp, uv, scale, samples) - thresh.xxxx, 0.0f.xxxx, 1.0f.xxxx) * (1.0f / (1.0f - thresh)); + return bright * exposure; +} + +float4 main(float4 sampleColor : COLOR0, float2 coords : TEXCOORD0) : COLOR0 +{ + return gauss_bloom(uImage0, coords, AspectCorrectedGBlurScale(uSource, 4.0f), 8, 1., 0.3f); +} + +technique Technique1 +{ + pass BloomShader + { + PixelShader = compile ps_3_0 main(); + } +} \ No newline at end of file diff --git a/Effects/SlashEffects/GaussianBloom.fxc b/Effects/SlashEffects/GaussianBloom.fxc new file mode 100644 index 0000000000..79fa77932a Binary files /dev/null and b/Effects/SlashEffects/GaussianBloom.fxc differ diff --git a/Effects/SlashEffects/NanoblackSlash.fx b/Effects/SlashEffects/NanoblackSlash.fx new file mode 100644 index 0000000000..ef05800a8b --- /dev/null +++ b/Effects/SlashEffects/NanoblackSlash.fx @@ -0,0 +1,147 @@ +// Judgement Cut–style horizontal slash +// HLSL for use with SanePrimitiveRenderer's custom Effect path. This shader needs to be compensated for before use. +// Specifically SanePrimitiveRenderer. This won't work with the regular PrimitiveRenderer. +// You have been warned. + +matrix uTransformMatrix; +float uTime; + +float3 uColor; +float uBrightness; + +struct VertexShaderInput +{ + float4 Position : POSITION0; + float4 Color : COLOR0; + float2 TextureCoordinates : TEXCOORD0; +}; + +struct VertexShaderOutput +{ + float4 Position : SV_POSITION; + float4 Color : COLOR0; + float2 TextureCoordinates : TEXCOORD0; +}; + +VertexShaderOutput VertexShaderFunction(in VertexShaderInput input) +{ + VertexShaderOutput output; + output.Position = mul(input.Position, uTransformMatrix); + output.Color = input.Color; + output.TextureCoordinates = input.TextureCoordinates; + return output; +} + +float hash21(float2 p) +{ + p = frac(p * float2(123.34, 456.21)); + p += dot(p, p + 45.32); + return frac(p.x * p.y); +} + +float noise(float2 p) +{ + float2 i = floor(p); + float2 f = frac(p); + float2 u = f * f * (3.0 - 2.0 * f); + + return lerp( + lerp(hash21(i), hash21(i + float2(1.0, 0.0)), u.x), + lerp(hash21(i + float2(0.0, 1.0)), hash21(i + float2(1.0, 1.0)), u.x), + u.y + ); +} + +float slashMask(float2 uv, float thickness, float feather) +{ + float d = abs(uv.y); + return smoothstep(thickness + feather, thickness, d); +} + +float3 chromaSlash(float2 uv, float time) +{ + float thickness = 0.02; + float feather = 0.08; + + float widthPulse = 1.0 + 0.35 * sin(uv.x * 18.0 - time * 14.0); + float localThickness = thickness * widthPulse; + + float distortA = noise(float2(uv.x * 8.0 - time * 1.3, time * 6.0)); + float distortB = noise(float2(uv.x * 16.0 + time * 0.9, time * 11.0)); + float distort = (distortA - 0.5) * 0.06 + (distortB - 0.5) * 0.035; + uv.y += distort * slashMask(uv, localThickness * 2.0, feather); + + float aberr = 0.015; + float r = slashMask(uv + float2( aberr, 0.0), localThickness, feather); + float g = slashMask(uv, localThickness, feather); + float b = slashMask(uv + float2(-aberr, 0.0), localThickness, feather); + + float3 col = float3(r, g, b); + + float core = slashMask(uv, localThickness * 0.38, feather * 0.22); + col += core * float3(1.4, 1.4, 1.5); + + float glow = slashMask(uv, localThickness * 3.8, feather * 2.4); + col += glow * uColor * 0.7; + + float veinNoise = noise(float2(uv.x * 22.0 - time * 3.0, uv.y * 48.0 + time * 10.0)); + float veins = smoothstep(0.7, 0.98, veinNoise) * glow; + col += veins * uColor * 0.9; + + float shock = exp(-abs(uv.y * 13.0 + sin(uv.x * 11.0 + time * 9.0) * 1.7)); + col += shock * glow * uColor * 0.25; + + return col; +} + +float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0 +{ + float2 uv = input.TextureCoordinates * 2.0 - 1.0; + + float time = uTime; + float3 col = chromaSlash(uv, time); + + float2 bloomUV = float2(uv.x * 0.85, uv.y * 2.4); + float centerBloom = exp(-dot(bloomUV, bloomUV) * 3.8); + float bloomNoise = noise(float2(uv.x * 10.0 + time * 0.6, uv.y * 5.0)); + centerBloom *= lerp(0.92, 1.08, bloomNoise); + centerBloom = saturate(centerBloom); + + col += centerBloom * float3(0.18, 0.2, 0.25); + + float sweepPos = frac(time * 1.25) * 2.0 - 1.0; + float sweep = exp(-abs(uv.x - sweepPos) * 18.0) * slashMask(uv, 0.12, 0.18); + col += sweep * lerp(float3(1.0, 1.0, 1.0), uColor, 0.2) * 0.55; + + float sparkNoise = noise(float2(uv.x * 30.0 + time * 7.0, uv.y * 7.0 - time * 2.0)); + float sparkMask = smoothstep(0.92, 0.995, sparkNoise) * slashMask(uv, 0.20, 0.24); + col += sparkMask * lerp(float3(1.0, 1.0, 1.0), uColor, 0.25) * 0.45; + + float chromaPulse = 0.5 + 0.5 * sin(time * 6.0 + uv.x * 8.0); + float3 pulseTint = lerp(float3(0.9, 0.9, 0.9), float3(1.1, 1.1, 1.1), chromaPulse); + col *= pulseTint; + + float flicker = 0.85 + 0.15 * sin(time * 40.0); + col *= flicker; + + float edgeFade = smoothstep(1.0, 0.3, abs(uv.x)); + col *= edgeFade; + + float3 rawCol = col; + + col *= input.Color.rgb; + col *= uBrightness; + + float structureAlpha = max(rawCol.r, max(rawCol.g, rawCol.b)); + float alpha = structureAlpha * input.Color.a; + return float4(col, alpha); +} + +technique Technique1 +{ + pass SlashPass + { + VertexShader = compile vs_2_0 VertexShaderFunction(); + PixelShader = compile ps_3_0 PixelShaderFunction(); + } +} diff --git a/Effects/SlashEffects/NanoblackSlash.fxc b/Effects/SlashEffects/NanoblackSlash.fxc new file mode 100644 index 0000000000..960e469a00 Binary files /dev/null and b/Effects/SlashEffects/NanoblackSlash.fxc differ diff --git a/Events/BossRushEvent.cs b/Events/BossRushEvent.cs index 959fac537d..ffab2d16b6 100644 --- a/Events/BossRushEvent.cs +++ b/Events/BossRushEvent.cs @@ -525,6 +525,10 @@ namespace CalamityMod.Events // Handle dialogue as appropriate. BossRushDialogueSystem.Tick(); + // Tier 1 animation between Xeroc's initial dialogue and the first boss. + if (BossRushSpawnCountdown == 179 && EndTimer == 0 && CurrentlyFoughtBoss == NPCID.KingSlime) + CreateTierAnimation(1); + // Disable the stupid credits sequence. if (CreditsRollEvent.IsEventOngoing) CreditsRollEvent.SetRemainingTimeDirect(1); diff --git a/Graphics/Metaballs/BloodBoilerMetaball.cs b/Graphics/Metaballs/BloodBoilerMetaball.cs index 42fce30903..ab4ef70051 100644 --- a/Graphics/Metaballs/BloodBoilerMetaball.cs +++ b/Graphics/Metaballs/BloodBoilerMetaball.cs @@ -5,6 +5,7 @@ using CalamityMod.Enums; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.GameContent; using Terraria.ModLoader; namespace CalamityMod.Graphics.Metaballs @@ -96,9 +97,9 @@ namespace CalamityMod.Graphics.Metaballs Vector2 scale = Vector2.One * particle.Size / tex.Size(); float pureRedInterpolant = Utils.GetLerpValue(25f, 60f, particle.Size, true) * pureRedIntensity; - Color drawColor = Color.Lerp(EdgeColor, Color.DarkRed, pureRedInterpolant).MultiplyRGBA(new Color(1f, 1f, 1f, opacity)); + Color drawColor = Color.Lerp(!ChildSafety.Disabled ? Color.CornflowerBlue : EdgeColor, (!ChildSafety.Disabled ? Color.CornflowerBlue : Color.DarkRed), pureRedInterpolant).MultiplyRGBA(new Color(1f, 1f, 1f, opacity)); - Main.spriteBatch.Draw(tex, drawPosition, null, drawColor, 0f, origin, scale, SpriteEffects.None, 0f); + Main.spriteBatch.Draw(tex, drawPosition, null, (!ChildSafety.Disabled ? Color.CornflowerBlue : drawColor), 0f, origin, scale, SpriteEffects.None, 0f); } } } diff --git a/Graphics/Metaballs/BloodBoilerMetaball2.cs b/Graphics/Metaballs/BloodBoilerMetaball2.cs index 2786575f77..410edb4498 100644 --- a/Graphics/Metaballs/BloodBoilerMetaball2.cs +++ b/Graphics/Metaballs/BloodBoilerMetaball2.cs @@ -5,6 +5,7 @@ using CalamityMod.Enums; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.GameContent; using Terraria.ModLoader; namespace CalamityMod.Graphics.Metaballs @@ -96,9 +97,9 @@ namespace CalamityMod.Graphics.Metaballs Vector2 scale = Vector2.One * particle.Size / tex.Size(); float pureRedInterpolant = Utils.GetLerpValue(25f, 60f, particle.Size, true) * pureRedIntensity; - Color drawColor = Color.Lerp(EdgeColor, Color.DarkRed, pureRedInterpolant).MultiplyRGBA(new Color(1f, 1f, 1f, opacity)); + Color drawColor = Color.Lerp(!ChildSafety.Disabled ? Color.CornflowerBlue : EdgeColor, (!ChildSafety.Disabled ? Color.CornflowerBlue : Color.DarkRed), pureRedInterpolant).MultiplyRGBA(new Color(1f, 1f, 1f, opacity)); - Main.spriteBatch.Draw(tex, drawPosition, null, drawColor, 0f, origin, scale, SpriteEffects.None, 0f); + Main.spriteBatch.Draw(tex, drawPosition, null, (!ChildSafety.Disabled ? Color.CornflowerBlue : drawColor), 0f, origin, scale, SpriteEffects.None, 0f); } } } diff --git a/Graphics/Metaballs/BloodMetaball.cs b/Graphics/Metaballs/BloodMetaball.cs index 24eb5e6452..8e7242d9af 100644 --- a/Graphics/Metaballs/BloodMetaball.cs +++ b/Graphics/Metaballs/BloodMetaball.cs @@ -5,6 +5,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; +using Terraria.GameContent; using Terraria.ModLoader; namespace CalamityMod.Graphics.Metaballs @@ -80,7 +81,7 @@ namespace CalamityMod.Graphics.Metaballs } public override GeneralDrawLayer DrawLayer => GeneralDrawLayer.BeforeProjectiles; - public override Color EdgeColor => new Color(67, 17, 17); + public override Color EdgeColor => !ChildSafety.Disabled ? Color.CornflowerBlue : new Color(67, 17, 17); public override void Update() { @@ -117,7 +118,7 @@ namespace CalamityMod.Graphics.Metaballs Vector2 scale = modScale * particle.Size / texture2d.Width; var frame = texture2d.Frame(1, particle.MaxFrames, 0, particle.CurrentFrame); Vector2 origin = frame.Size() * 0.5f; - Main.spriteBatch.Draw(texture2d, drawPosition, frame, Color.White, particle.rotation, origin, scale, SpriteEffects.None, 0f); + Main.spriteBatch.Draw(texture2d, drawPosition, frame, !ChildSafety.Disabled ? Color.Black : Color.White, particle.rotation, origin, scale, SpriteEffects.None, 0f); } } } diff --git a/Graphics/Metaballs/MetaballManager.cs b/Graphics/Metaballs/MetaballManager.cs index 95be12e03f..97cf967344 100644 --- a/Graphics/Metaballs/MetaballManager.cs +++ b/Graphics/Metaballs/MetaballManager.cs @@ -120,8 +120,15 @@ namespace CalamityMod.Graphics.Metaballs Main.screenPosition -= offset; // Draw the metaball's raw contents with the shader. - Main.spriteBatch.Draw(metaball.LayerTargets[i].Target, offset, Color.White); - + // If using Odd Mushroom, clone the drawing to each point. + Color metaballDraw = Main.LocalPlayer.Calamity().trippy ? Main.DiscoColor : Color.White; + Main.spriteBatch.Draw(metaball.LayerTargets[i].Target, offset, metaballDraw); + if (Main.LocalPlayer.Calamity().trippy) + { + Main.spriteBatch.Draw(metaball.LayerTargets[i].Target, offset, null, metaballDraw, 0f, Vector2.Zero, 1f, SpriteEffects.FlipHorizontally, 0f); + Main.spriteBatch.Draw(metaball.LayerTargets[i].Target, offset, null, metaballDraw, 0f, Vector2.Zero, 1f, SpriteEffects.FlipVertically, 0f); + Main.spriteBatch.Draw(metaball.LayerTargets[i].Target, offset, null, metaballDraw, 0f, Vector2.Zero, 1f, SpriteEffects.FlipHorizontally | SpriteEffects.FlipVertically, 0f); + } } } diff --git a/Graphics/Primitives/3DRendering/!readme.txt b/Graphics/Primitives/3DRendering/!readme.txt new file mode 100644 index 0000000000..589375b96d --- /dev/null +++ b/Graphics/Primitives/3DRendering/!readme.txt @@ -0,0 +1,14 @@ +Hi, if you are a Calamity addon or other mod dev, do not steal this directory. +I can almost guarantee that you will benefit from a simpler, less feature complete mesh renderer or simple shader. + +This system is designed for easy debugging, completeness, correctness, ease of use, and arbitrary reuse. +It is not designed for ease of understanding or compactness. It is unreasonable to expect that you will be able to maintain it as a beginner. +You have been warned. + +contact 'undeathlyghost' on discord for more information + +notes: +all non-strip meshgen generates correct UVs but incorrect 'distorted' uvs may be desired sometimes for effects +i use 1e-6 as my primary epsilon value in this system, and i suggest you do the same for consistency +it is entirely possible to reuse meshes and you are encouraged to do so rather than reconstructing one if your mesh has no reason to be modified again +pooled meshes are preferred to avoid garbage collection for non-persistent/constantly changing meshes \ No newline at end of file diff --git a/Graphics/Primitives/3DRendering/PooledPrimitiveMesh.cs b/Graphics/Primitives/3DRendering/PooledPrimitiveMesh.cs new file mode 100644 index 0000000000..c5e230da07 --- /dev/null +++ b/Graphics/Primitives/3DRendering/PooledPrimitiveMesh.cs @@ -0,0 +1,51 @@ +#nullable enable +using System; +using Microsoft.Xna.Framework.Graphics; + +namespace CalamityMod.Graphics.Primitives; + +public readonly struct PooledPrimitiveMesh : IDisposable +{ + private readonly PrimitiveMeshCache? _cache; + private readonly VertexPositionColorTexture[]? _textured; + private readonly VertexPositionColor[]? _colored; + private readonly short[] _indices; + + internal PooledPrimitiveMesh( + PrimitiveMeshCache cache, + VertexPositionColorTexture[]? textured, + VertexPositionColor[]? colored, + short[] indices, + int vertexCount, + int indexCount, + PrimitiveType primitiveType, + bool usesTexture) + { + _cache = cache; + _textured = textured; + _colored = colored; + _indices = indices ?? throw new ArgumentNullException(nameof(indices)); + VertexCount = vertexCount; + IndexCount = indexCount; + PrimitiveType = primitiveType; + UsesTexture = usesTexture; + } + + public bool UsesTexture { get; } + public int VertexCount { get; } + public int IndexCount { get; } + public PrimitiveType PrimitiveType { get; } + + public VertexPositionColorTexture[] TexturedVertices => _textured ?? throw new InvalidOperationException("Mesh lease does not contain textured vertices."); + public VertexPositionColor[] ColorVertices => _colored ?? throw new InvalidOperationException("Mesh lease does not contain color-only vertices."); + public short[] Indices => _indices; + + public PrimitiveMeshView View => UsesTexture + ? new PrimitiveMeshView(_textured!, _indices, PrimitiveType, 0, VertexCount, 0, IndexCount) + : new PrimitiveMeshView(_colored!, _indices, PrimitiveType, 0, VertexCount, 0, IndexCount); + + public void Dispose() + { + _cache?.Return(_textured, _colored, _indices, UsesTexture); + } +} diff --git a/Graphics/Primitives/3DRendering/PrimitiveMesh.cs b/Graphics/Primitives/3DRendering/PrimitiveMesh.cs new file mode 100644 index 0000000000..c63cefbc3e --- /dev/null +++ b/Graphics/Primitives/3DRendering/PrimitiveMesh.cs @@ -0,0 +1,86 @@ +#nullable enable +using System; +using Microsoft.Xna.Framework.Graphics; + +namespace CalamityMod.Graphics.Primitives; + +public readonly struct PrimitiveMesh +{ + private readonly VertexPositionColorTexture[]? _texturedVertices; + private readonly VertexPositionColor[]? _colorVertices; + + public PrimitiveMesh(VertexPositionColorTexture[] vertices, short[] indices, PrimitiveType primitiveType) + { + _texturedVertices = vertices ?? throw new ArgumentNullException(nameof(vertices)); + _colorVertices = null; + Indices = indices ?? throw new ArgumentNullException(nameof(indices)); + PrimitiveType = primitiveType; + + if (_texturedVertices.Length == 0 || Indices.Length == 0) + throw new ArgumentException("Mesh must contain vertices and indices."); + if (_texturedVertices.Length > short.MaxValue) + throw new ArgumentOutOfRangeException(nameof(vertices), "Vertex count exceeds index buffer range."); + + UsesTexture = true; + } + + public PrimitiveMesh(VertexPositionColor[] vertices, short[] indices, PrimitiveType primitiveType) + { + _texturedVertices = null; + _colorVertices = vertices ?? throw new ArgumentNullException(nameof(vertices)); + Indices = indices ?? throw new ArgumentNullException(nameof(indices)); + PrimitiveType = primitiveType; + + if (_colorVertices.Length == 0 || Indices.Length == 0) + throw new ArgumentException("Mesh must contain vertices and indices."); + if (_colorVertices.Length > short.MaxValue) + throw new ArgumentOutOfRangeException(nameof(vertices), "Vertex count exceeds index buffer range."); + + UsesTexture = false; + } + + public bool UsesTexture { get; } + public int VertexCount => UsesTexture ? _texturedVertices!.Length : _colorVertices!.Length; + public VertexPositionColorTexture[] TexturedVertices => _texturedVertices ?? throw new InvalidOperationException("Mesh does not contain textured vertices."); + public VertexPositionColor[] ColorVertices => _colorVertices ?? throw new InvalidOperationException("Mesh does not contain color-only vertices."); + public short[] Indices { get; } + public PrimitiveType PrimitiveType { get; } + public bool IsValid => VertexCount > 0 && Indices.Length > 0; + + public PrimitiveMeshView AsView() + { + return UsesTexture + ? new PrimitiveMeshView(_texturedVertices!, Indices, PrimitiveType, 0, _texturedVertices!.Length, 0, Indices.Length) + : new PrimitiveMeshView(_colorVertices!, Indices, PrimitiveType, 0, _colorVertices!.Length, 0, Indices.Length); + } + + public static PrimitiveMesh FromSequential(VertexPositionColorTexture[] vertices, PrimitiveType primitiveType) + { + if (vertices == null) + throw new ArgumentNullException(nameof(vertices)); + if (vertices.Length == 0) + throw new ArgumentException("Vertices collection is empty.", nameof(vertices)); + if (vertices.Length > short.MaxValue) + throw new ArgumentOutOfRangeException(nameof(vertices), "Vertex count exceeds index buffer range."); + + var indices = new short[vertices.Length]; + PrimitiveSimd.FillSequentialIndices(indices.AsSpan()); + + return new PrimitiveMesh(vertices, indices, primitiveType); + } + + public static PrimitiveMesh FromSequential(VertexPositionColor[] vertices, PrimitiveType primitiveType) + { + if (vertices == null) + throw new ArgumentNullException(nameof(vertices)); + if (vertices.Length == 0) + throw new ArgumentException("Vertices collection is empty.", nameof(vertices)); + if (vertices.Length > short.MaxValue) + throw new ArgumentOutOfRangeException(nameof(vertices), "Vertex count exceeds index buffer range."); + + var indices = new short[vertices.Length]; + PrimitiveSimd.FillSequentialIndices(indices.AsSpan()); + + return new PrimitiveMesh(vertices, indices, primitiveType); + } +} diff --git a/Graphics/Primitives/3DRendering/PrimitiveMeshCache.cs b/Graphics/Primitives/3DRendering/PrimitiveMeshCache.cs new file mode 100644 index 0000000000..110e52ce7f --- /dev/null +++ b/Graphics/Primitives/3DRendering/PrimitiveMeshCache.cs @@ -0,0 +1,93 @@ +#nullable enable +using System; +using System.Buffers; +using Microsoft.Xna.Framework.Graphics; + +namespace CalamityMod.Graphics.Primitives; + +public sealed class PrimitiveMeshCache +{ + public static PrimitiveMeshCache Shared { get; } = new PrimitiveMeshCache(); + + private readonly ArrayPool _texturedPool; + private readonly ArrayPool _colorPool; + private readonly ArrayPool _indexPool; + private readonly bool _clearOnReturn; + + public PrimitiveMeshCache( + ArrayPool? texturedPool = null, + ArrayPool? colorPool = null, + ArrayPool? indexPool = null, + bool clearOnReturn = false) + { + _texturedPool = texturedPool ?? ArrayPool.Shared; + _colorPool = colorPool ?? ArrayPool.Shared; + _indexPool = indexPool ?? ArrayPool.Shared; + _clearOnReturn = clearOnReturn; + } + + public PooledPrimitiveMesh RentTextured(int vertexCount, int indexCount, PrimitiveType primitiveType) + { + if (vertexCount <= 0) + throw new ArgumentOutOfRangeException(nameof(vertexCount), "Cannot meaningfully rent zero vertices."); + if (indexCount <= 0) + throw new ArgumentOutOfRangeException(nameof(indexCount), "Cannot meaningfully rent an index buffer of size zero."); + if (vertexCount > short.MaxValue) + throw new ArgumentOutOfRangeException(nameof(vertexCount), "Vertex count exceeds index buffer range."); + + var vertices = _texturedPool.Rent(vertexCount); + var indices = _indexPool.Rent(indexCount); + return new PooledPrimitiveMesh(this, vertices, null, indices, vertexCount, indexCount, primitiveType, true); + } + + public PooledPrimitiveMesh RentColored(int vertexCount, int indexCount, PrimitiveType primitiveType) + { + if (vertexCount <= 0) + throw new ArgumentOutOfRangeException(nameof(vertexCount), "Cannot meaningfully rent zero vertices."); + if (indexCount <= 0) + throw new ArgumentOutOfRangeException(nameof(indexCount), "Cannot meaningfully rent an index buffer of size zero."); + if (vertexCount > short.MaxValue) + throw new ArgumentOutOfRangeException(nameof(vertexCount), "Vertex count exceeds index buffer range."); + + var vertices = _colorPool.Rent(vertexCount); + var indices = _indexPool.Rent(indexCount); + return new PooledPrimitiveMesh(this, null, vertices, indices, vertexCount, indexCount, primitiveType, false); + } + + public PooledPrimitiveMesh RentFromMesh(in PrimitiveMesh mesh) + { + if (!mesh.IsValid) + throw new ArgumentException("Mesh is invalid.", nameof(mesh)); + + if (mesh.UsesTexture) + { + var lease = RentTextured(mesh.VertexCount, mesh.Indices.Length, mesh.PrimitiveType); + Array.Copy(mesh.TexturedVertices, lease.TexturedVertices, mesh.VertexCount); + Array.Copy(mesh.Indices, lease.Indices, mesh.Indices.Length); + return lease; + } + else + { + var lease = RentColored(mesh.VertexCount, mesh.Indices.Length, mesh.PrimitiveType); + Array.Copy(mesh.ColorVertices, lease.ColorVertices, mesh.VertexCount); + Array.Copy(mesh.Indices, lease.Indices, mesh.Indices.Length); + return lease; + } + } + + internal void Return(VertexPositionColorTexture[]? textured, VertexPositionColor[]? colored, short[] indices, bool usesTexture) + { + if (usesTexture) + { + if (textured != null) + _texturedPool.Return(textured, _clearOnReturn); + } + else + { + if (colored != null) + _colorPool.Return(colored, _clearOnReturn); + } + + _indexPool.Return(indices, _clearOnReturn); + } +} diff --git a/Graphics/Primitives/3DRendering/PrimitiveMeshExtensions.cs b/Graphics/Primitives/3DRendering/PrimitiveMeshExtensions.cs new file mode 100644 index 0000000000..7a851e11b7 --- /dev/null +++ b/Graphics/Primitives/3DRendering/PrimitiveMeshExtensions.cs @@ -0,0 +1,492 @@ +#nullable enable + +// 10FEB2026: jasper: you probably don't need this file for casual mesh use. +// you should be careful with mesh transformations, they are intended for advanced users. + +using System; +using System.Collections.Generic; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +namespace CalamityMod.Graphics.Primitives; + +public static class PrimitiveMeshExtensions +{ + public static PrimitiveMesh Transform(this in PrimitiveMesh mesh, in Matrix transform) + { + if (!mesh.IsValid) + return mesh; + + var indices = (short[])mesh.Indices.Clone(); + + if (mesh.UsesTexture) + { + var source = mesh.TexturedVertices; + var transformed = new VertexPositionColorTexture[source.Length]; + for (int i = 0; i < source.Length; i++) + { + var v = source[i]; + transformed[i] = new VertexPositionColorTexture( + Vector3.Transform(v.Position, transform), + v.Color, + v.TextureCoordinate); + } + + return new PrimitiveMesh(transformed, indices, mesh.PrimitiveType); + } + + { + var source = mesh.ColorVertices; + var transformed = new VertexPositionColor[source.Length]; + for (int i = 0; i < source.Length; i++) + { + var v = source[i]; + transformed[i] = new VertexPositionColor( + Vector3.Transform(v.Position, transform), + v.Color); + } + + return new PrimitiveMesh(transformed, indices, mesh.PrimitiveType); + } + } + + public static PrimitiveMesh Translate(this in PrimitiveMesh mesh, in Vector3 offset) => + mesh.Transform(Matrix.CreateTranslation(offset)); + + public static PrimitiveMesh Scale(this in PrimitiveMesh mesh, in Vector3 scale) => + mesh.Transform(Matrix.CreateScale(scale)); + + public static PrimitiveMesh Rotate(this in PrimitiveMesh mesh, in Quaternion rotation) => + mesh.Transform(Matrix.CreateFromQuaternion(rotation)); + + public static PrimitiveMesh Extrude(this in PrimitiveMesh mesh, in Vector3 direction, bool closeCaps = true) + { + if (!mesh.IsValid) + throw new InvalidOperationException("Cannot extrude an invalid mesh."); + if (mesh.PrimitiveType != PrimitiveType.TriangleList) + throw new NotSupportedException("Extrusion currently supports triangle list meshes only."); + if (direction.LengthSquared() <= 1e-6f) + return mesh; + + return mesh.UsesTexture + ? ExtrudeTextured(mesh, direction, closeCaps) + : ExtrudeColored(mesh, direction, closeCaps); + } + + private static PrimitiveMesh ExtrudeTextured(in PrimitiveMesh mesh, Vector3 direction, bool closeCaps) + { + var top = mesh.TexturedVertices; + var baseIndices = mesh.Indices; + int originalVertexCount = top.Length; + + var vertices = new List(originalVertexCount * 2); + vertices.AddRange(top); + + for (int i = 0; i < originalVertexCount; i++) + { + var v = top[i]; + vertices.Add(new VertexPositionColorTexture( + v.Position + direction, + v.Color, + v.TextureCoordinate)); + } + + var indices = new List(closeCaps ? baseIndices.Length * 2 : baseIndices.Length + originalVertexCount * 6); + indices.AddRange(baseIndices); + + if (closeCaps) + { + for (int i = 0; i < baseIndices.Length; i += 3) + { + short a = (short)(baseIndices[i] + originalVertexCount); + short b = (short)(baseIndices[i + 1] + originalVertexCount); + short c = (short)(baseIndices[i + 2] + originalVertexCount); + indices.Add(c); + indices.Add(b); + indices.Add(a); + } + } + + var positions = new Vector3[originalVertexCount]; + for (int i = 0; i < originalVertexCount; i++) + positions[i] = top[i].Position; + + var loops = BuildBoundaryLoops(positions, baseIndices); + foreach (var loop in loops) + { + float perimeter = 0f; + for (int i = 0; i < loop.Count; i++) + perimeter += loop[i].Length; + if (perimeter <= 1e-6f) + continue; + + float accumulated = 0f; + foreach (var edge in loop) + { + float u0 = accumulated / perimeter; + accumulated += edge.Length; + float u1 = accumulated / perimeter; + + var startTop = top[edge.Start]; + var endTop = top[edge.End]; + var startBottomPos = startTop.Position + direction; + var endBottomPos = endTop.Position + direction; + + short topStartIndex = AddVertex(vertices, new VertexPositionColorTexture(startTop.Position, startTop.Color, new Vector2(u0, 0f))); + short bottomStartIndex = AddVertex(vertices, new VertexPositionColorTexture(startBottomPos, startTop.Color, new Vector2(u0, 1f))); + short topEndIndex = AddVertex(vertices, new VertexPositionColorTexture(endTop.Position, endTop.Color, new Vector2(u1, 0f))); + short bottomEndIndex = AddVertex(vertices, new VertexPositionColorTexture(endBottomPos, endTop.Color, new Vector2(u1, 1f))); + + indices.Add(topStartIndex); + indices.Add(topEndIndex); + indices.Add(bottomEndIndex); + + indices.Add(topStartIndex); + indices.Add(bottomEndIndex); + indices.Add(bottomStartIndex); + } + } + + return new PrimitiveMesh(vertices.ToArray(), indices.ToArray(), PrimitiveType.TriangleList); + } + + private static PrimitiveMesh ExtrudeColored(in PrimitiveMesh mesh, Vector3 direction, bool closeCaps) + { + var top = mesh.ColorVertices; + var baseIndices = mesh.Indices; + int originalVertexCount = top.Length; + + var vertices = new List(originalVertexCount * 2); + vertices.AddRange(top); + + for (int i = 0; i < originalVertexCount; i++) + { + var v = top[i]; + vertices.Add(new VertexPositionColor(v.Position + direction, v.Color)); + } + + var indices = new List(closeCaps ? baseIndices.Length * 2 : baseIndices.Length + originalVertexCount * 6); + indices.AddRange(baseIndices); + + if (closeCaps) + { + for (int i = 0; i < baseIndices.Length; i += 3) + { + short a = (short)(baseIndices[i] + originalVertexCount); + short b = (short)(baseIndices[i + 1] + originalVertexCount); + short c = (short)(baseIndices[i + 2] + originalVertexCount); + indices.Add(c); + indices.Add(b); + indices.Add(a); + } + } + + var positions = new Vector3[originalVertexCount]; + for (int i = 0; i < originalVertexCount; i++) + positions[i] = top[i].Position; + + var loops = BuildBoundaryLoops(positions, baseIndices); + foreach (var loop in loops) + { + float perimeter = 0f; + for (int i = 0; i < loop.Count; i++) + perimeter += loop[i].Length; + if (perimeter <= 1e-6f) + continue; + + float accumulated = 0f; + foreach (var edge in loop) + { + float u0 = accumulated / perimeter; + accumulated += edge.Length; + float u1 = accumulated / perimeter; + + var startTop = top[edge.Start]; + var endTop = top[edge.End]; + var startBottomPos = startTop.Position + direction; + var endBottomPos = endTop.Position + direction; + + short topStartIndex = AddVertex(vertices, new VertexPositionColor(startTop.Position, startTop.Color)); + short bottomStartIndex = AddVertex(vertices, new VertexPositionColor(startBottomPos, startTop.Color)); + short topEndIndex = AddVertex(vertices, new VertexPositionColor(endTop.Position, endTop.Color)); + short bottomEndIndex = AddVertex(vertices, new VertexPositionColor(endBottomPos, endTop.Color)); + + indices.Add(topStartIndex); + indices.Add(topEndIndex); + indices.Add(bottomEndIndex); + + indices.Add(topStartIndex); + indices.Add(bottomEndIndex); + indices.Add(bottomStartIndex); + } + } + + return new PrimitiveMesh(vertices.ToArray(), indices.ToArray(), PrimitiveType.TriangleList); + } + + public static PrimitiveMesh CurveEdges(this in PrimitiveMesh mesh, in Vector3 axis, float magnitude, float exponent = 2f) + { + if (!mesh.IsValid) + return mesh; + if (axis.LengthSquared() <= 1e-6f) + throw new ArgumentException("Axis must be non-zero.", nameof(axis)); + if (mesh.PrimitiveType != PrimitiveType.TriangleList && mesh.PrimitiveType != PrimitiveType.TriangleStrip) + throw new NotSupportedException("CurveEdges supports triangle-based meshes."); + + float clampedExponent = Math.Max(exponent, 1e-3f); + Vector3 axisDir = Vector3.Normalize(axis); + var indices = (short[])mesh.Indices.Clone(); + + if (mesh.UsesTexture) + { + var source = mesh.TexturedVertices; + var vertices = new VertexPositionColorTexture[source.Length]; + ComputeCentroidAndRadius(source, out var centroid, out float radius); + + for (int i = 0; i < source.Length; i++) + { + var v = source[i]; + Vector3 diff = v.Position - centroid; + float radial = radius <= 1e-6f ? 0f : diff.Length() / radius; + float factor = MathF.Pow(MathHelper.Clamp(radial, 0f, 1f), clampedExponent); + Vector3 offset = axisDir * magnitude * factor; + + vertices[i] = new VertexPositionColorTexture(v.Position + offset, v.Color, v.TextureCoordinate); + } + + return new PrimitiveMesh(vertices, indices, mesh.PrimitiveType); + } + else + { + var source = mesh.ColorVertices; + var vertices = new VertexPositionColor[source.Length]; + ComputeCentroidAndRadius(source, out var centroid, out float radius); + + for (int i = 0; i < source.Length; i++) + { + var v = source[i]; + Vector3 diff = v.Position - centroid; + float radial = radius <= 1e-6f ? 0f : diff.Length() / radius; + float factor = MathF.Pow(MathHelper.Clamp(radial, 0f, 1f), clampedExponent); + Vector3 offset = axisDir * magnitude * factor; + + vertices[i] = new VertexPositionColor(v.Position + offset, v.Color); + } + + return new PrimitiveMesh(vertices, indices, mesh.PrimitiveType); + } + } + + private static void ComputeCentroidAndRadius(VertexPositionColorTexture[] vertices, out Vector3 centroid, out float radius) + { + centroid = Vector3.Zero; + for (int i = 0; i < vertices.Length; i++) + centroid += vertices[i].Position; + centroid /= vertices.Length; + + radius = 1e-6f; + for (int i = 0; i < vertices.Length; i++) + { + float length = Vector3.Distance(centroid, vertices[i].Position); + if (length > radius) + radius = length; + } + } + + private static void ComputeCentroidAndRadius(VertexPositionColor[] vertices, out Vector3 centroid, out float radius) + { + centroid = Vector3.Zero; + for (int i = 0; i < vertices.Length; i++) + centroid += vertices[i].Position; + centroid /= vertices.Length; + + radius = 1e-6f; + for (int i = 0; i < vertices.Length; i++) + { + float length = Vector3.Distance(centroid, vertices[i].Position); + if (length > radius) + radius = length; + } + } + + /// + /// Builds boundary loops from a triangle list. + /// Each loop is a sequence of connected boundary edges that form a closed path along the mesh surface. + /// Loops are returned in no particular order, and may be nested or intersecting. + /// Edges are oriented consistently within each loop, but not across different loops. + /// Only zero-length edges are discarded, and loops must close to be included. + /// + /// Vertex positions for the mesh. + /// Triangle-list indices (groups of 3). + /// Closed boundary loops built from boundary edges. + private static List> BuildBoundaryLoops(IReadOnlyList positions, short[] indices) + { + var edgeMap = new Dictionary(); + for (int i = 0; i < indices.Length; i += 3) + { + RegisterEdge(edgeMap, indices[i], indices[i + 1]); + RegisterEdge(edgeMap, indices[i + 1], indices[i + 2]); + RegisterEdge(edgeMap, indices[i + 2], indices[i]); + } + + var edges = new List(); + foreach (var pair in edgeMap) + { + if (pair.Value.Count == 1) + { + var oriented = pair.Value.Orientation; + float length = Vector3.Distance(positions[oriented.Start], positions[oriented.End]); + if (length > 1e-6f) + edges.Add(new OrientedEdge(oriented.Start, oriented.End, length)); + } + } + + var loops = new List>(); + var used = new bool[edges.Count]; + + for (int i = 0; i < edges.Count; i++) + { + if (used[i]) + continue; + + var loop = new List(); + used[i] = true; + loop.Add(edges[i]); + + short head = edges[i].End; + bool closed = head == loop[0].Start; + + while (!closed) + { + bool found = false; + for (int j = 0; j < edges.Count; j++) + { + if (used[j]) + continue; + + var candidate = edges[j]; + if (candidate.Start == head) + { + used[j] = true; + loop.Add(candidate); + head = candidate.End; + found = true; + } + else if (candidate.End == head) + { + candidate = candidate.Reversed(); + edges[j] = candidate; + used[j] = true; + loop.Add(candidate); + head = candidate.End; + found = true; + } + + if (found) + { + closed = head == loop[0].Start; + break; + } + } + + if (!found) + break; + } + + if (loop.Count > 1 && closed) + loops.Add(loop); + } + + return loops; + } + + private static void RegisterEdge(Dictionary edgeMap, short start, short end) + { + var key = new EdgeKey(Math.Min(start, end), Math.Max(start, end)); + if (edgeMap.TryGetValue(key, out var accumulator)) + { + accumulator.Count++; + edgeMap[key] = accumulator; + } + else + { + edgeMap[key] = new EdgeAccumulator + { + Count = 1, + Orientation = new OrientedEdge(start, end, 0f) + }; + } + } + + /// + /// Adds a vertex to the list and returns its index. Most likely, you do not need to use this directly. + /// + /// The vertex list to add to. + /// The vertex to add. + private static short AddVertex(List vertices, VertexPositionColorTexture vertex) + { + if (vertices.Count >= short.MaxValue) + throw new InvalidOperationException("Primitive mesh exceeded 16-bit vertex capacity."); + vertices.Add(vertex); + return (short)(vertices.Count - 1); + } + + /// + /// Adds a vertex to the list and returns its index. Most likely, you do not need to use this directly. + /// + /// The vertex list to add to. + /// The vertex to add. + private static short AddVertex(List vertices, VertexPositionColor vertex) + { + if (vertices.Count >= short.MaxValue) + throw new InvalidOperationException("Primitive mesh exceeded 16-bit vertex capacity."); + vertices.Add(vertex); + return (short)(vertices.Count - 1); + } + + private readonly struct EdgeKey : IEquatable + { + public readonly short Min; + public readonly short Max; + + public EdgeKey(short min, short max) + { + Min = min; + Max = max; + } + + public bool Equals(EdgeKey other) => Min == other.Min && Max == other.Max; + + public override bool Equals(object? obj) => obj is EdgeKey other && Equals(other); + + public override int GetHashCode() + { + unchecked + { + return (Min * 397) ^ Max; + } + } + } + + private struct EdgeAccumulator + { + public int Count; + public OrientedEdge Orientation; + } + + private struct OrientedEdge + { + public short Start; + public short End; + public float Length; + + public OrientedEdge(short start, short end, float length) + { + Start = start; + End = end; + Length = length; + } + + public OrientedEdge Reversed() => new OrientedEdge(End, Start, Length); + } +} diff --git a/Graphics/Primitives/3DRendering/PrimitiveMeshView.cs b/Graphics/Primitives/3DRendering/PrimitiveMeshView.cs new file mode 100644 index 0000000000..8240fa712d --- /dev/null +++ b/Graphics/Primitives/3DRendering/PrimitiveMeshView.cs @@ -0,0 +1,87 @@ +#nullable enable +using System; +using Microsoft.Xna.Framework.Graphics; + +namespace CalamityMod.Graphics.Primitives; + +public readonly struct PrimitiveMeshView +{ + private readonly VertexPositionColorTexture[]? _texturedVertices; + private readonly VertexPositionColor[]? _colorVertices; + + public PrimitiveMeshView( + VertexPositionColorTexture[] vertices, + short[] indices, + PrimitiveType primitiveType, + int vertexOffset, + int vertexCount, + int indexOffset, + int indexCount) + { + _texturedVertices = vertices ?? throw new ArgumentNullException(nameof(vertices)); + _colorVertices = null; + Indices = indices ?? throw new ArgumentNullException(nameof(indices)); + PrimitiveType = primitiveType; + + ValidateRanges(vertices.Length, indices.Length, vertexOffset, vertexCount, indexOffset, indexCount); + + VertexOffset = vertexOffset; + VertexCount = vertexCount; + IndexOffset = indexOffset; + IndexCount = indexCount; + UsesTexture = true; + } + + public PrimitiveMeshView( + VertexPositionColor[] vertices, + short[] indices, + PrimitiveType primitiveType, + int vertexOffset, + int vertexCount, + int indexOffset, + int indexCount) + { + _texturedVertices = null; + _colorVertices = vertices ?? throw new ArgumentNullException(nameof(vertices)); + Indices = indices ?? throw new ArgumentNullException(nameof(indices)); + PrimitiveType = primitiveType; + + ValidateRanges(vertices.Length, indices.Length, vertexOffset, vertexCount, indexOffset, indexCount); + + VertexOffset = vertexOffset; + VertexCount = vertexCount; + IndexOffset = indexOffset; + IndexCount = indexCount; + UsesTexture = false; + } + + public bool UsesTexture { get; } + public int VertexOffset { get; } + public int VertexCount { get; } + public int IndexOffset { get; } + public int IndexCount { get; } + public PrimitiveType PrimitiveType { get; } + public bool IsValid => VertexCount > 0 && IndexCount > 0; + + public VertexPositionColorTexture[] TexturedVertices => _texturedVertices ?? throw new InvalidOperationException("Mesh view does not contain textured vertices."); + public VertexPositionColor[] ColorVertices => _colorVertices ?? throw new InvalidOperationException("Mesh view does not contain color-only vertices."); + public short[] Indices { get; } + + private static void ValidateRanges(int vertexArrayLength, int indexArrayLength, int vertexOffset, int vertexCount, int indexOffset, int indexCount) + { + if (vertexOffset < 0) + throw new ArgumentOutOfRangeException(nameof(vertexOffset)); + if (vertexCount <= 0) + throw new ArgumentOutOfRangeException(nameof(vertexCount)); + if (indexOffset < 0) + throw new ArgumentOutOfRangeException(nameof(indexOffset)); + if (indexCount <= 0) + throw new ArgumentOutOfRangeException(nameof(indexCount)); + if (vertexOffset + vertexCount > vertexArrayLength) + throw new ArgumentOutOfRangeException(nameof(vertexCount), "Vertex range exceeds the vertex buffer length."); + if (indexOffset + indexCount > indexArrayLength) + throw new ArgumentOutOfRangeException(nameof(indexCount), "Index range exceeds the index buffer length."); + if (vertexCount > short.MaxValue) + throw new ArgumentOutOfRangeException(nameof(vertexCount), "Vertex count exceeds index buffer range."); + } +} diff --git a/Graphics/Primitives/3DRendering/PrimitiveRenderSystem.cs b/Graphics/Primitives/3DRendering/PrimitiveRenderSystem.cs new file mode 100644 index 0000000000..003799ccd6 --- /dev/null +++ b/Graphics/Primitives/3DRendering/PrimitiveRenderSystem.cs @@ -0,0 +1,23 @@ +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Graphics.Primitives; + +public sealed class PrimitiveRenderSystem : ModSystem +{ + public override void Load() + { + if (Main.dedServ) + return; + Main.QueueMainThreadAction(() => + { + SanePrimitiveRenderer.Initialize(); + }); + } + + public override void Unload() + { + SanePrimitiveRenderer.Dispose(); + } +} diff --git a/Graphics/Primitives/3DRendering/PrimitiveShapeBuilder.cs b/Graphics/Primitives/3DRendering/PrimitiveShapeBuilder.cs new file mode 100644 index 0000000000..4240c434ab --- /dev/null +++ b/Graphics/Primitives/3DRendering/PrimitiveShapeBuilder.cs @@ -0,0 +1,503 @@ +#nullable enable +using System; +using System.Collections.Generic; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +namespace CalamityMod.Graphics.Primitives; + +public static class PrimitiveShapeBuilder +{ + public static PrimitiveMesh BuildRectangularQuad( + Vector3 center, + Vector2 size, + Color color, + Vector3 normal, + Vector3 upHint, + bool textured = false) + { + BuildFrame(normal, upHint, out var right, out var up); + + var halfRight = right * (size.X * 0.5f); + var halfUp = up * (size.Y * 0.5f); + + if (textured) + { + var vertices = new[] + { + new VertexPositionColorTexture(center - halfRight - halfUp, color, new Vector2(0f, 1f)), + new VertexPositionColorTexture(center + halfRight - halfUp, color, new Vector2(1f, 1f)), + new VertexPositionColorTexture(center + halfRight + halfUp, color, new Vector2(1f, 0f)), + new VertexPositionColorTexture(center - halfRight + halfUp, color, new Vector2(0f, 0f)) + }; + var indices = new short[] { 0, 1, 2, 0, 2, 3 }; + return new PrimitiveMesh(vertices, indices, PrimitiveType.TriangleList); + } + + var colorVertices = new[] + { + new VertexPositionColor(center - halfRight - halfUp, color), + new VertexPositionColor(center + halfRight - halfUp, color), + new VertexPositionColor(center + halfRight + halfUp, color), + new VertexPositionColor(center - halfRight + halfUp, color) + }; + var colorIndices = new short[] { 0, 1, 2, 0, 2, 3 }; + return new PrimitiveMesh(colorVertices, colorIndices, PrimitiveType.TriangleList); + } + + /// + /// Builds a regular polygon with the specified number of sides, centered at the given position, and oriented according to the normal and up hint. + /// The polygon is constructed in a single triangle fan, with the center vertex as the first element and subsequent vertices arranged in a clockwise order around the normal. + /// If you need a different vertex order or a more complex polygon, consider + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static PrimitiveMesh BuildRegularPolygon( + Vector3 center, + float radius, + int sides, + Color color, + Vector3 normal, + Vector3 upHint, + bool textured = false) + { + if (sides < 3) + throw new ArgumentOutOfRangeException(nameof(sides), "Polygon requires at least three sides."); + + BuildFrame(normal, upHint, out var right, out var up); + + if (textured) + { + var texturedVertices = new VertexPositionColorTexture[sides + 1]; + texturedVertices[0] = new VertexPositionColorTexture(center, color, new Vector2(0.5f, 0.5f)); + + float safeRadius = Math.Max(radius, 1e-6f); + + for (int i = 0; i < sides; i++) + { + var direction = PolarToCartesian(i, sides, right, up) * radius; + var point = center + direction; + float u = 0.5f + 0.5f * MathHelper.Clamp(Vector3.Dot(direction, right) / safeRadius, -1f, 1f); + float v = 0.5f - 0.5f * MathHelper.Clamp(Vector3.Dot(direction, up) / safeRadius, -1f, 1f); + texturedVertices[i + 1] = new VertexPositionColorTexture(point, color, new Vector2(u, v)); + } + + var indices = new short[sides * 3]; + for (int i = 0; i < sides; i++) + { + int next = (i + 1) % sides; + int baseIndex = i * 3; + indices[baseIndex] = 0; + indices[baseIndex + 1] = (short)(i + 1); + indices[baseIndex + 2] = (short)(next + 1); + } + + return new PrimitiveMesh(texturedVertices, indices, PrimitiveType.TriangleList); + } + + var colorVertices = new VertexPositionColor[sides + 1]; + colorVertices[0] = new VertexPositionColor(center, color); + + for (int i = 0; i < sides; i++) + { + var direction = PolarToCartesian(i, sides, right, up) * radius; + colorVertices[i + 1] = new VertexPositionColor(center + direction, color); + } + + var colorIndices = new short[sides * 3]; + for (int i = 0; i < sides; i++) + { + int next = (i + 1) % sides; + int baseIndex = i * 3; + colorIndices[baseIndex] = 0; + colorIndices[baseIndex + 1] = (short)(i + 1); + colorIndices[baseIndex + 2] = (short)(next + 1); + } + + return new PrimitiveMesh(colorVertices, colorIndices, PrimitiveType.TriangleList); + } + + public static PrimitiveMesh BuildArbitraryPolygon(IReadOnlyList points, Color color, bool textured = false) + { + if (points == null) + throw new ArgumentNullException(nameof(points)); + if (points.Count < 3) + throw new ArgumentOutOfRangeException(nameof(points), "Polygon requires at least three points."); + + if (textured) + { + float minX = points[0].X, maxX = points[0].X; + float minY = points[0].Y, maxY = points[0].Y; + for (int i = 1; i < points.Count; i++) + { + var p = points[i]; + if (p.X < minX) minX = p.X; + if (p.X > maxX) maxX = p.X; + if (p.Y < minY) minY = p.Y; + if (p.Y > maxY) maxY = p.Y; + } + float width = Math.Max(maxX - minX, 1e-6f); + float height = Math.Max(maxY - minY, 1e-6f); + + var texturedVertices = new VertexPositionColorTexture[points.Count]; + for (int i = 0; i < points.Count; i++) + { + var point = points[i]; + float u = (point.X - minX) / width; + float v = (point.Y - minY) / height; + texturedVertices[i] = new VertexPositionColorTexture(point, color, new Vector2(u, v)); + } + + var indices = new short[(points.Count - 2) * 3]; + for (int i = 0; i < points.Count - 2; i++) + { + indices[i * 3] = 0; + indices[i * 3 + 1] = (short)(i + 1); + indices[i * 3 + 2] = (short)(i + 2); + } + + return new PrimitiveMesh(texturedVertices, indices, PrimitiveType.TriangleList); + } + + var colorVertices = new VertexPositionColor[points.Count]; + for (int i = 0; i < points.Count; i++) + { + var point = points[i]; + colorVertices[i] = new VertexPositionColor(point, color); + } + + var colorIndices = new short[(points.Count - 2) * 3]; + for (int i = 0; i < points.Count - 2; i++) + { + colorIndices[i * 3] = 0; + colorIndices[i * 3 + 1] = (short)(i + 1); + colorIndices[i * 3 + 2] = (short)(i + 2); + } + + return new PrimitiveMesh(colorVertices, colorIndices, PrimitiveType.TriangleList); + } + + public static PrimitiveMesh BuildEllipse( + Vector3 center, + Vector2 radii, + int segments, + Color color, + Vector3 normal, + Vector3 upHint, + bool textured = false) + { + if (segments < 3) + throw new ArgumentOutOfRangeException(nameof(segments), "Ellipse requires at least three segments."); + + BuildFrame(normal, upHint, out var right, out var up); + + if (textured) + { + var vertices = new VertexPositionColorTexture[segments + 1]; + vertices[0] = new VertexPositionColorTexture(center, color, new Vector2(0.5f, 0.5f)); + + float safeX = Math.Max(radii.X, 1e-6f); + float safeY = Math.Max(radii.Y, 1e-6f); + + for (int i = 0; i < segments; i++) + { + var offset = EllipseDirection(i, segments, right, up, radii); + var point = center + offset; + + float u = 0.5f + 0.5f * MathHelper.Clamp(Vector3.Dot(offset, right) / safeX, -1f, 1f); + float v = 0.5f - 0.5f * MathHelper.Clamp(Vector3.Dot(offset, up) / safeY, -1f, 1f); + + vertices[i + 1] = new VertexPositionColorTexture(point, color, new Vector2(u, v)); + } + + var indices = new short[segments * 3]; + for (int i = 0; i < segments; i++) + { + int next = (i + 1) % segments; + int baseIndex = i * 3; + indices[baseIndex] = 0; + indices[baseIndex + 1] = (short)(i + 1); + indices[baseIndex + 2] = (short)(next + 1); + } + + return new PrimitiveMesh(vertices, indices, PrimitiveType.TriangleList); + } + + var colorVertices = new VertexPositionColor[segments + 1]; + colorVertices[0] = new VertexPositionColor(center, color); + + for (int i = 0; i < segments; i++) + { + colorVertices[i + 1] = new VertexPositionColor(center + EllipseDirection(i, segments, right, up, radii), color); + } + + var colorIndices = new short[segments * 3]; + for (int i = 0; i < segments; i++) + { + int next = (i + 1) % segments; + int baseIndex = i * 3; + colorIndices[baseIndex] = 0; + colorIndices[baseIndex + 1] = (short)(i + 1); + colorIndices[baseIndex + 2] = (short)(next + 1); + } + + return new PrimitiveMesh(colorVertices, colorIndices, PrimitiveType.TriangleList); + } + + public static PrimitiveMesh BuildSphere( + Vector3 center, + float radius, + int latitudeSegments, + int longitudeSegments, + Func? colorFunc = null, + bool textured = false) + { + if (latitudeSegments < 2) + throw new ArgumentOutOfRangeException(nameof(latitudeSegments), "Sphere requires at least two latitude segments."); + if (longitudeSegments < 3) + throw new ArgumentOutOfRangeException(nameof(longitudeSegments), "Sphere requires at least three longitude segments."); + + colorFunc ??= static _ => Color.White; + + int vertexRows = latitudeSegments + 1; + int vertexCols = longitudeSegments + 1; + int vertexCount = vertexRows * vertexCols; + + if (vertexCount > short.MaxValue) + throw new InvalidOperationException("Sphere produced more vertices than supported by the index buffer."); + + if (textured) + { + var vertices = new VertexPositionColorTexture[vertexCount]; + int v = 0; + + for (int lat = 0; lat <= latitudeSegments; lat++) + { + float phi = MathF.PI * lat / latitudeSegments; + float sinPhi = MathF.Sin(phi); + float cosPhi = MathF.Cos(phi); + + float vCoord = 1f - (float)lat / latitudeSegments; + + for (int lon = 0; lon <= longitudeSegments; lon++) + { + float theta = MathHelper.TwoPi * lon / longitudeSegments; + var normal = SphericalDirection(sinPhi, cosPhi, theta); + float uCoord = (float)lon / longitudeSegments; + + vertices[v++] = new VertexPositionColorTexture(center + normal * radius, colorFunc(normal), new Vector2(uCoord, vCoord)); + } + } + + var indices = new List(latitudeSegments * longitudeSegments * 6); + for (int lat = 0; lat < latitudeSegments; lat++) + { + for (int lon = 0; lon < longitudeSegments; lon++) + { + int current = lat * vertexCols + lon; + int next = current + vertexCols; + + indices.Add((short)current); + indices.Add((short)(current + 1)); + indices.Add((short)next); + + indices.Add((short)(current + 1)); + indices.Add((short)(next + 1)); + indices.Add((short)next); + } + } + + return new PrimitiveMesh(vertices, indices.ToArray(), PrimitiveType.TriangleList); + } + + var colorVertices = new VertexPositionColor[vertexCount]; + int vIndex = 0; + + for (int lat = 0; lat <= latitudeSegments; lat++) + { + float phi = MathF.PI * lat / latitudeSegments; + float sinPhi = MathF.Sin(phi); + float cosPhi = MathF.Cos(phi); + + for (int lon = 0; lon <= longitudeSegments; lon++) + { + float theta = MathHelper.TwoPi * lon / longitudeSegments; + var normal = SphericalDirection(sinPhi, cosPhi, theta); + colorVertices[vIndex++] = new VertexPositionColor(center + normal * radius, colorFunc(normal)); + } + } + + var colorIndices = new List(latitudeSegments * longitudeSegments * 6); + for (int lat = 0; lat < latitudeSegments; lat++) + { + for (int lon = 0; lon < longitudeSegments; lon++) + { + int current = lat * vertexCols + lon; + int next = current + vertexCols; + + colorIndices.Add((short)current); + colorIndices.Add((short)(current + 1)); + colorIndices.Add((short)next); + + colorIndices.Add((short)(current + 1)); + colorIndices.Add((short)(next + 1)); + colorIndices.Add((short)next); + } + } + + return new PrimitiveMesh(colorVertices, colorIndices.ToArray(), PrimitiveType.TriangleList); + } + + // Heres your vertice, sir. You probably don't need to call this directly. + public static PrimitiveMesh BuildTriangle(Vector3 a, Vector3 b, Vector3 c, Color color, bool textured = false) + { + if (textured) + { + var vertices = new[] + { + new VertexPositionColorTexture(a, color, new Vector2(0f, 1f)), + new VertexPositionColorTexture(b, color, new Vector2(1f, 1f)), + new VertexPositionColorTexture(c, color, new Vector2(0.5f, 0f)) + }; + return new PrimitiveMesh(vertices, new short[] { 0, 1, 2 }, PrimitiveType.TriangleList); + } + + var colorVertices = new[] + { + new VertexPositionColor(a, color), + new VertexPositionColor(b, color), + new VertexPositionColor(c, color) + }; + return new PrimitiveMesh(colorVertices, new short[] { 0, 1, 2 }, PrimitiveType.TriangleList); + } + + public static PrimitiveMesh BuildSemiCircle( + Vector3 center, + float radius, + int segments, + Color color, + Vector3 normal, + Vector3 forward, + bool textured = false) + { + if (segments < 2) + throw new ArgumentOutOfRangeException(nameof(segments), "Semi-circle requires at least two segments."); + + var n = normal.LengthSquared() < 1e-6f ? Vector3.Backward : Vector3.Normalize(normal); + var f = forward.LengthSquared() < 1e-6f ? Vector3.Forward : Vector3.Normalize(forward); + + if (MathF.Abs(Vector3.Dot(f, n)) > 0.999f) + f = Vector3.Normalize(Vector3.Cross(n, Vector3.Right)); + + var right = Vector3.Normalize(Vector3.Cross(n, f)); + var tangent = Vector3.Normalize(Vector3.Cross(right, n)); + + if (textured) + { + var texturedVertices = new VertexPositionColorTexture[segments + 2]; + texturedVertices[0] = new VertexPositionColorTexture(center, color, new Vector2(0.5f, 1f)); + + float safeRadius = Math.Max(radius, 1e-6f); // todo: remove + float newStep = MathF.PI / segments; + + for (int i = 0; i <= segments; i++) + { + float angle = newStep * i; + Vector3 offset = right * MathF.Cos(angle) + tangent * MathF.Sin(angle); + Vector3 point = center + offset * radius; + + float x = MathHelper.Clamp(Vector3.Dot(offset, right), -1f, 1f); + float y = MathHelper.Clamp(Vector3.Dot(offset, tangent), 0f, 1f); + + float u = 0.5f + 0.5f * x; + float v = 1f - y; + + texturedVertices[i + 1] = new VertexPositionColorTexture(point, color, new Vector2(u, v)); + } + + var indices = new short[segments * 3]; + for (int i = 0; i < segments; i++) + { + int baseIndex = i * 3; + indices[baseIndex] = 0; + indices[baseIndex + 1] = (short)(i + 1); + indices[baseIndex + 2] = (short)(i + 2); + } + + return new PrimitiveMesh(texturedVertices, indices, PrimitiveType.TriangleList); + } + + var colorVertices = new VertexPositionColor[segments + 2]; + colorVertices[0] = new VertexPositionColor(center, color); + + float step = MathF.PI / segments; + for (int i = 0; i <= segments; i++) + { + float angle = step * i; + Vector3 offset = right * MathF.Cos(angle) + tangent * MathF.Sin(angle); + colorVertices[i + 1] = new VertexPositionColor(center + offset * radius, color); + } + + var colorIndices = new short[segments * 3]; + for (int i = 0; i < segments; i++) + { + int baseIndex = i * 3; + colorIndices[baseIndex] = 0; + colorIndices[baseIndex + 1] = (short)(i + 1); + colorIndices[baseIndex + 2] = (short)(i + 2); + } + + return new PrimitiveMesh(colorVertices, colorIndices, PrimitiveType.TriangleList); + } + + /// + /// Given a normal and an up hint, builds an orthonormal basis where the normal is the "forward" direction, + /// the right vector is perpendicular to both, and the up vector is perpendicular to the normal. + /// The implementation normalizes the inputs, handles near-parallel cases, and then re-orthogonalizes the up vector + /// from the computed right vector (so it is not guaranteed to be the closest possible to ). + /// + /// The forward/normal direction (fallbacks to if near-zero). + /// A preferred up direction (fallbacks to if near-zero). + /// The computed right vector. + /// The computed up vector. + private static void BuildFrame(Vector3 normal, Vector3 upHint, out Vector3 right, out Vector3 up) + { + var n = normal.LengthSquared() < 1e-6f ? Vector3.Backward : Vector3.Normalize(normal); + up = upHint.LengthSquared() < 1e-6f ? Vector3.Up : Vector3.Normalize(upHint); + + if (MathF.Abs(Vector3.Dot(n, up)) > 0.999f) + up = Vector3.Normalize(Vector3.Cross(n, Vector3.Right)); + + right = Vector3.Cross(up, n); + if (right.LengthSquared() < 1e-6f) + right = Vector3.Cross(Vector3.Forward, n); + + right.Normalize(); + up = Vector3.Normalize(Vector3.Cross(n, right)); + } + + private static Vector3 PolarToCartesian(int index, int total, Vector3 right, Vector3 up) + { + float angle = MathHelper.TwoPi * index / total; + return right * MathF.Cos(angle) + up * MathF.Sin(angle); + } + private static Vector3 EllipseDirection(int index, int total, Vector3 right, Vector3 up, Vector2 radii) + { + float angle = MathHelper.TwoPi * index / total; + return right * (MathF.Cos(angle) * radii.X) + up * (MathF.Sin(angle) * radii.Y); + } + + private static Vector3 SphericalDirection(float sinPhi, float cosPhi, float theta) + { + float cosTheta = MathF.Cos(theta); + float sinTheta = MathF.Sin(theta); + return new Vector3(sinPhi * cosTheta, cosPhi, sinPhi * sinTheta); + } +} diff --git a/Graphics/Primitives/3DRendering/PrimitiveSimd.cs b/Graphics/Primitives/3DRendering/PrimitiveSimd.cs new file mode 100644 index 0000000000..e57ee75abb --- /dev/null +++ b/Graphics/Primitives/3DRendering/PrimitiveSimd.cs @@ -0,0 +1,40 @@ +using System; + +namespace CalamityMod.Graphics.Primitives; + +internal static class PrimitiveSimd +{ + private static readonly System.Numerics.Vector LaneOffsets = CreateLaneOffsets(); + + public static void FillSequentialIndices(Span indices) + { + int i = 0; + if (System.Numerics.Vector.IsHardwareAccelerated) + { + int width = System.Numerics.Vector.Count; + Span temp = width <= 16 + ? stackalloc int[width] + : new int[width]; + + while (i <= indices.Length - width) + { + (LaneOffsets + new System.Numerics.Vector(i)).CopyTo(temp); + for (int lane = 0; lane < width; lane++) + indices[i + lane] = (short)temp[lane]; + i += width; + } + } + + for (; i < indices.Length; i++) + indices[i] = (short)i; + } + + private static System.Numerics.Vector CreateLaneOffsets() + { + int width = System.Numerics.Vector.Count; + Span lanes = stackalloc int[width]; + for (int i = 0; i < width; i++) + lanes[i] = i; + return new System.Numerics.Vector(lanes); + } +} diff --git a/Graphics/Primitives/3DRendering/SanePrimitiveRenderer.cs b/Graphics/Primitives/3DRendering/SanePrimitiveRenderer.cs new file mode 100644 index 0000000000..b91430f31e --- /dev/null +++ b/Graphics/Primitives/3DRendering/SanePrimitiveRenderer.cs @@ -0,0 +1,805 @@ +#nullable enable +using System; +using System.Collections.Generic; +using System.Diagnostics; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.GameContent; + +namespace CalamityMod.Graphics.Primitives; + +public static class SanePrimitiveRenderer +{ + private static GraphicsDevice _graphicsDevice => Main.graphics.GraphicsDevice; + private static BasicEffect? _effect; + + public readonly struct ShaderScope : IDisposable + { + private readonly GraphicsDevice _device; + private readonly Effect _effect; + private readonly bool _useBasicEffect; + private readonly Matrix _world; + private readonly Matrix _view; + private readonly Matrix _projection; + private readonly string? _transformMatrixParam; + private readonly RasterizerState _previousRasterizer; + private readonly DepthStencilState _previousDepth; + private readonly BlendState _previousBlend; + private readonly SamplerState? _previousSampler; + + internal ShaderScope( + GraphicsDevice device, + Effect effect, + bool useBasicEffect, + in Matrix world, + in Matrix view, + in Matrix projection, + string? transformMatrixParam, + RasterizerState? rasterizerState, + DepthStencilState? depthState, + BlendState? blendState, + SamplerState? samplerState) + { + _device = device; + _effect = effect; + _useBasicEffect = useBasicEffect; + _world = world; + _view = view; + _projection = projection; + _transformMatrixParam = transformMatrixParam; + + _previousRasterizer = device.RasterizerState; + _previousDepth = device.DepthStencilState; + _previousBlend = device.BlendState; + _previousSampler = device.SamplerStates[0]; + + device.RasterizerState = rasterizerState ?? RasterizerState.CullNone; + device.DepthStencilState = depthState ?? DepthStencilState.Default; + device.BlendState = blendState ?? BlendState.AlphaBlend; + device.SamplerStates[0] = samplerState ?? SamplerState.PointWrap; + + if (_useBasicEffect) + { + var basic = (BasicEffect)_effect; + basic.World = world; + basic.View = view; + basic.Projection = projection; + } + else if (transformMatrixParam != null) + { + var param = _effect.Parameters[transformMatrixParam]; + if (param != null) + param.SetValue(world * view * projection); + } + } + + public void Draw(in PrimitiveMesh mesh) + { + if (!mesh.IsValid) + return; + + if (_useBasicEffect) + { + var basic = (BasicEffect)_effect; + bool textured = mesh.UsesTexture; + basic.TextureEnabled = textured; + basic.Texture = textured ? TextureAssets.MagicPixel.Value : null; + } + + int primitiveCount = GetPrimitiveCount(mesh.PrimitiveType, mesh.Indices.Length); + bool usesTexture = mesh.UsesTexture; + + foreach (var pass in _effect.CurrentTechnique.Passes) + { + pass.Apply(); + if (usesTexture) + { + _device.DrawUserIndexedPrimitives( + mesh.PrimitiveType, + mesh.TexturedVertices, + 0, + mesh.VertexCount, + mesh.Indices, + 0, + primitiveCount); + } + else + { + _device.DrawUserIndexedPrimitives( + mesh.PrimitiveType, + mesh.ColorVertices, + 0, + mesh.VertexCount, + mesh.Indices, + 0, + primitiveCount); + } + } + } + + public void Draw(in PrimitiveMeshView mesh) + { + if (!mesh.IsValid) + return; + + if (_useBasicEffect) + { + var basic = (BasicEffect)_effect; + bool textured = mesh.UsesTexture; + basic.TextureEnabled = textured; + basic.Texture = textured ? TextureAssets.MagicPixel.Value : null; + } + + int primitiveCount = GetPrimitiveCount(mesh.PrimitiveType, mesh.IndexCount); + bool usesTexture = mesh.UsesTexture; + + foreach (var pass in _effect.CurrentTechnique.Passes) + { + pass.Apply(); + if (usesTexture) + { + _device.DrawUserIndexedPrimitives( + mesh.PrimitiveType, + mesh.TexturedVertices, + mesh.VertexOffset, + mesh.VertexCount, + mesh.Indices, + mesh.IndexOffset, + primitiveCount); + } + else + { + _device.DrawUserIndexedPrimitives( + mesh.PrimitiveType, + mesh.ColorVertices, + mesh.VertexOffset, + mesh.VertexCount, + mesh.Indices, + mesh.IndexOffset, + primitiveCount); + } + } + } + + public void Dispose() + { + _device.RasterizerState = _previousRasterizer; + _device.DepthStencilState = _previousDepth; + _device.BlendState = _previousBlend; + if (_previousSampler != null) + _device.SamplerStates[0] = _previousSampler; + } + } + + public static bool IsReady => + _graphicsDevice != null && + !_graphicsDevice.IsDisposed && + _effect != null && + !_effect.IsDisposed; + + public static void Initialize() + { + Main.RunOnMainThread(() => + { + if (_graphicsDevice == null) + throw new ArgumentNullException(nameof(_graphicsDevice)); + + _effect?.Dispose(); + _effect = new BasicEffect(_graphicsDevice) + { + VertexColorEnabled = true, + TextureEnabled = true, + LightingEnabled = false, + FogEnabled = false, + Texture = TextureAssets.Logo.Value + }; + }); + } + + public static void Dispose() + { + Main.RunOnMainThread(() => + _effect?.Dispose() + ); + } + + /// + /// Draws the specified mesh using the provided world, view, and projection matrices. + /// + /// World matrix. + /// View matrix. + /// Projection matrix. + /// The mesh to draw. + /// The rasterizer state to use. If null, defaults to . + /// The depth stencil state to use. If null, defaults to . + /// The blend state to use. If null, defaults to . + /// The renderer is not initialized. + /// The primitive type is not supported. Supported types are: TriangleList, TriangleStrip, LineList, LineStrip, and PointListEXT. + public static void DrawMesh( + in Matrix world, + in Matrix view, + in Matrix projection, + in PrimitiveMesh mesh, + RasterizerState? rasterizerState = null, + DepthStencilState? depthState = null, + BlendState? blendState = null) + { + if (!IsReady) + throw new InvalidOperationException("SanePrimitiveRenderer is not initialized."); + if (!mesh.IsValid) + return; + + Debug.Assert(_effect is not null); + + bool textured = mesh.UsesTexture; + + _effect.TextureEnabled = textured; + _effect.Texture = textured ? TextureAssets.MagicPixel.Value : null; + _graphicsDevice.SamplerStates[0] = SamplerState.PointWrap; + + _effect.World = world; + _effect.View = view; + _effect.Projection = projection; + + var device = _graphicsDevice; + + var previousRasterizer = device.RasterizerState; + var previousDepth = device.DepthStencilState; + var previousBlend = device.BlendState; + + device.RasterizerState = rasterizerState ?? RasterizerState.CullNone; + device.DepthStencilState = depthState ?? DepthStencilState.Default; + device.BlendState = blendState ?? BlendState.AlphaBlend; + + int primitiveCount = GetPrimitiveCount(mesh.PrimitiveType, mesh.Indices.Length); + + foreach (var pass in _effect.CurrentTechnique.Passes) + { + pass.Apply(); + if (textured) + { + device.DrawUserIndexedPrimitives( + mesh.PrimitiveType, + mesh.TexturedVertices, + 0, + mesh.VertexCount, + mesh.Indices, + 0, + primitiveCount); + } + else + { + device.DrawUserIndexedPrimitives( + mesh.PrimitiveType, + mesh.ColorVertices, + 0, + mesh.VertexCount, + mesh.Indices, + 0, + primitiveCount); + } + } + + device.RasterizerState = previousRasterizer; + device.DepthStencilState = previousDepth; + device.BlendState = previousBlend; + } + + /// + /// Draws the specified mesh using an arbitrary instead of the built-in .
+ /// The caller is responsible for setting all shader parameters (including any transform matrices) before calling this method.
+ /// A convenience parameter, , can be used to automatically set a uTransformMatrix + /// parameter on the effect to world * view * projection. + ///
+ /// World matrix. + /// View matrix. + /// Projection matrix. + /// The mesh to draw. + /// The custom effect to use for rendering. + /// + /// If non-null, the name of an on that will be set to world * view * projection. + /// Defaults to "uTransformMatrix". Pass null to skip automatic matrix assignment. + /// + /// The rasterizer state to use. If null, defaults to . + /// The depth stencil state to use. If null, defaults to . + /// The blend state to use. If null, defaults to . + /// is null. + /// The primitive type is not supported. + public static void DrawMesh( + in Matrix world, + in Matrix view, + in Matrix projection, + in PrimitiveMesh mesh, + Effect effect, + string? transformMatrixParam = "uTransformMatrix", + RasterizerState? rasterizerState = null, + DepthStencilState? depthState = null, + BlendState? blendState = null) + { + if (effect == null) + throw new ArgumentNullException(nameof(effect)); + if (!mesh.IsValid) + return; + + if (transformMatrixParam != null) + { + var param = effect.Parameters[transformMatrixParam]; + if (param != null) + param.SetValue(world * view * projection); + } + + var device = _graphicsDevice; + + var previousRasterizer = device.RasterizerState; + var previousDepth = device.DepthStencilState; + var previousBlend = device.BlendState; + + device.RasterizerState = rasterizerState ?? RasterizerState.CullNone; + device.DepthStencilState = depthState ?? DepthStencilState.Default; + device.BlendState = blendState ?? BlendState.AlphaBlend; + + int primitiveCount = GetPrimitiveCount(mesh.PrimitiveType, mesh.Indices.Length); + + bool textured = mesh.UsesTexture; + + foreach (var pass in effect.CurrentTechnique.Passes) + { + pass.Apply(); + if (textured) + { + device.DrawUserIndexedPrimitives( + mesh.PrimitiveType, + mesh.TexturedVertices, + 0, + mesh.VertexCount, + mesh.Indices, + 0, + primitiveCount); + } + else + { + device.DrawUserIndexedPrimitives( + mesh.PrimitiveType, + mesh.ColorVertices, + 0, + mesh.VertexCount, + mesh.Indices, + 0, + primitiveCount); + } + } + + device.RasterizerState = previousRasterizer; + device.DepthStencilState = previousDepth; + device.BlendState = previousBlend; + } + + /** + Draws a triangle strip using the specified parameters. + Alias for . Assumes you want a 'triangle strip' primitive type. + + The world matrix. + The view matrix. + The projection matrix. + The vertex positions and colors. + **/ + public static void DrawTriangleStrip( + in Matrix world, + in Matrix view, + in Matrix projection, + VertexPositionColorTexture[] vertices, + RasterizerState? rasterizerState = null, + DepthStencilState? depthState = null, + BlendState? blendState = null) + { + if (vertices == null) + throw new ArgumentNullException(nameof(vertices)); + if (vertices.Length < 3) + return; + if (vertices.Length > short.MaxValue) + throw new ArgumentOutOfRangeException(nameof(vertices), "Vertex count exceeds index buffer range."); + + DrawMesh( + world, + view, + projection, + PrimitiveMesh.FromSequential(vertices, PrimitiveType.TriangleStrip), + rasterizerState, + depthState, + blendState); + } + + /** + Draws a triangle strip using the specified parameters. + Alias for . Assumes you want a 'triangle strip' primitive type. + + The world matrix. + The view matrix. + The projection matrix. + The vertex positions and colors. + **/ + public static void DrawTriangleStrip( + in Matrix world, + in Matrix view, + in Matrix projection, + VertexPositionColor[] vertices, + RasterizerState? rasterizerState = null, + DepthStencilState? depthState = null, + BlendState? blendState = null) + { + if (vertices == null) + throw new ArgumentNullException(nameof(vertices)); + if (vertices.Length < 3) + return; + if (vertices.Length > short.MaxValue) + throw new ArgumentOutOfRangeException(nameof(vertices), "Vertex count exceeds index buffer range."); + + DrawMesh( + world, + view, + projection, + PrimitiveMesh.FromSequential(vertices, PrimitiveType.TriangleStrip), + rasterizerState, + depthState, + blendState); + } + + /** + Draws a triangle list using the specified parameters. + Alias for . Assumes you want a 'triangle list' primitive type. + + The world matrix. + The view matrix. + The projection matrix. + The vertex positions and colors. + **/ + public static void DrawTriangleList( + in Matrix world, + in Matrix view, + in Matrix projection, + VertexPositionColorTexture[] vertices, + RasterizerState? rasterizerState = null, + DepthStencilState? depthState = null, + BlendState? blendState = null) + { + if (vertices == null) + throw new ArgumentNullException(nameof(vertices)); + if (vertices.Length < 3 || vertices.Length % 3 != 0) + return; + if (vertices.Length > short.MaxValue) + throw new ArgumentOutOfRangeException(nameof(vertices), "Vertex count exceeds index buffer range."); + + DrawMesh( + world, + view, + projection, + PrimitiveMesh.FromSequential(vertices, PrimitiveType.TriangleList), + rasterizerState, + depthState, + blendState); + } + + /** + Draws a triangle list using the specified parameters. + Alias for . Assumes you want a 'triangle list' primitive type. + + The world matrix. + The view matrix. + The projection matrix. + The vertex positions and colors. + **/ + public static void DrawTriangleList( + in Matrix world, + in Matrix view, + in Matrix projection, + VertexPositionColor[] vertices, + RasterizerState? rasterizerState = null, + DepthStencilState? depthState = null, + BlendState? blendState = null) + { + if (vertices == null) + throw new ArgumentNullException(nameof(vertices)); + if (vertices.Length < 3 || vertices.Length % 3 != 0) + return; + if (vertices.Length > short.MaxValue) + throw new ArgumentOutOfRangeException(nameof(vertices), "Vertex count exceeds index buffer range."); + + DrawMesh( + world, + view, + projection, + PrimitiveMesh.FromSequential(vertices, PrimitiveType.TriangleList), + rasterizerState, + depthState, + blendState); + } + + public static void DrawMesh( + in Matrix world, + in Matrix view, + in Matrix projection, + in PrimitiveMeshView mesh, + RasterizerState? rasterizerState = null, + DepthStencilState? depthState = null, + BlendState? blendState = null) + { + if (!IsReady) + throw new InvalidOperationException("SanePrimitiveRenderer is not initialized."); + if (!mesh.IsValid) + return; + + Debug.Assert(_effect is not null); + + bool textured = mesh.UsesTexture; + + _effect.TextureEnabled = textured; + _effect.Texture = textured ? TextureAssets.MagicPixel.Value : null; + _graphicsDevice.SamplerStates[0] = SamplerState.PointWrap; + + _effect.World = world; + _effect.View = view; + _effect.Projection = projection; + + var device = _graphicsDevice; + + var previousRasterizer = device.RasterizerState; + var previousDepth = device.DepthStencilState; + var previousBlend = device.BlendState; + + device.RasterizerState = rasterizerState ?? RasterizerState.CullNone; + device.DepthStencilState = depthState ?? DepthStencilState.Default; + device.BlendState = blendState ?? BlendState.AlphaBlend; + + int primitiveCount = GetPrimitiveCount(mesh.PrimitiveType, mesh.IndexCount); + + foreach (var pass in _effect.CurrentTechnique.Passes) + { + pass.Apply(); + if (textured) + { + device.DrawUserIndexedPrimitives( + mesh.PrimitiveType, + mesh.TexturedVertices, + mesh.VertexOffset, + mesh.VertexCount, + mesh.Indices, + mesh.IndexOffset, + primitiveCount); + } + else + { + device.DrawUserIndexedPrimitives( + mesh.PrimitiveType, + mesh.ColorVertices, + mesh.VertexOffset, + mesh.VertexCount, + mesh.Indices, + mesh.IndexOffset, + primitiveCount); + } + } + + device.RasterizerState = previousRasterizer; + device.DepthStencilState = previousDepth; + device.BlendState = previousBlend; + } + + public static void DrawMesh( + in Matrix world, + in Matrix view, + in Matrix projection, + in PrimitiveMeshView mesh, + Effect effect, + string? transformMatrixParam = "uTransformMatrix", + RasterizerState? rasterizerState = null, + DepthStencilState? depthState = null, + BlendState? blendState = null) + { + if (effect == null) + throw new ArgumentNullException(nameof(effect)); + if (!mesh.IsValid) + return; + + if (transformMatrixParam != null) + { + var param = effect.Parameters[transformMatrixParam]; + if (param != null) + param.SetValue(world * view * projection); + } + + var device = _graphicsDevice; + + var previousRasterizer = device.RasterizerState; + var previousDepth = device.DepthStencilState; + var previousBlend = device.BlendState; + + device.RasterizerState = rasterizerState ?? RasterizerState.CullNone; + device.DepthStencilState = depthState ?? DepthStencilState.Default; + device.BlendState = blendState ?? BlendState.AlphaBlend; + + int primitiveCount = GetPrimitiveCount(mesh.PrimitiveType, mesh.IndexCount); + + bool textured = mesh.UsesTexture; + + foreach (var pass in effect.CurrentTechnique.Passes) + { + pass.Apply(); + if (textured) + { + device.DrawUserIndexedPrimitives( + mesh.PrimitiveType, + mesh.TexturedVertices, + mesh.VertexOffset, + mesh.VertexCount, + mesh.Indices, + mesh.IndexOffset, + primitiveCount); + } + else + { + device.DrawUserIndexedPrimitives( + mesh.PrimitiveType, + mesh.ColorVertices, + mesh.VertexOffset, + mesh.VertexCount, + mesh.Indices, + mesh.IndexOffset, + primitiveCount); + } + } + + device.RasterizerState = previousRasterizer; + device.DepthStencilState = previousDepth; + device.BlendState = previousBlend; + } + + public static ShaderScope BeginShaderScope( + in Matrix world, + in Matrix view, + in Matrix projection, + RasterizerState? rasterizerState = null, + DepthStencilState? depthState = null, + BlendState? blendState = null, + SamplerState? samplerState = null) + { + if (!IsReady) + throw new InvalidOperationException("SanePrimitiveRenderer is not initialized."); + + Debug.Assert(_effect is not null); + + return new ShaderScope( + _graphicsDevice, + _effect, + true, + world, + view, + projection, + null, + rasterizerState, + depthState, + blendState, + samplerState); + } + + public static ShaderScope BeginShaderScope( + Effect effect, + in Matrix world, + in Matrix view, + in Matrix projection, + string? transformMatrixParam = "uTransformMatrix", + RasterizerState? rasterizerState = null, + DepthStencilState? depthState = null, + BlendState? blendState = null, + SamplerState? samplerState = null) + { + if (effect == null) + throw new ArgumentNullException(nameof(effect)); + + return new ShaderScope( + _graphicsDevice, + effect, + false, + world, + view, + projection, + transformMatrixParam, + rasterizerState, + depthState, + blendState, + samplerState); + } + + public static void DrawMeshes( + in Matrix world, + in Matrix view, + in Matrix projection, + IReadOnlyList meshes, + RasterizerState? rasterizerState = null, + DepthStencilState? depthState = null, + BlendState? blendState = null, + SamplerState? samplerState = null) + { + if (meshes == null) + throw new ArgumentNullException(nameof(meshes)); + + using var scope = BeginShaderScope(world, view, projection, rasterizerState, depthState, blendState, samplerState); + for (int i = 0; i < meshes.Count; i++) + scope.Draw(meshes[i]); + } + + public static void DrawMeshes( + in Matrix world, + in Matrix view, + in Matrix projection, + IReadOnlyList meshes, + RasterizerState? rasterizerState = null, + DepthStencilState? depthState = null, + BlendState? blendState = null, + SamplerState? samplerState = null) + { + if (meshes == null) + throw new ArgumentNullException(nameof(meshes)); + + using var scope = BeginShaderScope(world, view, projection, rasterizerState, depthState, blendState, samplerState); + for (int i = 0; i < meshes.Count; i++) + scope.Draw(meshes[i]); + } + + public static void DrawMeshes( + Effect effect, + in Matrix world, + in Matrix view, + in Matrix projection, + IReadOnlyList meshes, + string? transformMatrixParam = "uTransformMatrix", + RasterizerState? rasterizerState = null, + DepthStencilState? depthState = null, + BlendState? blendState = null, + SamplerState? samplerState = null) + { + if (effect == null) + throw new ArgumentNullException(nameof(effect)); + if (meshes == null) + throw new ArgumentNullException(nameof(meshes)); + + using var scope = BeginShaderScope(effect, world, view, projection, transformMatrixParam, rasterizerState, depthState, blendState, samplerState); + for (int i = 0; i < meshes.Count; i++) + scope.Draw(meshes[i]); + } + + public static void DrawMeshes( + Effect effect, + in Matrix world, + in Matrix view, + in Matrix projection, + IReadOnlyList meshes, + string? transformMatrixParam = "uTransformMatrix", + RasterizerState? rasterizerState = null, + DepthStencilState? depthState = null, + BlendState? blendState = null, + SamplerState? samplerState = null) + { + if (effect == null) + throw new ArgumentNullException(nameof(effect)); + if (meshes == null) + throw new ArgumentNullException(nameof(meshes)); + + using var scope = BeginShaderScope(effect, world, view, projection, transformMatrixParam, rasterizerState, depthState, blendState, samplerState); + for (int i = 0; i < meshes.Count; i++) + scope.Draw(meshes[i]); + } + + private static int GetPrimitiveCount(PrimitiveType primitiveType, int indexCount) + { + return primitiveType switch + { + PrimitiveType.TriangleList => indexCount / 3, + PrimitiveType.TriangleStrip => Math.Max(indexCount - 2, 0), + PrimitiveType.LineList => indexCount / 2, + PrimitiveType.LineStrip => Math.Max(indexCount - 1, 0), + PrimitiveType.PointListEXT => indexCount, + _ => throw new NotSupportedException(primitiveType.ToString()) + }; + } +} diff --git a/Graphics/Primitives/3DRendering/StripCapStyle.cs b/Graphics/Primitives/3DRendering/StripCapStyle.cs new file mode 100644 index 0000000000..9375eb134e --- /dev/null +++ b/Graphics/Primitives/3DRendering/StripCapStyle.cs @@ -0,0 +1,16 @@ +namespace CalamityMod.Graphics.Primitives; + +/// +/// Determines the shape of end caps for strip primitives. This is used to give a more polished look to the start and end of strips, especially when they are thick. The cap is drawn at the end of the strip, centered on the last vertex, and oriented to match the strip's direction at that point. The options are: +/// +/// : No cap is drawn, leaving the strip to end abruptly at the last vertex. This is the default and most performant option. +/// : A simple triangular cap is drawn, extending the strip in a pointed shape. The triangle's base is aligned with the last segment of the strip, and its height is proportional to the strip's width. +/// : A semicircular cap is drawn, creating a rounded end to the strip. +/// +/// +public enum StripCapStyle +{ + None, + Triangle, + HalfCircle +} diff --git a/Graphics/Primitives/3DRendering/StripCurveType.cs b/Graphics/Primitives/3DRendering/StripCurveType.cs new file mode 100644 index 0000000000..cd311962c8 --- /dev/null +++ b/Graphics/Primitives/3DRendering/StripCurveType.cs @@ -0,0 +1,18 @@ +namespace CalamityMod.Graphics.Primitives; + + +/// +/// Specifies the type of curve interpolation to use when generating a strip mesh from a sequence of points. +/// +/// +/// The curve type determines how the strip will be shaped between the control points. +/// Different curve types can produce smoother or sharper results, and may have different performance characteristics. +/// +/// +public enum StripCurveType +{ + CatmullRom, + Linear, + CubicBezier, + Hermite +} diff --git a/Graphics/Primitives/3DRendering/StripJoinStyle.cs b/Graphics/Primitives/3DRendering/StripJoinStyle.cs new file mode 100644 index 0000000000..6c9d2bfd9d --- /dev/null +++ b/Graphics/Primitives/3DRendering/StripJoinStyle.cs @@ -0,0 +1,15 @@ +namespace CalamityMod.Graphics.Primitives; + +/// +/// Specifies how to join segments in a strip mesh. +/// +/// +/// : Uses the averaged per-segment right vectors to build a perpendicular join at corners. This is the default and most performant option. +/// : Uses a miter join that extends the edges to their intersection, with a built-in miter limit to avoid extreme spikes on sharp angles. +/// +/// +public enum StripJoinStyle +{ + Perpendicular, + Miter +} diff --git a/Graphics/Primitives/3DRendering/StripWidthAttenuation.cs b/Graphics/Primitives/3DRendering/StripWidthAttenuation.cs new file mode 100644 index 0000000000..8d211871b9 --- /dev/null +++ b/Graphics/Primitives/3DRendering/StripWidthAttenuation.cs @@ -0,0 +1,15 @@ +namespace CalamityMod.Graphics.Primitives; + +/// +/// Controls how strip width is attenuated along the path. +/// +/// +/// : No attenuation is applied; width comes solely from the provided width function/constant. +/// : Attenuates width based on directional continuity between consecutive tangents. +/// +/// +public enum StripWidthAttenuation +{ + None, + ContinuitySquared +} diff --git a/Graphics/Primitives/3DRendering/TriangleStripBuilder.cs b/Graphics/Primitives/3DRendering/TriangleStripBuilder.cs new file mode 100644 index 0000000000..2e63ac6a14 --- /dev/null +++ b/Graphics/Primitives/3DRendering/TriangleStripBuilder.cs @@ -0,0 +1,1369 @@ +#nullable enable +using System; +using System.Collections.Generic; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +namespace CalamityMod.Graphics.Primitives; + +public static class TriangleStripBuilder +{ + + /// + /// Builds a triangle strip mesh along the specified path with a uniform color, using pooled buffers. + /// + public static PooledPrimitiveMesh BuildStripPooled( + IReadOnlyList path, + float width, + Color color, + PrimitiveMeshCache? cache, + Vector3? upHint = null, + int smoothingSegments = 0, + StripCapStyle startCap = StripCapStyle.None, + StripCapStyle endCap = StripCapStyle.None, + int capSegments = 8, + StripJoinStyle joinStyle = StripJoinStyle.Perpendicular, + bool textured = true, + StripCurveType smoothingCurve = StripCurveType.CatmullRom, + StripWidthAttenuation widthAttenuation = StripWidthAttenuation.None) + { + if (path == null) + throw new ArgumentNullException(nameof(path)); + if (width <= 0f) + throw new ArgumentOutOfRangeException(nameof(width), "Width must be positive."); + + return BuildStripCorePooled( + path, + _ => color, + _ => width, + upHint ?? Vector3.UnitZ, + smoothingSegments, + startCap, + endCap, + capSegments, + joinStyle, + textured, + smoothingCurve, + widthAttenuation, + cache); + } + + /// + /// Builds a triangle strip mesh along the specified path with varying colors, using pooled buffers. + /// + public static PooledPrimitiveMesh BuildStripPooled( + IReadOnlyList path, + float width, + IReadOnlyList colors, + PrimitiveMeshCache? cache, + Vector3? upHint = null, + int smoothingSegments = 0, + StripCapStyle startCap = StripCapStyle.None, + StripCapStyle endCap = StripCapStyle.None, + int capSegments = 8, + StripJoinStyle joinStyle = StripJoinStyle.Perpendicular, + bool textured = true, + StripCurveType smoothingCurve = StripCurveType.CatmullRom, + StripWidthAttenuation widthAttenuation = StripWidthAttenuation.None) + { + if (path == null) + throw new ArgumentNullException(nameof(path)); + if (colors == null) + throw new ArgumentNullException(nameof(colors)); + if (colors.Count != path.Count) + throw new ArgumentException("Color count must match path length.", nameof(colors)); + if (width <= 0f) + throw new ArgumentOutOfRangeException(nameof(width), "Width must be positive."); + + return BuildStripCorePooled( + path, + progress => SampleColor(colors, progress), + _ => width, + upHint ?? Vector3.UnitZ, + smoothingSegments, + startCap, + endCap, + capSegments, + joinStyle, + textured, + smoothingCurve, + widthAttenuation, + cache); + } + + /// + /// Builds a triangle strip mesh along the specified path with varying width, using pooled buffers. + /// + public static PooledPrimitiveMesh BuildStripPooled( + IReadOnlyList path, + Func widthFunc, + Color color, + PrimitiveMeshCache? cache, + Func? easing = null, + Vector3? upHint = null, + int smoothingSegments = 0, + StripCapStyle startCap = StripCapStyle.None, + StripCapStyle endCap = StripCapStyle.None, + int capSegments = 8, + StripJoinStyle joinStyle = StripJoinStyle.Perpendicular, + bool textured = true, + StripCurveType smoothingCurve = StripCurveType.CatmullRom, + StripWidthAttenuation widthAttenuation = StripWidthAttenuation.None) + { + if (path == null) + throw new ArgumentNullException(nameof(path)); + if (widthFunc == null) + throw new ArgumentNullException(nameof(widthFunc)); + + return BuildStripCorePooled( + path, + _ => color, + progress => EvaluateWidth(widthFunc, easing, progress), + upHint ?? Vector3.UnitZ, + smoothingSegments, + startCap, + endCap, + capSegments, + joinStyle, + textured, + smoothingCurve, + widthAttenuation, + cache); + } + + /// + /// Builds a triangle strip mesh along the specified path with varying width and gradient colors, using pooled buffers. + /// + public static PooledPrimitiveMesh BuildStripPooled( + IReadOnlyList path, + Func widthFunc, + IReadOnlyList colors, + PrimitiveMeshCache? cache, + Func? easing = null, + Vector3? upHint = null, + int smoothingSegments = 0, + StripCapStyle startCap = StripCapStyle.None, + StripCapStyle endCap = StripCapStyle.None, + int capSegments = 8, + StripJoinStyle joinStyle = StripJoinStyle.Perpendicular, + bool textured = true, + StripCurveType smoothingCurve = StripCurveType.CatmullRom, + StripWidthAttenuation widthAttenuation = StripWidthAttenuation.None) + { + if (path == null) + throw new ArgumentNullException(nameof(path)); + if (colors == null) + throw new ArgumentNullException(nameof(colors)); + if (colors.Count != path.Count) + throw new ArgumentException("Color count must match path length.", nameof(colors)); + if (widthFunc == null) + throw new ArgumentNullException(nameof(widthFunc)); + + return BuildStripCorePooled( + path, + progress => SampleColor(colors, progress), + progress => EvaluateWidth(widthFunc, easing, progress), + upHint ?? Vector3.UnitZ, + smoothingSegments, + startCap, + endCap, + capSegments, + joinStyle, + textured, + smoothingCurve, + widthAttenuation, + cache); + } + + /// + /// Builds a triangle strip mesh along the specified path with varying width and color, using pooled buffers. + /// + public static PooledPrimitiveMesh BuildStripPooled( + IReadOnlyList path, + Func widthFunc, + Func colorFunc, + PrimitiveMeshCache? cache, + Func? easing = null, + Vector3? upHint = null, + int smoothingSegments = 0, + StripCapStyle startCap = StripCapStyle.None, + StripCapStyle endCap = StripCapStyle.None, + int capSegments = 8, + StripJoinStyle joinStyle = StripJoinStyle.Perpendicular, + bool textured = true, + StripCurveType smoothingCurve = StripCurveType.CatmullRom, + StripWidthAttenuation widthAttenuation = StripWidthAttenuation.None) + { + if (path == null) + throw new ArgumentNullException(nameof(path)); + if (widthFunc == null) + throw new ArgumentNullException(nameof(widthFunc)); + if (colorFunc == null) + throw new ArgumentNullException(nameof(colorFunc)); + + return BuildStripCorePooled( + path, + progress => colorFunc(MathHelper.Clamp(progress, 0f, 1f)), + progress => EvaluateWidth(widthFunc, easing, progress), + upHint ?? Vector3.UnitZ, + smoothingSegments, + startCap, + endCap, + capSegments, + joinStyle, + textured, + smoothingCurve, + widthAttenuation, + cache); + } + + /// + /// Builds a triangle strip mesh along the specified path with a uniform color. + /// + /// The path along which the strip is built. + /// The width of the strip. + /// The color of the strip. + /// An optional hint for the up vector. + /// The number of segments to use for smoothing. + /// The style of cap at the start of the strip. + /// The style of cap at the end of the strip. + /// The number of segments to use for each cap. + /// The style of join between segments. + /// The style of width attenuation along the strip. + /// The curve type for smoothing. + /// A triangle strip mesh. + /// + /// + public static PrimitiveMesh BuildStrip(IReadOnlyList path, float width, Color color, Vector3? upHint = null, int smoothingSegments = 0, StripCapStyle startCap = StripCapStyle.None, StripCapStyle endCap = StripCapStyle.None, int capSegments = 8, StripJoinStyle joinStyle = StripJoinStyle.Perpendicular, bool textured = true, StripCurveType smoothingCurve = StripCurveType.CatmullRom, StripWidthAttenuation widthAttenuation = StripWidthAttenuation.None) + { + if (path == null) + throw new ArgumentNullException(nameof(path)); + if (width <= 0f) + throw new ArgumentOutOfRangeException(nameof(width), "Width must be positive."); + + return BuildStripCore( + path, + _ => color, + _ => width, + upHint ?? Vector3.UnitZ, + smoothingSegments, + startCap, + endCap, + capSegments, + joinStyle, + textured, + smoothingCurve, + widthAttenuation); + } + + /// + /// Builds a triangle strip mesh along the specified path with varying colors. + /// + /// The path along which the strip is built. + /// The width of the strip. + /// The colors of the strip at each point. + /// An optional hint for the up vector. + /// The number of segments to use for smoothing. + /// The style of cap at the start of the strip. + /// The style of cap at the end of the strip. + /// The number of segments to use for each cap. + /// The style of join between segments. + /// The style of width attenuation along the strip. + /// The curve type for smoothing. + /// A triangle strip mesh. + /// + /// + public static PrimitiveMesh BuildStrip(IReadOnlyList path, float width, IReadOnlyList colors, Vector3? upHint = null, int smoothingSegments = 0, StripCapStyle startCap = StripCapStyle.None, StripCapStyle endCap = StripCapStyle.None, int capSegments = 8, StripJoinStyle joinStyle = StripJoinStyle.Perpendicular, bool textured = true, StripCurveType smoothingCurve = StripCurveType.CatmullRom, StripWidthAttenuation widthAttenuation = StripWidthAttenuation.None) + { + if (path == null) + throw new ArgumentNullException(nameof(path)); + if (colors == null) + throw new ArgumentNullException(nameof(colors)); + if (colors.Count != path.Count) + throw new ArgumentException("Color count must match path length.", nameof(colors)); + if (width <= 0f) + throw new ArgumentOutOfRangeException(nameof(width), "Width must be positive."); + + return BuildStripCore( + path, + progress => SampleColor(colors, progress), + _ => width, + upHint ?? Vector3.UnitZ, + smoothingSegments, + startCap, + endCap, + capSegments, + joinStyle, + textured, + smoothingCurve, + widthAttenuation); + } + /// + /// Builds a triangle strip mesh along the specified path. + /// + /// The path along which the strip is built. + /// A function that maps progress (0 to 1) to the width at that point. + /// The color of the strip. + /// An optional easing function to apply to the progress. + /// An optional hint for the up vector. + /// The number of segments to use for smoothing. + /// The style of cap at the start of the strip. + /// The style of cap at the end of the strip. + /// The number of segments to use for each cap. + /// The style of join between segments. + /// The style of width attenuation along the strip. + /// The curve type for smoothing. + /// A triangle strip mesh. + /// + public static PrimitiveMesh BuildStrip( + IReadOnlyList path, + Func widthFunc, + Color color, + Func? easing = null, + Vector3? upHint = null, + int smoothingSegments = 0, + StripCapStyle startCap = StripCapStyle.None, + StripCapStyle endCap = StripCapStyle.None, + int capSegments = 8, + StripJoinStyle joinStyle = StripJoinStyle.Perpendicular, + bool textured = true, + StripCurveType smoothingCurve = StripCurveType.CatmullRom, + StripWidthAttenuation widthAttenuation = StripWidthAttenuation.None) + { + if (path == null) + throw new ArgumentNullException(nameof(path)); + if (widthFunc == null) + throw new ArgumentNullException(nameof(widthFunc)); + + return BuildStripCore( + path, + _ => color, + progress => EvaluateWidth(widthFunc, easing, progress), + upHint ?? Vector3.UnitZ, + smoothingSegments, + startCap, + endCap, + capSegments, + joinStyle, + textured, + smoothingCurve, + widthAttenuation); + } + /// + /// Builds a triangle strip mesh along the specified path with a gradient color. + /// + /// The path along which the strip is built. + /// A function that maps progress (0 to 1) to the width at that point. + /// The colors of the strip. + /// An optional easing function to apply to the progress. + /// An optional hint for the up vector. + /// The number of segments to use for smoothing. + /// The style of cap at the start of the strip. + /// The style of cap at the end of the strip. + /// The number of segments to use for each cap. + /// The style of join between segments. + /// A triangle strip mesh. + /// + /// + public static PrimitiveMesh BuildStrip( + IReadOnlyList path, + Func widthFunc, + IReadOnlyList colors, + Func? easing = null, + Vector3? upHint = null, + int smoothingSegments = 0, + StripCapStyle startCap = StripCapStyle.None, + StripCapStyle endCap = StripCapStyle.None, + int capSegments = 8, + StripJoinStyle joinStyle = StripJoinStyle.Perpendicular, + bool textured = true, + StripCurveType smoothingCurve = StripCurveType.CatmullRom, + StripWidthAttenuation widthAttenuation = StripWidthAttenuation.None) + { + if (path == null) + throw new ArgumentNullException(nameof(path)); + if (colors == null) + throw new ArgumentNullException(nameof(colors)); + if (colors.Count != path.Count) + throw new ArgumentException("Color count must match path length.", nameof(colors)); + if (widthFunc == null) + throw new ArgumentNullException(nameof(widthFunc)); + + return BuildStripCore( + path, + progress => SampleColor(colors, progress), + progress => EvaluateWidth(widthFunc, easing, progress), + upHint ?? Vector3.UnitZ, + smoothingSegments, + startCap, + endCap, + capSegments, + joinStyle, + textured, + smoothingCurve, + widthAttenuation); + } + /// + /// Builds a triangle strip mesh along the specified path with varying width and color. + /// + /// The path along which the strip is built. + /// A function that maps progress (0 to 1) to the width at that point. + /// A function that maps progress (0 to 1) to the color at that point. + /// An optional easing function to apply to the progress. + /// An optional hint for the up vector. + /// The number of segments to use for smoothing. + /// The style of cap at the start of the strip. + /// The style of cap at the end of the strip. + /// The number of segments to use for each cap. + /// The style of join between segments. + /// The style of width attenuation. + /// The curve type for smoothing. + /// A triangle strip mesh. + /// + public static PrimitiveMesh BuildStrip( + IReadOnlyList path, + Func widthFunc, + Func colorFunc, + Func? easing = null, + Vector3? upHint = null, + int smoothingSegments = 0, + StripCapStyle startCap = StripCapStyle.None, + StripCapStyle endCap = StripCapStyle.None, + int capSegments = 8, + StripJoinStyle joinStyle = StripJoinStyle.Perpendicular, + bool textured = true, + StripCurveType smoothingCurve = StripCurveType.CatmullRom, + StripWidthAttenuation widthAttenuation = StripWidthAttenuation.None) + { + if (path == null) + throw new ArgumentNullException(nameof(path)); + if (widthFunc == null) + throw new ArgumentNullException(nameof(widthFunc)); + if (colorFunc == null) + throw new ArgumentNullException(nameof(colorFunc)); + + return BuildStripCore( + path, + progress => colorFunc(MathHelper.Clamp(progress, 0f, 1f)), + progress => EvaluateWidth(widthFunc, easing, progress), + upHint ?? Vector3.UnitZ, + smoothingSegments, + startCap, + endCap, + capSegments, + joinStyle, + textured, + smoothingCurve, + widthAttenuation); + } + /// + /// Core implementation for building a triangle strip mesh. + /// + /// The path along which the strip is built. + /// A function that resolves the color at a given progress. + /// A function that resolves the width at a given progress. + /// The up vector for the strip. + private static PrimitiveMesh BuildStripCore( + IReadOnlyList path, + Func colorResolver, + Func widthResolver, + Vector3 up, + int smoothingSegments, + StripCapStyle startCap, + StripCapStyle endCap, + int capSegments, + StripJoinStyle joinStyle, + bool textured, + StripCurveType smoothingCurve, + StripWidthAttenuation widthAttenuation) + { + if (path.Count < 2) + throw new ArgumentException("At least two points are required.", nameof(path)); + if (colorResolver == null) + throw new ArgumentNullException(nameof(colorResolver)); + if (widthResolver == null) + throw new ArgumentNullException(nameof(widthResolver)); + + var workingPath = RemoveDegenerates(MaybeSmoothPath(path, smoothingSegments, smoothingCurve)); + var progress = ComputeProgress(workingPath, out _); + + var texturedVertices = textured ? new VertexPositionColorTexture[workingPath.Count * 2] : null; + var colorVertices = textured ? null : new VertexPositionColor[workingPath.Count * 2]; + + if ((textured ? texturedVertices!.Length : colorVertices!.Length) > short.MaxValue) + throw new InvalidOperationException("Strip produced more vertices than supported by the index buffer."); + + var tangents = new Vector3[workingPath.Count]; + var rights = new Vector3[workingPath.Count]; + var centers = new Vector3[workingPath.Count]; + var sectionColors = new Color[workingPath.Count]; + var halfWidths = new float[workingPath.Count]; + + var upNormalized = up.LengthSquared() < 1e-6f ? Vector3.UnitZ : Vector3.Normalize(up); + + int segmentCount = workingPath.Count - 1; + var segmentDirs = new Vector3[segmentCount]; + var segmentRights = new Vector3[segmentCount]; + + for (int i = 0; i < segmentCount; i++) + { + Vector3 dir = workingPath[i + 1] - workingPath[i]; + if (dir.LengthSquared() < 1e-6f) + dir = i > 0 ? segmentDirs[i - 1] : Vector3.UnitY; + dir.Normalize(); + + Vector3 right = Vector3.Cross(upNormalized, dir); + if (right.LengthSquared() < 1e-6f) + right = FindPerpendicular(dir); + else + right.Normalize(); + + segmentDirs[i] = dir; + segmentRights[i] = right; + } + + Vector3 lastTangent = segmentDirs[0]; + + for (int i = 0; i < workingPath.Count; i++) + { + var position = workingPath[i]; + float t = progress[i]; + float baseWidth = Math.Max(0f, widthResolver(MathHelper.Clamp(t, 0f, 1f))); + + Vector3 prevDir = segmentDirs[Math.Max(i - 1, 0)]; + Vector3 nextDir = segmentDirs[Math.Min(i, segmentCount - 1)]; + + Vector3 tangent; + if (i == 0) + tangent = nextDir; + else if (i == segmentCount) + tangent = prevDir; + else + { + tangent = prevDir + nextDir; + if (tangent.LengthSquared() < 1e-6f) + tangent = nextDir; + else + tangent.Normalize(); + } + + float width = baseWidth; + + + if (i > 0 && widthAttenuation == StripWidthAttenuation.ContinuitySquared) + { + float continuity = MathHelper.Clamp((Vector3.Dot(lastTangent, tangent) + 1f) * 0.5f, 0f, 1f); + width *= continuity * continuity; + } + + float halfWidth = width * 0.5f; + + Vector3 prevRight = segmentRights[Math.Max(i - 1, 0)]; + Vector3 nextRight = segmentRights[Math.Min(i, segmentCount - 1)]; + + Vector3 rightOffset; + Vector3 leftOffset; + + if (joinStyle == StripJoinStyle.Miter) + { + rightOffset = ComputeMiterOffset(prevRight, nextRight, i == 0, i == segmentCount, halfWidth); + leftOffset = ComputeMiterOffset(-prevRight, -nextRight, i == 0, i == segmentCount, halfWidth); + } + else + { + Vector3 joinNormal; + if (i == 0) + joinNormal = nextRight; + else if (i == segmentCount) + joinNormal = prevRight; + else + { + joinNormal = prevRight + nextRight; + if (joinNormal.LengthSquared() < 1e-6f) + joinNormal = nextRight; + } + + if (joinNormal.LengthSquared() < 1e-6f) + joinNormal = Vector3.UnitY; + + joinNormal.Normalize(); + rightOffset = joinNormal * halfWidth; + leftOffset = -joinNormal * halfWidth; + } + + Vector3 leftPos = position + leftOffset; + Vector3 rightPos = position + rightOffset; + Vector3 chord = rightPos - leftPos; + float chordLength = chord.Length(); + Vector3 lateralDir = chordLength > 1e-6f ? chord / chordLength : (nextRight.LengthSquared() > 1e-6f ? nextRight : Vector3.UnitX); + Vector3 crossCenter = (leftPos + rightPos) * 0.5f; + float effectiveHalfWidth = chordLength * 0.5f; + + float uCoord = progress[i]; + var color = colorResolver(t); + + if (textured) + { + texturedVertices![i * 2] = CreateEdgeVertex(leftPos, color, uCoord, isLeft: true); + texturedVertices[i * 2 + 1] = CreateEdgeVertex(rightPos, color, uCoord, isLeft: false); + } + else + { + colorVertices![i * 2] = new VertexPositionColor(leftPos, color); + colorVertices[i * 2 + 1] = new VertexPositionColor(rightPos, color); + } + + Vector3 rightForCap = lateralDir.LengthSquared() > 1e-6f ? lateralDir : Vector3.UnitX; + + tangents[i] = tangent; + rights[i] = Vector3.Normalize(rightForCap); + centers[i] = crossCenter; + sectionColors[i] = color; + halfWidths[i] = effectiveHalfWidth; + lastTangent = tangent; + } + + bool needCaps = startCap != StripCapStyle.None || endCap != StripCapStyle.None; + if (!needCaps) + { + var stripIndices = new short[textured ? texturedVertices!.Length : colorVertices!.Length]; + PrimitiveSimd.FillSequentialIndices(stripIndices.AsSpan()); + + return textured + ? new PrimitiveMesh(texturedVertices!, stripIndices, PrimitiveType.TriangleStrip) + : new PrimitiveMesh(colorVertices!, stripIndices, PrimitiveType.TriangleStrip); + } + + if (textured) + { + var vertexList = new List(texturedVertices!); + var indexList = new List(); + AppendStripAsTriangles(indexList, vertexList.Count); + + int startLeftIndex = 0; + int startRightIndex = 1; + int endLeftIndex = texturedVertices!.Length - 2; + int endRightIndex = texturedVertices!.Length - 1; + int capSteps = Math.Max(2, capSegments); + float startU = progress[0]; + float endU = progress[^1]; + + if (startCap == StripCapStyle.Triangle) + AddTriangleCap(vertexList, indexList, centers[0], tangents[0], rights[0], halfWidths[0], sectionColors[0], startU, startLeftIndex, startRightIndex, true); + else if (startCap == StripCapStyle.HalfCircle) + AddHalfCircleCap(vertexList, indexList, centers[0], tangents[0], rights[0], halfWidths[0], sectionColors[0], startU, startLeftIndex, startRightIndex, true, capSteps); + + if (endCap == StripCapStyle.Triangle) + AddTriangleCap(vertexList, indexList, centers[^1], tangents[^1], rights[^1], halfWidths[^1], sectionColors[^1], endU, endLeftIndex, endRightIndex, false); + else if (endCap == StripCapStyle.HalfCircle) + AddHalfCircleCap(vertexList, indexList, centers[^1], tangents[^1], rights[^1], halfWidths[^1], sectionColors[^1], endU, endLeftIndex, endRightIndex, false, capSteps); + + return new PrimitiveMesh(vertexList.ToArray(), indexList.ToArray(), PrimitiveType.TriangleList); + } + else + { + var vertexList = new List(colorVertices!); + var indexList = new List(); + AppendStripAsTriangles(indexList, vertexList.Count); + + int startLeftIndex = 0; + int startRightIndex = 1; + int endLeftIndex = colorVertices!.Length - 2; + int endRightIndex = colorVertices!.Length - 1; + int capSteps = Math.Max(2, capSegments); + + if (startCap == StripCapStyle.Triangle) + AddTriangleCap(vertexList, indexList, centers[0], tangents[0], rights[0], halfWidths[0], sectionColors[0], startLeftIndex, startRightIndex, true); + else if (startCap == StripCapStyle.HalfCircle) + AddHalfCircleCap(vertexList, indexList, centers[0], tangents[0], rights[0], halfWidths[0], sectionColors[0], startLeftIndex, startRightIndex, true, capSteps); + + if (endCap == StripCapStyle.Triangle) + AddTriangleCap(vertexList, indexList, centers[^1], tangents[^1], rights[^1], halfWidths[^1], sectionColors[^1], endLeftIndex, endRightIndex, false); + else if (endCap == StripCapStyle.HalfCircle) + AddHalfCircleCap(vertexList, indexList, centers[^1], tangents[^1], rights[^1], halfWidths[^1], sectionColors[^1], endLeftIndex, endRightIndex, false, capSteps); + + return new PrimitiveMesh(vertexList.ToArray(), indexList.ToArray(), PrimitiveType.TriangleList); + } + } + + private static PooledPrimitiveMesh BuildStripCorePooled( + IReadOnlyList path, + Func colorResolver, + Func widthResolver, + Vector3 up, + int smoothingSegments, + StripCapStyle startCap, + StripCapStyle endCap, + int capSegments, + StripJoinStyle joinStyle, + bool textured, + StripCurveType smoothingCurve, + StripWidthAttenuation widthAttenuation, + PrimitiveMeshCache? cache) + { + if (path.Count < 2) + throw new ArgumentException("At least two points are required.", nameof(path)); + if (colorResolver == null) + throw new ArgumentNullException(nameof(colorResolver)); + if (widthResolver == null) + throw new ArgumentNullException(nameof(widthResolver)); + + cache ??= PrimitiveMeshCache.Shared; + + var workingPath = RemoveDegenerates(MaybeSmoothPath(path, smoothingSegments, smoothingCurve)); + var progress = ComputeProgress(workingPath, out _); + + int vertexCount = workingPath.Count * 2; + if (vertexCount > short.MaxValue) + throw new InvalidOperationException("Strip produced more vertices than supported by the index buffer."); + + bool needCaps = startCap != StripCapStyle.None || endCap != StripCapStyle.None; + + VertexPositionColorTexture[]? texturedVertices = null; + VertexPositionColor[]? colorVertices = null; + PooledPrimitiveMesh pooledLease = default; + bool hasLease = false; + List? texturedList = null; + List? colorList = null; + + var tangents = needCaps ? new Vector3[workingPath.Count] : null; + var rights = needCaps ? new Vector3[workingPath.Count] : null; + var centers = needCaps ? new Vector3[workingPath.Count] : null; + var sectionColors = needCaps ? new Color[workingPath.Count] : null; + var halfWidths = needCaps ? new float[workingPath.Count] : null; + + if (needCaps) + { + if (textured) + texturedList = new List(vertexCount); + else + colorList = new List(vertexCount); + } + else + { + if (textured) + { + pooledLease = cache.RentTextured(vertexCount, vertexCount, PrimitiveType.TriangleStrip); + texturedVertices = pooledLease.TexturedVertices; + } + else + { + pooledLease = cache.RentColored(vertexCount, vertexCount, PrimitiveType.TriangleStrip); + colorVertices = pooledLease.ColorVertices; + } + + hasLease = true; + } + + var upNormalized = up.LengthSquared() < 1e-6f ? Vector3.UnitZ : Vector3.Normalize(up); + + int segmentCount = workingPath.Count - 1; + var segmentDirs = new Vector3[segmentCount]; + var segmentRights = new Vector3[segmentCount]; + + for (int i = 0; i < segmentCount; i++) + { + Vector3 dir = workingPath[i + 1] - workingPath[i]; + if (dir.LengthSquared() < 1e-6f) + dir = i > 0 ? segmentDirs[i - 1] : Vector3.UnitY; + dir.Normalize(); + + Vector3 right = Vector3.Cross(upNormalized, dir); + if (right.LengthSquared() < 1e-6f) + right = FindPerpendicular(dir); + else + right.Normalize(); + + segmentDirs[i] = dir; + segmentRights[i] = right; + } + + Vector3 lastTangent = segmentDirs[0]; + + for (int i = 0; i < workingPath.Count; i++) + { + var position = workingPath[i]; + float t = progress[i]; + float baseWidth = Math.Max(0f, widthResolver(MathHelper.Clamp(t, 0f, 1f))); + + Vector3 prevDir = segmentDirs[Math.Max(i - 1, 0)]; + Vector3 nextDir = segmentDirs[Math.Min(i, segmentCount - 1)]; + + Vector3 tangent; + if (i == 0) + tangent = nextDir; + else if (i == segmentCount) + tangent = prevDir; + else + { + tangent = prevDir + nextDir; + if (tangent.LengthSquared() < 1e-6f) + tangent = nextDir; + else + tangent.Normalize(); + } + + float width = baseWidth; + + if (i > 0 && widthAttenuation == StripWidthAttenuation.ContinuitySquared) + { + float continuity = MathHelper.Clamp((Vector3.Dot(lastTangent, tangent) + 1f) * 0.5f, 0f, 1f); + width *= continuity * continuity; + } + + float halfWidth = width * 0.5f; + + Vector3 prevRight = segmentRights[Math.Max(i - 1, 0)]; + Vector3 nextRight = segmentRights[Math.Min(i, segmentCount - 1)]; + + Vector3 rightOffset; + Vector3 leftOffset; + + if (joinStyle == StripJoinStyle.Miter) + { + rightOffset = ComputeMiterOffset(prevRight, nextRight, i == 0, i == segmentCount, halfWidth); + leftOffset = ComputeMiterOffset(-prevRight, -nextRight, i == 0, i == segmentCount, halfWidth); + } + else + { + Vector3 joinNormal; + if (i == 0) + joinNormal = nextRight; + else if (i == segmentCount) + joinNormal = prevRight; + else + { + joinNormal = prevRight + nextRight; + if (joinNormal.LengthSquared() < 1e-6f) + joinNormal = nextRight; + } + + if (joinNormal.LengthSquared() < 1e-6f) + joinNormal = Vector3.UnitY; + + joinNormal.Normalize(); + rightOffset = joinNormal * halfWidth; + leftOffset = -joinNormal * halfWidth; + } + + Vector3 leftPos = position + leftOffset; + Vector3 rightPos = position + rightOffset; + Vector3 chord = rightPos - leftPos; + float chordLength = chord.Length(); + Vector3 lateralDir = chordLength > 1e-6f ? chord / chordLength : (nextRight.LengthSquared() > 1e-6f ? nextRight : Vector3.UnitX); + Vector3 crossCenter = (leftPos + rightPos) * 0.5f; + float effectiveHalfWidth = chordLength * 0.5f; + + float uCoord = progress[i]; + var color = colorResolver(t); + + if (textured) + { + if (needCaps) + { + texturedList!.Add(CreateEdgeVertex(leftPos, color, uCoord, isLeft: true)); + texturedList.Add(CreateEdgeVertex(rightPos, color, uCoord, isLeft: false)); + } + else + { + texturedVertices![i * 2] = CreateEdgeVertex(leftPos, color, uCoord, isLeft: true); + texturedVertices[i * 2 + 1] = CreateEdgeVertex(rightPos, color, uCoord, isLeft: false); + } + } + else + { + if (needCaps) + { + colorList!.Add(new VertexPositionColor(leftPos, color)); + colorList.Add(new VertexPositionColor(rightPos, color)); + } + else + { + colorVertices![i * 2] = new VertexPositionColor(leftPos, color); + colorVertices[i * 2 + 1] = new VertexPositionColor(rightPos, color); + } + } + + Vector3 rightForCap = lateralDir.LengthSquared() > 1e-6f ? lateralDir : Vector3.UnitX; + + if (needCaps) + { + tangents![i] = tangent; + rights![i] = Vector3.Normalize(rightForCap); + centers![i] = crossCenter; + sectionColors![i] = color; + halfWidths![i] = effectiveHalfWidth; + } + lastTangent = tangent; + } + if (!needCaps) + { + if (!hasLease) + throw new InvalidOperationException("Pooled mesh lease was not initialized."); + + PrimitiveSimd.FillSequentialIndices(pooledLease.Indices.AsSpan(0, vertexCount)); + return pooledLease; + } + + if (textured) + { + var vertexList = texturedList!; + var indexList = new List(); + AppendStripAsTriangles(indexList, vertexList.Count); + + int startLeftIndex = 0; + int startRightIndex = 1; + int endLeftIndex = texturedVertices!.Length - 2; + int endRightIndex = texturedVertices!.Length - 1; + int capSteps = Math.Max(2, capSegments); + float startU = progress[0]; + float endU = progress[^1]; + + if (startCap == StripCapStyle.Triangle) + AddTriangleCap(vertexList, indexList, centers![0], tangents![0], rights![0], halfWidths![0], sectionColors![0], startU, startLeftIndex, startRightIndex, true); + else if (startCap == StripCapStyle.HalfCircle) + AddHalfCircleCap(vertexList, indexList, centers![0], tangents![0], rights![0], halfWidths![0], sectionColors![0], startU, startLeftIndex, startRightIndex, true, capSteps); + + if (endCap == StripCapStyle.Triangle) + AddTriangleCap(vertexList, indexList, centers![^1], tangents![^1], rights![^1], halfWidths![^1], sectionColors![^1], endU, endLeftIndex, endRightIndex, false); + else if (endCap == StripCapStyle.HalfCircle) + AddHalfCircleCap(vertexList, indexList, centers![^1], tangents![^1], rights![^1], halfWidths![^1], sectionColors![^1], endU, endLeftIndex, endRightIndex, false, capSteps); + + var lease = cache.RentTextured(vertexList.Count, indexList.Count, PrimitiveType.TriangleList); + vertexList.CopyTo(0, lease.TexturedVertices, 0, vertexList.Count); + indexList.CopyTo(0, lease.Indices, 0, indexList.Count); + return lease; + } + else + { + var vertexList = colorList!; + var indexList = new List(); + AppendStripAsTriangles(indexList, vertexList.Count); + + int startLeftIndex = 0; + int startRightIndex = 1; + int endLeftIndex = colorVertices!.Length - 2; + int endRightIndex = colorVertices!.Length - 1; + int capSteps = Math.Max(2, capSegments); + + if (startCap == StripCapStyle.Triangle) + AddTriangleCap(vertexList, indexList, centers![0], tangents![0], rights![0], halfWidths![0], sectionColors![0], startLeftIndex, startRightIndex, true); + else if (startCap == StripCapStyle.HalfCircle) + AddHalfCircleCap(vertexList, indexList, centers![0], tangents![0], rights![0], halfWidths![0], sectionColors![0], startLeftIndex, startRightIndex, true, capSteps); + + if (endCap == StripCapStyle.Triangle) + AddTriangleCap(vertexList, indexList, centers![^1], tangents![^1], rights![^1], halfWidths![^1], sectionColors![^1], endLeftIndex, endRightIndex, false); + else if (endCap == StripCapStyle.HalfCircle) + AddHalfCircleCap(vertexList, indexList, centers![^1], tangents![^1], rights![^1], halfWidths![^1], sectionColors![^1], endLeftIndex, endRightIndex, false, capSteps); + + var lease = cache.RentColored(vertexList.Count, indexList.Count, PrimitiveType.TriangleList); + vertexList.CopyTo(0, lease.ColorVertices, 0, vertexList.Count); + indexList.CopyTo(0, lease.Indices, 0, indexList.Count); + return lease; + } + } + + private static IReadOnlyList MaybeSmoothPath(IReadOnlyList path, int subdivisions, StripCurveType curveType) + { + if (subdivisions <= 0 || path.Count < 2) + return path; + + var result = new List((path.Count - 1) * (subdivisions + 1) + 1); + + for (int i = 0; i < path.Count - 1; i++) + { + var p0 = path[Math.Max(i - 1, 0)]; + var p1 = path[i]; + var p2 = path[i + 1]; + var p3 = path[Math.Min(i + 2, path.Count - 1)]; + + if (i == 0) + result.Add(p1); + + for (int s = 1; s <= subdivisions; s++) + { + float t = s / (float)(subdivisions + 1); + var point = EvaluateCurve(curveType, p0, p1, p2, p3, t, path.Count); + result.Add(point); + } + + result.Add(p2); + } + + return result; + } + + private static Vector3 EvaluateCurve(StripCurveType curveType, Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3, float t, int count) + { + switch (curveType) + { + case StripCurveType.Linear: + return Vector3.Lerp(p1, p2, t); + + case StripCurveType.CatmullRom when count >= 4: + return Vector3.CatmullRom(p0, p1, p2, p3, t); + + case StripCurveType.CubicBezier when count >= 4: + { + Vector3 c1 = p1 + (p2 - p0) / 6f; + Vector3 c2 = p2 - (p3 - p1) / 6f; + float inv = 1f - t; + return inv * inv * inv * p1 + + 3f * inv * inv * t * c1 + + 3f * inv * t * t * c2 + + t * t * t * p2; + } + + case StripCurveType.Hermite when count >= 4: + { + Vector3 tan1 = (p2 - p0) * 0.5f; + Vector3 tan2 = (p3 - p1) * 0.5f; + return Vector3.Hermite(p1, tan1, p2, tan2, t); + } + + default: + return Vector3.Lerp(p1, p2, t); + } + } + + private static Color SampleColor(IReadOnlyList colors, float progress) + { + if (colors.Count == 1) + return colors[0]; + + float scaled = MathHelper.Clamp(progress, 0f, 1f) * (colors.Count - 1); + int index = Math.Min(colors.Count - 2, (int)MathF.Floor(scaled)); + float localT = scaled - index; + return Color.Lerp(colors[index], colors[index + 1], localT); + } + + private static float[] ComputeProgress(IReadOnlyList path, out float totalLength) + { + var progress = new float[path.Count]; + float cumulative = 0f; + + for (int i = 1; i < path.Count; i++) + { + cumulative += Vector3.Distance(path[i - 1], path[i]); + progress[i] = cumulative; + } + + totalLength = cumulative; + + if (cumulative > 1e-6f) + { + float inv = 1f / cumulative; + for (int i = 1; i < progress.Length; i++) + progress[i] *= inv; + } + + return progress; + } + + private static float EvaluateWidth(Func widthFunc, Func? easing, float progress) + { + float eased = easing?.Invoke(MathHelper.Clamp(progress, 0f, 1f)) ?? MathHelper.Clamp(progress, 0f, 1f); + return Math.Max(0f, widthFunc(MathHelper.Clamp(eased, 0f, 1f))); + } + + private static Vector3 FindPerpendicular(Vector3 vector) + { + Vector3 axis = Math.Abs(vector.Y) < Math.Abs(vector.X) + ? Vector3.UnitY + : Vector3.UnitX; + + var perpendicular = Vector3.Cross(vector, axis); + if (perpendicular.LengthSquared() < 1e-6f) + { + perpendicular = Vector3.Cross(vector, Vector3.UnitZ); + } + + perpendicular.Normalize(); + return perpendicular; + } + + // maybe find a better name for this? + private static IReadOnlyList RemoveDegenerates(IReadOnlyList path) + { + if (path.Count < 2) + return path; + + var result = new List(path.Count); + var last = path[0]; + result.Add(last); + + for (int i = 1; i < path.Count; i++) + { + if (Vector3.DistanceSquared(last, path[i]) <= 1e-6f) + continue; + + last = path[i]; + result.Add(last); + } + + if (result.Count == 1) + result.Add(path[path.Count - 1]); + + return result; + } + + private static void AppendStripAsTriangles(List indices, int vertexCount) + { + for (int i = 0; i < vertexCount - 2; i++) + { + if ((i & 1) == 0) + { + indices.Add((short)i); + indices.Add((short)(i + 1)); + indices.Add((short)(i + 2)); + } + else + { + indices.Add((short)(i + 1)); + indices.Add((short)i); + indices.Add((short)(i + 2)); + } + } + } + + private static void AddTriangleCap( + List vertices, + List indices, + Vector3 center, + Vector3 tangent, + Vector3 rightDir, + float halfWidth, + Color color, + float uCoord, + int leftIndex, + int rightIndex, + bool isStart) + { + if (halfWidth <= 1e-6f) + return; + + var outward = isStart ? -tangent : tangent; + short apexIndex = AddVertex(vertices, CreateCapVertex(center + outward * halfWidth, color, uCoord, center, rightDir, halfWidth)); + + if (isStart) + { + indices.Add(apexIndex); + indices.Add((short)rightIndex); + indices.Add((short)leftIndex); + } + else + { + indices.Add(apexIndex); + indices.Add((short)leftIndex); + indices.Add((short)rightIndex); + } + } + + private static void AddTriangleCap( + List vertices, + List indices, + Vector3 center, + Vector3 tangent, + Vector3 rightDir, // todo: remove + float halfWidth, + Color color, + int leftIndex, + int rightIndex, + bool isStart) + { + if (halfWidth <= 1e-6f) + return; + + var outward = isStart ? -tangent : tangent; + short apexIndex = AddVertex(vertices, new VertexPositionColor(center + outward * halfWidth, color)); + + if (isStart) + { + indices.Add(apexIndex); + indices.Add((short)rightIndex); + indices.Add((short)leftIndex); + } + else + { + indices.Add(apexIndex); + indices.Add((short)leftIndex); + indices.Add((short)rightIndex); + } + } + + private static void AddHalfCircleCap( + List vertices, + List indices, + Vector3 center, + Vector3 tangent, + Vector3 rightDir, + float halfWidth, + Color color, + float uCoord, + int leftIndex, + int rightIndex, + bool isStart, + int segments) + { + if (halfWidth <= 1e-6f) + return; + + var outward = isStart ? -tangent : tangent; + short centerIndex = AddVertex(vertices, CreateCapVertex(center, color, uCoord, center, rightDir, halfWidth)); + + var arcVertices = new List + { + isStart ? (short)rightIndex : (short)leftIndex + }; + + float step = MathF.PI / segments; + for (int i = 1; i < segments; i++) + { + float angle = isStart ? step * i : MathF.PI - step * i; + Vector3 offset = rightDir * MathF.Cos(angle) + outward * MathF.Sin(angle); + short arcIndex = AddVertex(vertices, CreateCapVertex(center + offset * halfWidth, color, uCoord, center, rightDir, halfWidth)); + arcVertices.Add(arcIndex); + } + + arcVertices.Add(isStart ? (short)leftIndex : (short)rightIndex); + + for (int i = 0; i < arcVertices.Count - 1; i++) + { + if (isStart) + { + indices.Add(centerIndex); + indices.Add(arcVertices[i]); + indices.Add(arcVertices[i + 1]); + } + else + { + indices.Add(centerIndex); + indices.Add(arcVertices[i + 1]); + indices.Add(arcVertices[i]); + } + } + } + + private static void AddHalfCircleCap( + List vertices, + List indices, + Vector3 center, + Vector3 tangent, + Vector3 rightDir, + float halfWidth, + Color color, + int leftIndex, + int rightIndex, + bool isStart, + int segments) + { + if (halfWidth <= 1e-6f) + return; + + var outward = isStart ? -tangent : tangent; + short centerIndex = AddVertex(vertices, new VertexPositionColor(center, color)); + + var arcVertices = new List + { + isStart ? (short)rightIndex : (short)leftIndex + }; + + float step = MathF.PI / segments; + for (int i = 1; i < segments; i++) + { + float angle = isStart ? step * i : MathF.PI - step * i; + Vector3 offset = rightDir * MathF.Cos(angle) + outward * MathF.Sin(angle); + short arcIndex = AddVertex(vertices, new VertexPositionColor(center + offset * halfWidth, color)); + arcVertices.Add(arcIndex); + } + + arcVertices.Add(isStart ? (short)leftIndex : (short)rightIndex); + + for (int i = 0; i < arcVertices.Count - 1; i++) + { + if (isStart) + { + indices.Add(centerIndex); + indices.Add(arcVertices[i]); + indices.Add(arcVertices[i + 1]); + } + else + { + indices.Add(centerIndex); + indices.Add(arcVertices[i + 1]); + indices.Add(arcVertices[i]); + } + } + } + + private static short AddVertex(List vertices, VertexPositionColorTexture vertex) + { + if (vertices.Count >= short.MaxValue) + throw new InvalidOperationException("Primitive mesh exceeded 16-bit index capacity."); + vertices.Add(vertex); + return (short)(vertices.Count - 1); + } + + private static short AddVertex(List vertices, VertexPositionColor vertex) + { + if (vertices.Count >= short.MaxValue) + throw new InvalidOperationException("Primitive mesh exceeded 16-bit index capacity."); + vertices.Add(vertex); + return (short)(vertices.Count - 1); + } + + private static VertexPositionColorTexture CreateEdgeVertex(Vector3 position, Color color, float u, bool isLeft) + { + return new VertexPositionColorTexture( + position, + color, + new Vector2(MathHelper.Clamp(u, 0f, 1f), isLeft ? 0f : 1f)); + } + + private static VertexPositionColorTexture CreateCapVertex(Vector3 position, Color color, float u, Vector3 center, Vector3 rightDir, float halfWidth) + { + Vector3 right = rightDir.LengthSquared() > 1e-6f ? Vector3.Normalize(rightDir) : Vector3.UnitX; + float width = Math.Max(halfWidth, 1e-6f); + float lateral = MathHelper.Clamp(Vector3.Dot(position - center, right) / width, -1f, 1f); + float v = 0.5f + 0.5f * lateral; + return new VertexPositionColorTexture( + position, + color, + new Vector2(MathHelper.Clamp(u, 0f, 1f), MathHelper.Clamp(v, 0f, 1f))); + } + + private static Vector3 ComputeMiterOffset(Vector3 prevNormal, Vector3 nextNormal, bool isStart, bool isEnd, float halfWidth) + { + if (halfWidth <= 1e-6f) + return Vector3.Zero; + + if (isStart) + return nextNormal * halfWidth; + if (isEnd) + return prevNormal * halfWidth; + + float prevLenSq = prevNormal.LengthSquared(); + float nextLenSq = nextNormal.LengthSquared(); + if (prevLenSq < 1e-6f || nextLenSq < 1e-6f) + return (nextLenSq >= prevLenSq ? nextNormal : prevNormal) * halfWidth; + + Vector3 sum = prevNormal + nextNormal; + float sumLenSq = sum.LengthSquared(); + if (sumLenSq < 1e-4f) + return nextNormal * halfWidth; + + Vector3 miter = sum / MathF.Sqrt(sumLenSq); + float denom = Vector3.Dot(miter, nextNormal); + float absDenom = MathF.Abs(denom); + if (absDenom <= 1e-3f) + return nextNormal * halfWidth; + + float scale = halfWidth / denom; + const float MiterLimit = 4f; + float maxScale = halfWidth * MiterLimit; + if (MathF.Abs(scale) > maxScale) + scale = MathF.Sign(scale) * maxScale; + + return miter * scale; + } +} diff --git a/Items/Accessories/BatholithBangle.cs b/Items/Accessories/BatholithBangle.cs index ef0d8c630f..c244cd51d4 100644 --- a/Items/Accessories/BatholithBangle.cs +++ b/Items/Accessories/BatholithBangle.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Items.Accessories { public new string LocalizationCategory => "Items.Accessories"; public static int cooldown = 600; - public static int damage = 225; + public static int damage = 100; public override void SetDefaults() { Item.width = 36; diff --git a/Items/Accessories/BlackGlassBand.cs b/Items/Accessories/BlackGlassBand.cs index ff767add74..affacf97aa 100644 --- a/Items/Accessories/BlackGlassBand.cs +++ b/Items/Accessories/BlackGlassBand.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Items.Accessories { public new string LocalizationCategory => "Items.Accessories"; public static int cooldown = 300; - public static int damage = 32; + public static int damage = 20; public override void SetDefaults() { Item.width = 30; diff --git a/Items/Accessories/ChaosStone.cs b/Items/Accessories/ChaosStone.cs index e339d2c5f8..8b743a1c10 100644 --- a/Items/Accessories/ChaosStone.cs +++ b/Items/Accessories/ChaosStone.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Items.Accessories public class ChaosStone : ModItem, ILocalizedModType { public static float LostRegenPer100Mana => 8; - public static float DamageMultPer100Mana => 0.03f; + public static float DamageMultPer100Mana => 0.04f; public new string LocalizationCategory => "Items.Accessories"; public override void ModifyTooltips(List tooltips) { diff --git a/Items/Accessories/ProfanedSoulCrystal.cs b/Items/Accessories/ProfanedSoulCrystal.cs index f551bca324..c9c1807c50 100644 --- a/Items/Accessories/ProfanedSoulCrystal.cs +++ b/Items/Accessories/ProfanedSoulCrystal.cs @@ -427,17 +427,9 @@ namespace CalamityMod.Items.Accessories player.Calamity().profanedSoulWeaponUsage = 0; } int manaCost = (int)(100 * player.manaCost); - if (player.statMana < manaCost && player.Calamity().profanedSoulWeaponUsage == 0) - { - if (player.manaFlower) - { - player.QuickMana(); - } - } - if (player.statMana >= manaCost && player.Calamity().profanedSoulWeaponUsage == 0 && !player.silence) + if (player.Calamity().profanedSoulWeaponUsage == 0 && !player.silence && player.CheckMana(manaCost, true)) { player.manaRegenDelay = (int)player.maxRegenDelay; - player.statMana -= manaCost; correctedVelocity *= 25f; SoundEngine.PlaySound(SoundID.Item20, player.Center); int magefireBaseDamage = 900; diff --git a/Items/Accessories/ProtolithBangle.cs b/Items/Accessories/ProtolithBangle.cs index 70274095b3..b80f6f8225 100644 --- a/Items/Accessories/ProtolithBangle.cs +++ b/Items/Accessories/ProtolithBangle.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Items.Accessories { public new string LocalizationCategory => "Items.Accessories"; public static int cooldown = 420; - public static int damage = 68; + public static int damage = 60; public override void SetDefaults() { Item.width = 34; diff --git a/Items/Accessories/ScionsCurio.cs b/Items/Accessories/ScionsCurio.cs index 0a1d545869..66e34b7350 100644 --- a/Items/Accessories/ScionsCurio.cs +++ b/Items/Accessories/ScionsCurio.cs @@ -1,4 +1,6 @@ -using CalamityMod.CalPlayer; +using System.Collections.Generic; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.CalPlayer; using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Terraria; @@ -34,5 +36,11 @@ namespace CalamityMod.Items.Accessories Projectile.NewProjectileDirect(player.GetSource_FromThis(), player.Center, Vector2.Zero, ProjectileType(), 0, 0f, player.whoAmI); } } + public override void ModifyTooltips(List list) + { + Player player = Main.LocalPlayer; + if (Main.LocalPlayer != null) + list.FindAndReplace("[DAMAGE]", ((int)(player.Calamity().scionsCurioDebuffDamage / 2)).ToString() + " DPS"); + } } } diff --git a/Items/Accessories/TheAmalgam.cs b/Items/Accessories/TheAmalgam.cs index fdea11a01a..d54b5c5e34 100644 --- a/Items/Accessories/TheAmalgam.cs +++ b/Items/Accessories/TheAmalgam.cs @@ -39,11 +39,11 @@ namespace CalamityMod.Items.Accessories modPlayer.rBrain = true; // Handles shaderain cloud spawning on hit modPlayer.amalgam = true; player.brainOfConfusionItem = Item; - modPlayer.HeatDebuffMultiplier += 3f; - modPlayer.ColdDebuffMultiplier += 3f; - modPlayer.SicknessDebuffMultiplier += 3f; - modPlayer.WaterDebuffMultiplier += 3f; - modPlayer.ElectricDebuffMultiplier += 3f; + modPlayer.HeatDebuffMultiplier += 2f; + modPlayer.ColdDebuffMultiplier += 2f; + modPlayer.SicknessDebuffMultiplier += 2f; + modPlayer.WaterDebuffMultiplier += 2f; + modPlayer.ElectricDebuffMultiplier += 2f; } public override void AddRecipes() diff --git a/Items/Accessories/Wings/MOAB.cs b/Items/Accessories/Wings/MOAB.cs index 4603a286db..3dc07519cb 100644 --- a/Items/Accessories/Wings/MOAB.cs +++ b/Items/Accessories/Wings/MOAB.cs @@ -152,6 +152,7 @@ namespace CalamityMod.Items.Accessories.Wings player.jumpBoost = true; player.autoJump = true; player.jumpSpeedBoost += 1.6f; + player.noFallDmg = true; // Mirrors the +5% luck from Lucky Horseshoe (vanilla behavior). player.Calamity().calamityBonusLuck += 0.05f; diff --git a/Items/Armor/SnowRuffian/SnowRuffianChestplate.cs b/Items/Armor/SnowRuffian/SnowRuffianChestplate.cs index eb8c2b383c..37fff98cc2 100644 --- a/Items/Armor/SnowRuffian/SnowRuffianChestplate.cs +++ b/Items/Armor/SnowRuffian/SnowRuffianChestplate.cs @@ -39,7 +39,7 @@ namespace CalamityMod.Items.Armor.SnowRuffian Item.height = 18; Item.value = CalamityGlobalItem.RarityBlueBuyPrice; Item.rare = ItemRarityID.Blue; - Item.defense = 5; //12 + Item.defense = 4; //9 } public override void UpdateEquip(Player player) => player.GetCritChance() += RangedCritBoost; diff --git a/Items/Armor/SnowRuffian/SnowRuffianGreaves.cs b/Items/Armor/SnowRuffian/SnowRuffianGreaves.cs index 8c1bbf66ac..a2309f288a 100644 --- a/Items/Armor/SnowRuffian/SnowRuffianGreaves.cs +++ b/Items/Armor/SnowRuffian/SnowRuffianGreaves.cs @@ -10,8 +10,8 @@ namespace CalamityMod.Items.Armor.SnowRuffian { public new string LocalizationCategory => "Items.Armor.PreHardmode"; - public static int RangedCritBoost = 4; - public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(RangedCritBoost); + public static float RangedDamageBoost = 0.05f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(RangedDamageBoost.ToPercent()); public override void SetDefaults() { @@ -19,10 +19,10 @@ namespace CalamityMod.Items.Armor.SnowRuffian Item.height = 18; Item.value = CalamityGlobalItem.RarityBlueBuyPrice; Item.rare = ItemRarityID.Blue; - Item.defense = 4; //12 + Item.defense = 3; //9 } - public override void UpdateEquip(Player player) => player.GetCritChance() += RangedCritBoost; + public override void UpdateEquip(Player player) => player.GetCritChance() += RangedDamageBoost; public override void AddRecipes() { diff --git a/Items/Armor/SnowRuffian/SnowRuffianMask.cs b/Items/Armor/SnowRuffian/SnowRuffianMask.cs index bff6f97d86..78cb84a91e 100644 --- a/Items/Armor/SnowRuffian/SnowRuffianMask.cs +++ b/Items/Armor/SnowRuffian/SnowRuffianMask.cs @@ -10,12 +10,12 @@ namespace CalamityMod.Items.Armor.SnowRuffian { public new string LocalizationCategory => "Items.Armor.PreHardmode"; - public static int RangedCritBoost = 4; - public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(RangedCritBoost); + public static float RangedDamageBoost = 0.05f; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(RangedDamageBoost.ToPercent()); // Set Bonus public static float GlideFallSpeedMult = 0.9f; - public static int SetBonusFrostburnDuration = CalamityUtils.SecondsToFrames(3); + public static int SetBonusFrostburnDuration = CalamityUtils.SecondsToFrames(2); public override void Load() { @@ -31,7 +31,7 @@ namespace CalamityMod.Items.Armor.SnowRuffian Item.height = 18; Item.value = CalamityGlobalItem.RarityBlueBuyPrice; Item.rare = ItemRarityID.Blue; - Item.defense = 3; // 12 + Item.defense = 2; // 9 } public override bool IsArmorSet(Item head, Item body, Item legs) => body.type == ModContent.ItemType() && legs.type == ModContent.ItemType(); @@ -43,7 +43,7 @@ namespace CalamityMod.Items.Armor.SnowRuffian player.setBonus = this.GetLocalization("SetBonus").Format(SetBonusFrostburnDuration.FramesToSeconds()); } - public override void UpdateEquip(Player player) => player.GetCritChance() += RangedCritBoost; + public override void UpdateEquip(Player player) => player.GetCritChance() += RangedDamageBoost; public override void AddRecipes() { diff --git a/Items/BaseItems/TransformationAccessory.cs b/Items/BaseItems/TransformationAccessory.cs index dc76f2aaff..028dda9434 100644 --- a/Items/BaseItems/TransformationAccessory.cs +++ b/Items/BaseItems/TransformationAccessory.cs @@ -177,22 +177,8 @@ namespace CalamityMod.Items.BaseItems { currentTransformation.ModifyDrawInfo(ref drawInfo); - if (currentTransformation.EquipSlots.Any(s => s.Type == EquipType.Head)) - { - drawInfo.headGlowMask = -1; - drawInfo.helmetOffset = Vector2.Zero; - } - - if (currentTransformation.EquipSlots.Any(s => s.Type == EquipType.Body)) - { - drawInfo.bodyGlowMask = -1; - } - - if (currentTransformation.EquipSlots.Any(s => s.Type == EquipType.Legs)) - { - drawInfo.legsGlowMask = -1; - drawInfo.legsOffset = Vector2.Zero; - } + // CIT 24FEB2026: Previously, this hook also reset glowmasks and offsets on the head, body, and legs. + // This has been removed, as it resulted in index OOB crashes due to the original armor being drawn for one frame. } } diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index 4af8eb478d..9ca1d5efee 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -1049,31 +1049,9 @@ namespace CalamityMod.Items player.GetAttackSpeed() += 0.05f; break; - case ItemID.SquireGreaves: - player.GetDamage() -= 0.05f; - break; - case ItemID.HuntressWig: - player.GetCritChance() += 5; - break; - case ItemID.HuntressJerkin: - player.GetDamage() -= 0.05f; - player.GetDamage() -= 0.05f; - break; - case ItemID.ApprenticeHat: - player.GetDamage() -= 0.1f; - break; - - case ItemID.ApprenticeRobe: - player.GetDamage() -= 0.05f; - player.GetDamage() += 0.05f; - break; - - case ItemID.ApprenticeTrousers: - player.GetCritChance() -= 5; - break; case ItemID.ShroomiteBreastplate: player.GetDamage() -= 0.05f; @@ -1094,28 +1072,6 @@ namespace CalamityMod.Items player.GetDamage() -= 0.05f; break; - case ItemID.HuntressAltShirt: - player.GetDamage() -= 0.05f; - player.GetDamage() -= 0.05f; - break; - - case ItemID.HuntressAltPants: - player.GetDamage() -= 0.05f; - break; - - case ItemID.ApprenticeAltHead: - player.GetDamage() -= 0.05f; - player.GetDamage() -= 0.05f; - break; - - case ItemID.ApprenticeAltShirt: - player.GetDamage() -= 0.05f; - break; - - case ItemID.ApprenticeAltPants: - player.GetCritChance() -= 10; - break; - case ItemID.SolarFlareHelmet: player.GetCritChance() -= 6; break; diff --git a/Items/CalamityGlobalItemTooltip.cs b/Items/CalamityGlobalItemTooltip.cs index 30346a9b56..ef4a5f2bdd 100644 --- a/Items/CalamityGlobalItemTooltip.cs +++ b/Items/CalamityGlobalItemTooltip.cs @@ -941,20 +941,6 @@ namespace CalamityMod.Items #region DD2 Armor // Nerf sets that are too strong - if (item.type == ItemID.SquireGreaves) - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("SquireGreaves")); - - if (item.type == ItemID.HuntressWig) - EditTooltipByNum(0, (line) => line.Text = line.Text.Replace("10%", "15%")); - if (item.type == ItemID.HuntressJerkin) - EditTooltipByNum(0, (line) => line.Text = line.Text.Replace("20%", "15%")); - - if (item.type == ItemID.ApprenticeHat) - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("ApprenticeHat")); - if (item.type == ItemID.ApprenticeRobe) - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("ApprenticeRobe")); - if (item.type == ItemID.ApprenticeTrousers) - EditTooltipByNum(0, (line) => line.Text = EditedTooltip("ApprenticeTrousers")); if (item.type == ItemID.SquireAltHead) EditTooltipByNum(0, (line) => line.Text = line.Text.Replace("10%", "15%")); @@ -963,18 +949,6 @@ namespace CalamityMod.Items if (item.type == ItemID.SquireAltPants) EditTooltipByNum(0, (line) => line.Text = line.Text.Replace("20%", "15%")); - if (item.type == ItemID.HuntressAltShirt) - EditTooltipByNum(0, (line) => line.Text = line.Text.Replace("25%", "20%")); - if (item.type == ItemID.HuntressAltPants) - EditTooltipByNum(0, (line) => line.Text = line.Text.Replace("25%", "20%")); - - if (item.type == ItemID.ApprenticeAltHead) - EditTooltipByNum(0, (line) => line.Text = line.Text.Replace("15%", "10%")); - if (item.type == ItemID.ApprenticeAltShirt) - EditTooltipByNum(0, (line) => line.Text = line.Text.Replace("25%", "20%")); - if (item.type == ItemID.ApprenticeAltPants) - EditTooltipByNum(0, (line) => line.Text = line.Text.Replace("25%", "15%")); - // Tweaks into Rogue // Monk armor if (item.type == ItemID.MonkBrows) @@ -1199,12 +1173,11 @@ namespace CalamityMod.Items AddWingStats(item.wingSlot, 0.5f, 0.1f, 0.5f, 1.5f, 0.1f); // All developer wings have identical stats and no special effects - if (item.type == ItemID.Yoraiz0rWings || item.type == ItemID.JimsWings || item.type == ItemID.SkiphsWings || - item.type == ItemID.LokisWings || item.type == ItemID.ArkhalisWings || item.type == ItemID.LeinforsWings || - item.type == ItemID.BejeweledValkyrieWing || item.type == ItemID.RedsWings || item.type == ItemID.DTownsWings || - item.type == ItemID.WillsWings || item.type == ItemID.CrownosWings || item.type == ItemID.CenxsWings || - item.type == ItemID.FoodBarbarianWings || item.type == ItemID.GroxTheGreatWings || item.type == ItemID.GhostarsWings || - item.type == ItemID.SafemanWings) + if (item.type == ItemID.Yoraiz0rWings || item.type == ItemID.JimsWings || item.type == ItemID.LokisWings || + item.type == ItemID.ArkhalisWings || item.type == ItemID.LeinforsWings || item.type == ItemID.RedsWings || + item.type == ItemID.DTownsWings || item.type == ItemID.WillsWings || item.type == ItemID.CrownosWings || + item.type == ItemID.CenxsWings || item.type == ItemID.FoodBarbarianWings || item.type == ItemID.GroxTheGreatWings || + item.type == ItemID.GhostarsWings || item.type == ItemID.SafemanWings) { AddWingStats(item.wingSlot, 0.5f, 0.1f, 0.5f, 1.5f, 0.1f); } diff --git a/Items/Critters/BabyCannonballJellyfishItem.cs b/Items/Critters/BabyCannonballJellyfishItem.cs index d36cc2a4b9..644de42130 100644 --- a/Items/Critters/BabyCannonballJellyfishItem.cs +++ b/Items/Critters/BabyCannonballJellyfishItem.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Critters Item.DefaultToCapturedCritter(ModContent.NPCType()); Item.value = Item.sellPrice(silver: 10); Item.rare = ItemRarityID.Green; - Item.damage = 400; + Item.damage = 300; } } } diff --git a/Items/Fishing/AstralCatches/UrsaSergeant.cs b/Items/Fishing/AstralCatches/UrsaSergeant.cs index 82616a1b1e..f563452b86 100644 --- a/Items/Fishing/AstralCatches/UrsaSergeant.cs +++ b/Items/Fishing/AstralCatches/UrsaSergeant.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Items.Fishing.AstralCatches public static int CooldownReducedPerKill = 180; public static int MaxCooldown = 300; - public static int BaseSwipeDamage = 200; + public static int BaseSwipeDamage = 325; // About 65 dps public override void SetDefaults() { diff --git a/Items/LoreItems/LorePrelude.png b/Items/LoreItems/LorePrelude.png index 2066dbfb09..f21e4c3367 100644 Binary files a/Items/LoreItems/LorePrelude.png and b/Items/LoreItems/LorePrelude.png differ diff --git a/Items/LoreItems/LoreRequiem.png b/Items/LoreItems/LoreRequiem.png index 791be4707c..1b608ed643 100644 Binary files a/Items/LoreItems/LoreRequiem.png and b/Items/LoreItems/LoreRequiem.png differ diff --git a/Items/Materials/SeaRemains.cs b/Items/Materials/SeaRemains.cs index 44de9475c0..ff70b1ad9f 100644 --- a/Items/Materials/SeaRemains.cs +++ b/Items/Materials/SeaRemains.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Materials Item.width = 30; Item.height = 24; Item.maxStack = Item.CommonMaxStack; - Item.value = Item.sellPrice(silver: 6); + Item.value = Item.sellPrice(silver: 36); Item.rare = ItemRarityID.Green; } public override void AddRecipes() diff --git a/Items/PermanentBoosters/MiracleFruit.cs b/Items/PermanentBoosters/MiracleFruit.cs index bd12178cf9..055e92bc5c 100644 --- a/Items/PermanentBoosters/MiracleFruit.cs +++ b/Items/PermanentBoosters/MiracleFruit.cs @@ -32,7 +32,7 @@ namespace CalamityMod.Items.PermanentBoosters Item.useAnimation = Item.useTime = 30; Item.UseSound = UseSound; Item.useStyle = ItemUseStyleID.HoldUp; - Item.value = Item.sellPrice(gold: 30); + Item.value = Item.sellPrice(gold: 24); Item.rare = ItemRarityID.Yellow; } diff --git a/Items/PermanentBoosters/SacredStrawberry.cs b/Items/PermanentBoosters/SacredStrawberry.cs index 96e4dd00f7..50e53a941c 100644 --- a/Items/PermanentBoosters/SacredStrawberry.cs +++ b/Items/PermanentBoosters/SacredStrawberry.cs @@ -35,7 +35,7 @@ namespace CalamityMod.Items.PermanentBoosters Item.useAnimation = Item.useTime = 30; Item.UseSound = UseSound; Item.useStyle = ItemUseStyleID.HoldUp; - Item.value = Item.sellPrice(gold: 48); + Item.value = Item.sellPrice(gold: 36); Item.rare = ModContent.RarityType(); } diff --git a/Items/PermanentBoosters/SanguineTangerine.cs b/Items/PermanentBoosters/SanguineTangerine.cs index 473b2b825b..2f8a6cb783 100644 --- a/Items/PermanentBoosters/SanguineTangerine.cs +++ b/Items/PermanentBoosters/SanguineTangerine.cs @@ -33,7 +33,7 @@ namespace CalamityMod.Items.PermanentBoosters Item.useAnimation = Item.useTime = 30; Item.UseSound = UseSound; Item.useStyle = ItemUseStyleID.HoldUp; - Item.value = Item.sellPrice(gold: 24); + Item.value = Item.sellPrice(gold: 16); Item.rare = ItemRarityID.LightPurple; } diff --git a/Items/PermanentBoosters/TaintedCloudberry.cs b/Items/PermanentBoosters/TaintedCloudberry.cs index 93bcaf634f..8e4092d358 100644 --- a/Items/PermanentBoosters/TaintedCloudberry.cs +++ b/Items/PermanentBoosters/TaintedCloudberry.cs @@ -34,7 +34,7 @@ namespace CalamityMod.Items.PermanentBoosters Item.useAnimation = Item.useTime = 30; Item.UseSound = UseSound; Item.useStyle = ItemUseStyleID.HoldUp; - Item.value = Item.sellPrice(gold: 36); + Item.value = Item.sellPrice(gold: 28); Item.rare = ModContent.RarityType(); } diff --git a/Items/Placeables/Furniture/Paintings/ThankYouPainting.cs b/Items/Placeables/Furniture/Paintings/ThankYouPainting.cs index f98612ef5b..f50c787909 100644 --- a/Items/Placeables/Furniture/Paintings/ThankYouPainting.cs +++ b/Items/Placeables/Furniture/Paintings/ThankYouPainting.cs @@ -78,6 +78,7 @@ namespace CalamityMod.Items.Placeables.Furniture.Paintings "PokerFace", "Raesh", "Sagittariod", + "sixtydegrees", "StipulateVenus", "Sunny", "_tofu", diff --git a/Items/SummonItems/BloodwormItem.cs b/Items/SummonItems/BloodwormItem.cs index be23362d9c..b511859045 100644 --- a/Items/SummonItems/BloodwormItem.cs +++ b/Items/SummonItems/BloodwormItem.cs @@ -1,7 +1,10 @@ -using CalamityMod.NPCs.AcidRain; +using System.Collections.Generic; +using System.Linq; +using CalamityMod.NPCs.AcidRain; using CalamityMod.Rarities; using Terraria; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Items.SummonItems @@ -9,6 +12,8 @@ namespace CalamityMod.Items.SummonItems public class BloodwormItem : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.SummonItems"; + + public const int SpoofBaitNumber = 4444; public override void SetStaticDefaults() { Item.ResearchUnlockCount = 3; @@ -20,7 +25,10 @@ namespace CalamityMod.Items.SummonItems Item.width = 28; Item.height = 28; Item.maxStack = Item.CommonMaxStack; - Item.bait = 4444; + // Why spoof this in the tooltip? + // To fix bugs related to how bait power affects hooking fish. + // Vanilla gets around this for Truffle Worm with a hundred hardcoded checks but we don't have the full luxury to do that. + Item.bait = 50; Item.useStyle = ItemUseStyleID.Swing; Item.autoReuse = true; Item.useTurn = true; @@ -38,5 +46,11 @@ namespace CalamityMod.Items.SummonItems { itemGroup = ContentSamples.CreativeHelper.ItemGroup.BossItem; } + + public override void ModifyTooltips(List tooltips) + { + TooltipLine bait = tooltips.FirstOrDefault(x => x.Mod == "Terraria" && x.Name == "BaitPower"); + bait?.Text = Language.GetTextValue("GameUI.BaitPower", SpoofBaitNumber); + } } } diff --git a/Items/SummonItems/Terminus.cs b/Items/SummonItems/Terminus.cs index 71f0b167e4..c1432c9c8b 100644 --- a/Items/SummonItems/Terminus.cs +++ b/Items/SummonItems/Terminus.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Items.SummonItems public new string LocalizationCategory => "Items.SummonItems"; public override void SetDefaults() { - Item.width = Main.zenithWorld ? 54 : 28; - Item.height = Main.zenithWorld ? 78 : 28; + Item.width = Main.zenithWorld ? 54 : 70; + Item.height = Main.zenithWorld ? 78 : 80; Item.rare = ItemRarityID.Blue; Item.useAnimation = 45; Item.useTime = 45; @@ -31,17 +31,67 @@ namespace CalamityMod.Items.SummonItems Item.SetNameOverride(this.GetLocalizedValue("GFBName")); } - public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frameI, Color drawColor, Color itemColor, Vector2 origin, float scale) + public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) { + // The wiki classifies Boss Rush as an event + itemGroup = ContentSamples.CreativeHelper.ItemGroup.EventItem; + } + + #region Sprite Drawing + public static void DrawTerminusGlow(SpriteBatch spriteBatch, Vector2 baseDrawPosition, Rectangle frame, float rotation, float baseScale) + { + Texture2D glowTexture = ModContent.Request("CalamityMod/Items/SummonItems/TerminusGlow").Value; + Vector2 origin = frame.Size() * 0.5f; + + float pulseRate = Main.GlobalTimeWrappedHourly % 5f; + float slowingRate = Main.GlobalTimeWrappedHourly * 0.4f; + float orbitRadius = baseScale != 1f ? 4f : 7f; + float glowCount = 3f; + + pulseRate /= 2.5f; + if (pulseRate >= 1f) + pulseRate = 2f - pulseRate; + pulseRate *= 0.6f; + + for (int i = 0; i < glowCount; i++) + { + float progress = i / glowCount; + float pulseRotation = (progress + slowingRate) * MathHelper.TwoPi; + + Vector2 offset = Vector2.UnitY * orbitRadius; + offset = offset.RotatedBy(pulseRotation) * pulseRate; + + spriteBatch.Draw(glowTexture, baseDrawPosition + offset, frame, new Color(56, 12, 115, 33), rotation, origin, baseScale, 0, 0); + } + + spriteBatch.Draw(glowTexture, baseDrawPosition, frame, Color.White, rotation, origin, baseScale, 0, 0); + } + + public static void DrawGlowInWorld(SpriteBatch spriteBatch, Vector2 baseDrawPosition, float rotation, float baseScale) + { + Texture2D glowTexture = ModContent.Request("CalamityMod/Items/SummonItems/TerminusGlow").Value; + Rectangle frame = glowTexture.Bounds; + DrawTerminusGlow(spriteBatch, baseDrawPosition + new Vector2(0, -1), frame, rotation, baseScale); + } + + public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) + { + Texture2D texture; + float invScale = scale * 1.4f; + if (Main.zenithWorld) { - Texture2D texture = ModContent.Request("CalamityMod/Items/SummonItems/Terminus_GFB").Value; - Color overlay = Color.White; - spriteBatch.Draw(texture, position, null, overlay, 0f, origin, scale, 0, 0); - return false; + texture = ModContent.Request("CalamityMod/Items/SummonItems/Terminus_GFB").Value; + spriteBatch.Draw(texture, position - new Vector2(-4, -1), null, Color.White, 0f, origin, invScale - 0.04f, 0, 0); } else - return true; + { + texture = ModContent.Request("CalamityMod/Items/SummonItems/Terminus").Value; + spriteBatch.Draw(texture, position, null, Color.White, 0f, origin, invScale, 0, 0); + DrawTerminusGlow(spriteBatch, position, frame, 0f, invScale); + } + + return false; } public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI) @@ -49,17 +99,20 @@ namespace CalamityMod.Items.SummonItems if (Main.zenithWorld) { Texture2D texture = ModContent.Request("CalamityMod/Items/SummonItems/Terminus_GFB").Value; - spriteBatch.Draw(texture, Item.position - Main.screenPosition, null, lightColor, 0f, Vector2.Zero, 1f, 0, 0); + spriteBatch.Draw(texture, Item.position - Main.screenPosition, null, lightColor, rotation, Vector2.Zero, scale, 0, 0); return false; } else return true; } - public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup) + public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) { - // The wiki classifies Boss Rush as an event - itemGroup = ContentSamples.CreativeHelper.ItemGroup.EventItem; + if (!Main.zenithWorld) + { + DrawGlowInWorld(spriteBatch, Item.Center - Main.screenPosition, rotation, scale); + } } + #endregion } } diff --git a/Items/SummonItems/Terminus.png b/Items/SummonItems/Terminus.png index 9693d24bb8..b94449e1dd 100644 Binary files a/Items/SummonItems/Terminus.png and b/Items/SummonItems/Terminus.png differ diff --git a/Items/SummonItems/TerminusGlow.png b/Items/SummonItems/TerminusGlow.png new file mode 100644 index 0000000000..67ce074418 Binary files /dev/null and b/Items/SummonItems/TerminusGlow.png differ diff --git a/Items/Tools/Gelpick.cs b/Items/Tools/Gelpick.cs index c10908edba..fc35ce49da 100644 --- a/Items/Tools/Gelpick.cs +++ b/Items/Tools/Gelpick.cs @@ -15,9 +15,9 @@ namespace CalamityMod.Items.Tools Item.height = 48; Item.damage = 19; Item.knockBack = 2.5f; - Item.useTime = 6; + Item.useTime = 9; Item.useAnimation = 12; - Item.pick = 90; + Item.pick = 105; Item.tileBoost += 1; Item.DamageType = DamageClass.Melee; diff --git a/Items/VanillaArmorChanges/MonkT2ArmorSetChange.cs b/Items/VanillaArmorChanges/MonkT2ArmorSetChange.cs index 50f35ac57a..0858e7b99f 100644 --- a/Items/VanillaArmorChanges/MonkT2ArmorSetChange.cs +++ b/Items/VanillaArmorChanges/MonkT2ArmorSetChange.cs @@ -24,14 +24,13 @@ namespace CalamityMod.Items.VanillaArmorChanges public override void ApplyHeadPieceEffect(Player player) { player.GetAttackSpeed() -= 0.2f; - player.Calamity().rogueVelocity += 0.15f; // Replace melee speed with rogue velocity. + player.Calamity().rogueVelocity += 0.2f; // Replace melee speed with rogue velocity. } public override void ApplyBodyPieceEffect(Player player) { player.GetDamage() -= 0.2f; - player.GetDamage() += 0.15f; // Replace melee damage with rogue damage. - player.GetDamage() -= 0.05f; // Small nerf to summon damage. + player.GetDamage() += 0.2f; // Replace melee damage with rogue damage. } public override void ApplyLegPieceEffect(Player player) diff --git a/Items/VanillaArmorChanges/MonkT3ArmorSetChange.cs b/Items/VanillaArmorChanges/MonkT3ArmorSetChange.cs index 8ff9fa762b..85ad1064f3 100644 --- a/Items/VanillaArmorChanges/MonkT3ArmorSetChange.cs +++ b/Items/VanillaArmorChanges/MonkT3ArmorSetChange.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.VanillaArmorChanges public override string ArmorSetName => "MonkTier3"; - public static float SetBonusRogueStealth = 1f; + public static float SetBonusRogueStealth = 1.1f; public override void UpdateSetBonusText(ref string setBonusText) { @@ -38,8 +38,7 @@ namespace CalamityMod.Items.VanillaArmorChanges public override void ApplyLegPieceEffect(Player player) { player.GetCritChance() -= 20; - player.GetCritChance() += 10; // Replace melee crit with rogue crit. - player.GetDamage() -= 0.1f; // Small nerf to summon damage. + player.GetCritChance() += 20; // Replace melee crit with rogue crit. } public override void ApplyArmorSetBonus(Player player) diff --git a/Items/Weapons/Magic/TheSwarmer.cs b/Items/Weapons/Magic/TheSwarmer.cs index 665c7963e1..b3329489f6 100644 --- a/Items/Weapons/Magic/TheSwarmer.cs +++ b/Items/Weapons/Magic/TheSwarmer.cs @@ -33,26 +33,30 @@ namespace CalamityMod.Items.Weapons.Magic public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - for (int i = 0; i <= 3; i++) + int beeAmount = player.strongBees ? 3 : 2; + for (int i = 0; i <= beeAmount; i++) { float SpeedX = velocity.X + (float)Main.rand.Next(-35, 36) * 0.05f; float SpeedY = velocity.Y + (float)Main.rand.Next(-35, 36) * 0.05f; - int wasps = Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, type, damage, 0f, player.whoAmI); + int wasps = Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, type, player.strongBees ? damage+5 : damage, 0f, player.whoAmI); if (wasps.WithinBounds(Main.maxProjectiles)) - { - Main.projectile[wasps].penetrate = 1; + {; Main.projectile[wasps].DamageType = DamageClass.Magic; + Main.projectile[wasps].idStaticNPCHitCooldown = 5; + if (player.strongBees) + Main.projectile[wasps].ArmorPenetration += 5; + } } - for (int i = 0; i <= 3; i++) + for (int i = 0; i <= beeAmount; i++) { float SpeedX2 = velocity.X + (float)Main.rand.Next(-35, 36) * 0.05f; float SpeedY2 = velocity.Y + (float)Main.rand.Next(-35, 36) * 0.05f; int bees = Projectile.NewProjectile(source, position.X, position.Y, SpeedX2, SpeedY2, player.beeType(), player.beeDamage(Item.damage), player.beeKB(0f), player.whoAmI); if (bees.WithinBounds(Main.maxProjectiles)) { - Main.projectile[bees].penetrate = 1; Main.projectile[bees].DamageType = DamageClass.Magic; + Main.projectile[bees].idStaticNPCHitCooldown = 5; } } return false; diff --git a/Items/Weapons/Melee/Bonebreaker.cs b/Items/Weapons/Melee/Bonebreaker.cs index 10443ca6d9..a84839d1e6 100644 --- a/Items/Weapons/Melee/Bonebreaker.cs +++ b/Items/Weapons/Melee/Bonebreaker.cs @@ -8,7 +8,7 @@ namespace CalamityMod.Items.Weapons.Melee public class Bonebreaker : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Melee"; - public const int BaseDamage = 45; + public const int BaseDamage = 55; public override void SetDefaults() { diff --git a/Items/Weapons/Melee/DeathsAscension.cs b/Items/Weapons/Melee/DeathsAscension.cs index 4d1b2516d2..8468e0ba75 100644 --- a/Items/Weapons/Melee/DeathsAscension.cs +++ b/Items/Weapons/Melee/DeathsAscension.cs @@ -33,7 +33,7 @@ namespace CalamityMod.Items.Weapons.Melee { Item.width = 70; Item.height = 70; - Item.damage = 900; + Item.damage = 700; Item.knockBack = 9f; Item.useAnimation = Item.useTime = 24; Item.DamageType = DamageClass.Melee; diff --git a/Items/Weapons/Melee/ExaltedOathblade.cs b/Items/Weapons/Melee/ExaltedOathblade.cs index 15f6113870..bfd403ae03 100644 --- a/Items/Weapons/Melee/ExaltedOathblade.cs +++ b/Items/Weapons/Melee/ExaltedOathblade.cs @@ -73,7 +73,7 @@ namespace CalamityMod.Items.Weapons.Melee } if (player.Calamity().demonSwordKillMode && player.ownedProjectileCounts[ModContent.ProjectileType()] <= 0 && player.Calamity().killModeCooldown == KillMode.cooldownMax + KillMode.buffMax) { - Projectile.NewProjectile(player.GetSource_FromThis(), player.MountedCenter, Vector2.Zero, ModContent.ProjectileType(), Item.damage * 14, Item.knockBack, player.whoAmI, 0, throwCount); //This used to be 23x damage. + Projectile.NewProjectile(player.GetSource_FromThis(), player.MountedCenter, Vector2.Zero, ModContent.ProjectileType(), Item.damage * 16, Item.knockBack, player.whoAmI, 0, throwCount); } } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) diff --git a/Items/Weapons/Melee/ForbiddenOathblade.cs b/Items/Weapons/Melee/ForbiddenOathblade.cs index 8ee7e170fd..b8339e9b17 100644 --- a/Items/Weapons/Melee/ForbiddenOathblade.cs +++ b/Items/Weapons/Melee/ForbiddenOathblade.cs @@ -72,7 +72,7 @@ namespace CalamityMod.Items.Weapons.Melee } if (player.Calamity().demonSwordKillMode && player.ownedProjectileCounts[ModContent.ProjectileType()] <= 0 && player.Calamity().killModeCooldown == KillMode.cooldownMax + KillMode.buffMax) { - Projectile blade = Projectile.NewProjectileDirect(player.GetSource_FromThis(), player.MountedCenter,Vector2.Zero, ModContent.ProjectileType(), Item.damage * 10, Item.knockBack, player.whoAmI, 0, throwCount); // This used to be 12x damage. + Projectile blade = Projectile.NewProjectileDirect(player.GetSource_FromThis(), player.MountedCenter,Vector2.Zero, ModContent.ProjectileType(), Item.damage * 12, Item.knockBack, player.whoAmI, 0, throwCount); } } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) diff --git a/Items/Weapons/Melee/GrandDad.cs b/Items/Weapons/Melee/GrandDad.cs index 19af4012db..fab3876b27 100644 --- a/Items/Weapons/Melee/GrandDad.cs +++ b/Items/Weapons/Melee/GrandDad.cs @@ -75,7 +75,8 @@ namespace CalamityMod.Items.Weapons.Melee if (time == 0 && Item.velocity.Y != 0) { oldVel = Item.velocity; - Item.velocity = new Vector2(Math.Sign(Item.velocity.X) * 20, -10); + if (!hitFloor) + Item.velocity = new Vector2(Math.Sign(Item.velocity.X) * 20, -10); } if (oldVel.Y != 0 && Item.velocity.Y == 0) { @@ -87,6 +88,7 @@ namespace CalamityMod.Items.Weapons.Melee float blastSize = 150 * power; float minMultiplier = 0.3f; int hitsToMinMult = 8; + hitFloor = true; Projectile blast = Projectile.NewProjectileDirect(Item.GetSource_FromThis(), place, Vector2.Zero, ModContent.ProjectileType(), (int)(Item.damage * 2 * power), -35 * power, -1, blastSize, minMultiplier, hitsToMinMult); blast.timeLeft = 5; @@ -123,7 +125,8 @@ namespace CalamityMod.Items.Weapons.Melee highestSpeed = Item.velocity.Y; } - gravity = 0; + if (Item.velocity.Y != 0) + gravity = 0; maxFallSpeed = 75; oldVel = Item.velocity; } diff --git a/Items/Weapons/Melee/GreatswordofJudgement.cs b/Items/Weapons/Melee/GreatswordofJudgement.cs index 81de0f4665..cc8e3162bd 100644 --- a/Items/Weapons/Melee/GreatswordofJudgement.cs +++ b/Items/Weapons/Melee/GreatswordofJudgement.cs @@ -23,6 +23,7 @@ namespace CalamityMod.Items.Weapons.Melee public bool canHit => (completion >= 0.35f && completion <= 0.8f); public int swingCount = 0; public bool spawnProj = true; + public bool spawnTrueMeleeProj = true; public bool playSound = true; public Color clr = Color.MediumOrchid; @@ -70,6 +71,7 @@ namespace CalamityMod.Items.Weapons.Melee bladeHitboxPos = player.Center; bladeRotation = 0; spawnProj = true; + spawnTrueMeleeProj = true; playSound = true; int dir = -Math.Sign(player.Center.X - player.Calamity().mouseWorld.X); float startRot = MathHelper.ToRadians(-90) * dir * (swingCount % 2 == 0 ? 1 : -1); @@ -106,7 +108,8 @@ namespace CalamityMod.Items.Weapons.Melee } if (completion >= 0.65f && spawnProj) { - Projectile.NewProjectile(player.GetSource_FromThis(), player.Center, shootDir, Item.shoot, Item.damage, Item.knockBack, player.whoAmI, 0f); + if (!player.Calamity().bladeArmEnchant) // Manually remove projectiles when Tainted + Projectile.NewProjectile(player.GetSource_FromThis(), player.Center, shootDir, Item.shoot, Item.damage, Item.knockBack, player.whoAmI, 0f); Particle swipe = new CustomSpark(player.Center - shootDir * 5, shootDir.RotatedBy(0.4f * (dir * (swingCount % 2 == 0 ? 1 : -1))) * 2.5f, "CalamityMod/Particles/VerticalSmearLarge", false, (int)(14 / player.GetAttackSpeed(DamageClass.Melee)), 0.6f, clr, new Vector2(1f, 1f), true, false, 0, false, false); GeneralParticleHandler.SpawnParticle(swipe); @@ -132,13 +135,17 @@ namespace CalamityMod.Items.Weapons.Melee } public override void OnHitNPC(Player player, NPC target, NPC.HitInfo hit, int damageDone) { - int beamDamage = player.CalcIntDamage(Item.damage * 0.4f); - Vector2 mouseClamped = player.ClampedMouseWorld(); - SoundEngine.PlaySound(SoundID.Item84 with { Volume = 1f, Pitch = Main.rand.NextFloat(0.5f, 0.7f) }, player.Center); - for (int i = 0; i < 2; i++) + if (spawnTrueMeleeProj) { - Vector2 vel = player.Center.DirectionFrom(target.Center).RotatedByRandom(0.7f) * Main.rand.NextFloat(18, 20); - Projectile.NewProjectile(player.GetSource_ItemUse(Item), player.Center, vel, ModContent.ProjectileType(), beamDamage, 0, player.whoAmI, 0, (i == 0 ? -1 : 1), 1); + int beamDamage = player.CalcIntDamage(Item.damage * 0.35f); + Vector2 mouseClamped = player.ClampedMouseWorld(); + SoundEngine.PlaySound(SoundID.Item84 with { Volume = 1f, Pitch = Main.rand.NextFloat(0.5f, 0.7f) }, player.Center); + for (int i = 0; i < 2; i++) + { + Vector2 vel = player.Center.DirectionFrom(target.Center).RotatedByRandom(0.7f) * Main.rand.NextFloat(18, 20); + Projectile.NewProjectile(player.GetSource_ItemUse(Item), player.Center, vel, ModContent.ProjectileType(), beamDamage, 0, player.whoAmI, 0, (i == 0 ? -1 : 1), 1); + } + spawnTrueMeleeProj = false; } } public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) diff --git a/Items/Weapons/Melee/HolyCollider.cs b/Items/Weapons/Melee/HolyCollider.cs index 481ff370dd..51133ffcf2 100644 --- a/Items/Weapons/Melee/HolyCollider.cs +++ b/Items/Weapons/Melee/HolyCollider.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Weapons.Melee { Item.width = 114; Item.height = 146; - Item.damage = 3140; + Item.damage = 2900; Item.DamageType = TrueMeleeDamageClass.Instance; Item.useAnimation = 45; Item.useStyle = ItemUseStyleID.Swing; diff --git a/Items/Weapons/Melee/Lucrecia.cs b/Items/Weapons/Melee/Lucrecia.cs index ff151ba276..6fd7a2d0d9 100644 --- a/Items/Weapons/Melee/Lucrecia.cs +++ b/Items/Weapons/Melee/Lucrecia.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Items.Weapons.Melee Item.width = 54; Item.height = 54; Item.useStyle = ItemUseStyleID.Shoot; - Item.damage = 170; + Item.damage = 150; Item.DamageType = DamageClass.Melee; Item.useAnimation = Item.useTime = 34; Item.shootSpeed = 10f; diff --git a/Items/Weapons/Melee/MonstrousKnives.cs b/Items/Weapons/Melee/MonstrousKnives.cs index 4dff8f0547..72d7cdd46c 100644 --- a/Items/Weapons/Melee/MonstrousKnives.cs +++ b/Items/Weapons/Melee/MonstrousKnives.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.Weapons.Melee { Item.width = 18; Item.height = 20; - Item.damage = 9; + Item.damage = 8; Item.DamageType = DamageClass.MeleeNoSpeed; Item.noMelee = true; Item.noUseGraphic = true; diff --git a/Items/Weapons/Melee/Orderbringer.cs b/Items/Weapons/Melee/Orderbringer.cs index 657b17ab47..3fc0e1639a 100644 --- a/Items/Weapons/Melee/Orderbringer.cs +++ b/Items/Weapons/Melee/Orderbringer.cs @@ -29,11 +29,12 @@ namespace CalamityMod.Items.Weapons.Melee public bool canHit => (completion >= 0.35f && completion <= 0.8f); public int swingCount = 0; public bool spawnProj = true; + public bool spawnTrueMeleeProj = true; public bool playSound = true; public override void SetDefaults() { Item.width = Item.height = 112; - Item.damage = 840; + Item.damage = 800; Item.DamageType = DamageClass.Melee; Item.useAnimation = Item.useTime = 16; Item.useStyle = ItemUseStyleID.Swing; @@ -72,6 +73,7 @@ namespace CalamityMod.Items.Weapons.Melee bladeHitboxPos = player.Center; bladeRotation = 0; spawnProj = true; + spawnTrueMeleeProj = true; playSound = true; int dir = -Math.Sign(player.Center.X - player.Calamity().mouseWorld.X); float startRot = MathHelper.ToRadians(-90) * dir * (swingCount % 2 == 0 ? 1 : -1); @@ -106,13 +108,16 @@ namespace CalamityMod.Items.Weapons.Melee } if (completion >= 0.65f && spawnProj) { - Projectile.NewProjectile(player.GetSource_FromThis(), player.Center, shootDir, Item.shoot, Item.damage, Item.knockBack, player.whoAmI, 0f); - - for (int i = 0; i < 4; i++) + if (!player.Calamity().bladeArmEnchant) // Manually remove projectiles when Tainted { - float rot = Main.rand.NextFloat(0.5f, 0.65f) * (Main.rand.NextBool() ? 1 : -1); - Vector2 vel = (shootDir * 2.5f).RotatedByRandom(0.6f); - Projectile.NewProjectile(player.GetSource_FromThis(), player.ClampedMouseWorld() - (shootDir * 40) + Main.rand.NextVector2Circular(130, 130), vel.RotatedBy(rot) * Main.rand.NextFloat(0.9f, 1.2f), ModContent.ProjectileType(), (int)(Item.damage * 0.12f), (int)(Item.knockBack * 0.2f), player.whoAmI, 0, rot, 1); + Projectile.NewProjectile(player.GetSource_FromThis(), player.Center, shootDir, Item.shoot, Item.damage, Item.knockBack, player.whoAmI, 0f); + + for (int i = 0; i < 4; i++) + { + float rot = Main.rand.NextFloat(0.5f, 0.65f) * (Main.rand.NextBool() ? 1 : -1); + Vector2 vel = (shootDir * 2.5f).RotatedByRandom(0.6f); + Projectile.NewProjectile(player.GetSource_FromThis(), player.ClampedMouseWorld() - (shootDir * 40) + Main.rand.NextVector2Circular(130, 130), vel.RotatedBy(rot) * Main.rand.NextFloat(0.9f, 1.2f), ModContent.ProjectileType(), (int)(Item.damage * 0.12f), (int)(Item.knockBack * 0.2f), player.whoAmI, 0, rot, 1); + } } Particle swipe = new CustomSpark(player.Center - shootDir * 5, shootDir.RotatedBy(0.4f * (dir * (swingCount % 2 == 0 ? 1 : -1))) * 2.5f, "CalamityMod/Particles/VerticalSmearLarge", false, (int)(14 / player.GetAttackSpeed(DamageClass.Melee)), 0.8f, player.Calamity().lightRGB, new Vector2(1f, 1f), true, false, 0, false, false); @@ -140,19 +145,23 @@ namespace CalamityMod.Items.Weapons.Melee } public override void OnHitNPC(Player player, NPC target, NPC.HitInfo hit, int damageDone) { - int beamDamage = player.CalcIntDamage(Item.damage * 0.4f); - Vector2 mouseClamped = player.ClampedMouseWorld(); - SoundEngine.PlaySound(SoundID.Item84 with { Volume = 1f, Pitch = Main.rand.NextFloat(0.5f, 0.7f)}, player.Center); - for (int i = 0; i < 2; i++) + if (spawnTrueMeleeProj) { - Vector2 targetPos = Main.MouseWorld; - NPC target2 = Main.MouseWorld.ClosestNPCAt(650); - if (target2 != null) - targetPos = target2.Center; + int beamDamage = player.CalcIntDamage(Item.damage * 0.35f); + Vector2 mouseClamped = player.ClampedMouseWorld(); + SoundEngine.PlaySound(SoundID.Item84 with { Volume = 1f, Pitch = Main.rand.NextFloat(0.5f, 0.7f) }, player.Center); + for (int i = 0; i < 2; i++) + { + Vector2 targetPos = Main.MouseWorld; + NPC target2 = Main.MouseWorld.ClosestNPCAt(650); + if (target2 != null) + targetPos = target2.Center; - Vector2 spawnPos = mouseClamped + new Vector2(Main.rand.NextFloat(-300, 300), -900); - Vector2 vel = (targetPos - spawnPos).SafeNormalize(Vector2.UnitY) * 10; - Projectile.NewProjectile(player.GetSource_ItemUse(Item), spawnPos, vel, ModContent.ProjectileType(), beamDamage, 0, player.whoAmI); + Vector2 spawnPos = mouseClamped + new Vector2(Main.rand.NextFloat(-300, 300), -900); + Vector2 vel = (targetPos - spawnPos).SafeNormalize(Vector2.UnitY) * 10; + Projectile.NewProjectile(player.GetSource_ItemUse(Item), spawnPos, vel, ModContent.ProjectileType(), beamDamage, 0, player.whoAmI); + } + spawnTrueMeleeProj = false; } } public override void ModifyTooltips(List list) diff --git a/Items/Weapons/Melee/TheBurningSky.cs b/Items/Weapons/Melee/TheBurningSky.cs index 161909dfc0..4147065fcb 100644 --- a/Items/Weapons/Melee/TheBurningSky.cs +++ b/Items/Weapons/Melee/TheBurningSky.cs @@ -6,6 +6,7 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.DataStructures; +using Terraria.GameContent.Prefixes; using Terraria.ID; using Terraria.ModLoader; @@ -44,6 +45,8 @@ namespace CalamityMod.Items.Weapons.Melee Item.value = CalamityGlobalItem.RarityVioletBuyPrice; Item.rare = ModContent.RarityType(); } + public override bool RangedPrefix() => true; //class identity is fake + public override bool MeleePrefix() => false; public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { diff --git a/Items/Weapons/Melee/TheOracle.cs b/Items/Weapons/Melee/TheOracle.cs index 100bef55bb..ad16f5eeab 100644 --- a/Items/Weapons/Melee/TheOracle.cs +++ b/Items/Weapons/Melee/TheOracle.cs @@ -12,8 +12,8 @@ namespace CalamityMod.Items.Weapons.Melee public class TheOracle : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Melee"; - public const int AuraBaseDamage = 68; - public const int AuraMaxDamage = 150; + public const float AuraBaseDamageMult = 0.35f; + public const float AuraMaxDamageMult = 0.8f; public static float Reach = 800f; public static float Speed = 60f; @@ -31,7 +31,7 @@ namespace CalamityMod.Items.Weapons.Melee Item.width = 58; Item.height = 50; Item.DamageType = DamageClass.MeleeNoSpeed; - Item.damage = 192; + Item.damage = 201; Item.knockBack = 4f; Item.useTime = 20; Item.useAnimation = 20; diff --git a/Items/Weapons/Ranged/FirestormCannon.cs b/Items/Weapons/Ranged/FirestormCannon.cs index f26eca63a1..bece6011c9 100644 --- a/Items/Weapons/Ranged/FirestormCannon.cs +++ b/Items/Weapons/Ranged/FirestormCannon.cs @@ -25,7 +25,7 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 56; Item.height = 28; - Item.damage = 17; + Item.damage = 15; Item.DamageType = DamageClass.Ranged; Item.useTime = Item.useAnimation = 11; Item.knockBack = 1.5f; diff --git a/Items/Weapons/Ranged/HalibutCannon.cs b/Items/Weapons/Ranged/HalibutCannon.cs index 82e65e004e..c97d932eaf 100644 --- a/Items/Weapons/Ranged/HalibutCannon.cs +++ b/Items/Weapons/Ranged/HalibutCannon.cs @@ -40,9 +40,9 @@ namespace CalamityMod.Items.Weapons.Ranged { SoundEngine.PlaySound(SoundID.Item38, player.Center); - // Really jammed in GFB - if (Main.zenithWorld) - return Main.rand.NextBool(5); + // Really jammed in GFB (only fires 20% of the time) + if (Main.zenithWorld && Main.rand.Next(5) < 4) + return false; int bulletAmt = Main.rand.Next(25, 36); for (int index = 0; index < bulletAmt; ++index) diff --git a/Items/Weapons/Ranged/HalleysInferno.cs b/Items/Weapons/Ranged/HalleysInferno.cs index c6fbde9718..69890dfbb8 100644 --- a/Items/Weapons/Ranged/HalleysInferno.cs +++ b/Items/Weapons/Ranged/HalleysInferno.cs @@ -20,13 +20,13 @@ namespace CalamityMod.Items.Weapons.Ranged public static readonly SoundStyle ShootSound = new("CalamityMod/Sounds/Item/HalleysInfernoShoot") { Volume = 0.68f }; public static readonly SoundStyle Hit = new("CalamityMod/Sounds/Item/HalleysInfernoHit") { Volume = 0.75f }; public static float MaxStarburstPerComet => 1; - public static float MaxStarburstPerStar => 0.25f; + public static float MaxStarburstPerStar => 0.5f; public static float LostAccuracyPerMiss => 4; public static float MaxAccuracy => 50; - public static float StarburstDmgMult => 1.25f; + public static float StarburstDmgMult => 2.5f; - public static float StarburstVelMult = 0.75f; + public static float StarburstVelMult => 0.75f; public override void SetDefaults() { Item.width = 84; @@ -62,6 +62,9 @@ namespace CalamityMod.Items.Weapons.Ranged public override void ModifyWeaponCrit(Player player, ref float crit) => crit += 20; public override void HoldItem(Player player) { + if (player.mount.Type == MountID.Drill) + return; + if (Main.LocalPlayer == player) { if (!Main.projectile.Any(x=> x.active && x.owner == player.whoAmI && x.type == Item.shoot)) diff --git a/Items/Weapons/Ranged/M1Garand.cs b/Items/Weapons/Ranged/M1Garand.cs index ff034f96b2..27254cb375 100644 --- a/Items/Weapons/Ranged/M1Garand.cs +++ b/Items/Weapons/Ranged/M1Garand.cs @@ -31,7 +31,7 @@ namespace CalamityMod.Items.Weapons.Ranged Item.useAmmo = AmmoID.Bullet; Item.noUseGraphic = true; - Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; + Item.value = Item.buyPrice(gold: 20); // Sold by Arms Dealer Item.rare = ItemRarityID.Orange; } diff --git a/Items/Weapons/Ranged/SpectralstormCannon.cs b/Items/Weapons/Ranged/SpectralstormCannon.cs index cf941d622b..3f8d0fe46a 100644 --- a/Items/Weapons/Ranged/SpectralstormCannon.cs +++ b/Items/Weapons/Ranged/SpectralstormCannon.cs @@ -25,7 +25,7 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 66; Item.height = 26; - Item.damage = 82; + Item.damage = 85; Item.DamageType = DamageClass.Ranged; Item.useTime = Item.useAnimation = 11; Item.knockBack = 1.5f; diff --git a/Items/Weapons/Rogue/Exorcism.cs b/Items/Weapons/Rogue/Exorcism.cs index 4f412f2c09..090684968f 100644 --- a/Items/Weapons/Rogue/Exorcism.cs +++ b/Items/Weapons/Rogue/Exorcism.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Weapons.Rogue { Item.width = 109; Item.height = 128; - Item.damage = 192; + Item.damage = 222; Item.noMelee = true; Item.noUseGraphic = true; // Due to the amazing sound engine, having multiple crosses embedded in enemies cuts off the sound diff --git a/Items/Weapons/Rogue/MoltenAmputator.cs b/Items/Weapons/Rogue/MoltenAmputator.cs index 205b0c8fbc..5c21deb49e 100644 --- a/Items/Weapons/Rogue/MoltenAmputator.cs +++ b/Items/Weapons/Rogue/MoltenAmputator.cs @@ -38,7 +38,7 @@ namespace CalamityMod.Items.Weapons.Rogue { if (player.Calamity().StealthStrikeAvailable()) { - player.Calamity().amputatorBuff = 30; + player.Calamity().focusFlurryAttackCount = 30; player.Calamity().ConsumeStealthByAttacking(); SoundStyle buff = new("CalamityMod/Sounds/Custom/ProfanedGuardians/GuardianRay"); SoundEngine.PlaySound(buff with { Volume = 1f, Pitch = Main.rand.NextFloat(0.2f, 0.3f) }, player.Center); @@ -67,24 +67,24 @@ namespace CalamityMod.Items.Weapons.Rogue } public override float UseSpeedMultiplier(Player player) { - return (player.Calamity().amputatorBuff > 0 ? 3f : 1); + return (player.Calamity().focusFlurryAttackCount > 0 ? 3f : 1); } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - bool fastToss = player.Calamity().amputatorBuff > 0; + bool fastToss = player.Calamity().focusFlurryAttackCount > 0; SoundStyle fire = new("CalamityMod/Sounds/Item/SpearofDestiny"); - SoundEngine.PlaySound(fire with { Volume = 0.5f, Pitch = (player.Calamity().amputatorBuff > 0 ? -0.4f + (player.Calamity().amputatorBuff * 0.02f) : Main.rand.NextFloat(-0.4f, -0.65f)) }, position); + SoundEngine.PlaySound(fire with { Volume = 0.5f, Pitch = (player.Calamity().focusFlurryAttackCount > 0 ? -0.4f + (player.Calamity().focusFlurryAttackCount * 0.02f) : Main.rand.NextFloat(-0.4f, -0.65f)) }, position); // Since the positioning of the scythe is important, its velocity is based on your mouse position Vector2 staticSpeed = Utils.DirectionTo(position, position + velocity) * Utils.Distance(position, player.ClampedMouseWorld()) * 0.022f; // "fast toss" is the stealth, if you need to change stealth values, change those int fastTossDamage = (int)(damage * 0.65f); - Projectile scythe = Projectile.NewProjectileDirect(source, position, staticSpeed.RotatedByRandom((player.Calamity().amputatorBuff > 0 ? 0.7f : 0)), type, fastToss ? fastTossDamage : damage, knockback, player.whoAmI, 0, 0, 0); + Projectile scythe = Projectile.NewProjectileDirect(source, position, staticSpeed.RotatedByRandom((player.Calamity().focusFlurryAttackCount > 0 ? 0.7f : 0)), type, fastToss ? fastTossDamage : damage, knockback, player.whoAmI, 0, 0, 0); if (fastToss) { scythe.extraUpdates = 6; scythe.Calamity().stealthStrike = true; - player.Calamity().amputatorBuff--; + player.Calamity().focusFlurryAttackCount--; } player.Calamity().ConsumeStealthByAttacking(); diff --git a/Items/Weapons/Rogue/NanoblackReaper.cs b/Items/Weapons/Rogue/NanoblackReaper.cs index 4e74227094..7c690b132a 100644 --- a/Items/Weapons/Rogue/NanoblackReaper.cs +++ b/Items/Weapons/Rogue/NanoblackReaper.cs @@ -1,19 +1,37 @@ -using CalamityMod.Items.Materials; +using CalamityMod.CalPlayer; +using CalamityMod.Items.Materials; +using CalamityMod.Particles; using CalamityMod.Projectiles.Rogue; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; using Microsoft.Xna.Framework; using Terraria; +using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Rogue { - // Deny me no longer! + // Bleak, directionless slaughter. + // A celebration of the vices that brought Her to this point. [LegacyName("NanoblackReaperMelee", "NanoblackReaperRogue")] public class NanoblackReaper : RogueWeapon, IHoldShiftTooltipItem { + // Right triangles, and like triangles. + internal const float PiOver3 = MathHelper.Pi / 3f; + internal const float TwoPiOver3 = MathHelper.TwoPi / 3f; + + internal static readonly Color NanoblackSlashColor1 = new Color(47, 248, 211); // #2FF8D4 + internal static readonly Color NanoblackSlashColor2 = new Color(15, 15, 15); // #0F0F0F + internal static readonly Color NanoblackDustColor1 = new Color(52, 239, 184); // #34EFB8 + internal static readonly Color TesselationParticleColor = new Color(79, 240, 168); // 4FF0A8 + internal static readonly Color ZeroPointLineColor = new Color(24, 191, 160); // #1FBFA0 + internal static readonly Color ZeroPointImpactColor = new Color(31, 223, 128, 96); // #1FDF80 + internal static readonly Color PiercingStrikeColor = new Color(36, 252, 212); // #24FCD4 + internal static readonly Color LightspeedCarveColor1 = new Color(68, 242, 242); // #44F2F2 + internal static readonly Color LightspeedCarveColor2 = new Color(66, 219, 173); // #42DBAD + public bool ShowExtensionIndicator => false; public bool HasFlavorTooltip => true; public Color? TooltipExtensionColor => new Color(31, 223, 128); // #1FDF80 @@ -22,14 +40,28 @@ namespace CalamityMod.Items.Weapons.Rogue public static float Knockback = 9f; public static float Speed = 16f; + public static int FocusFlurryAttacks = 12; + public static int PerfectLightspeedCarveFrames = 4; + public static int ImperfectLightspeedCarveFrames = 8; // This frame window is immediately after the perfect window. + public static float LightspeedCarveKnockback = 7f; + + public static int ArmorPenetration = 30; + // Armor pen declared on projectiles will be added to that of the parent projectile or, failing that, item that spawned it. + public static int ZeroPointArmorPenetration = 120; // Total: 150. + public static int LightspeedCarveArmorPenetration = 120; // Total: 150. + public static float TesselationDamageRatio = 0.25f; + public static float TesselationKnockback = 1.5f; + + public override float StealthDamageMultiplier => 1.0f; + public override void SetDefaults() { Item.width = 78; Item.height = 64; - Item.damage = 130; + Item.damage = 315; Item.knockBack = Knockback; - Item.useTime = 6; - Item.useAnimation = 6; + Item.ArmorPenetration = ArmorPenetration; + Item.useTime = Item.useAnimation = 19; Item.autoReuse = true; Item.noMelee = true; Item.noUseGraphic = true; @@ -46,23 +78,97 @@ namespace CalamityMod.Items.Weapons.Rogue Item.shootSpeed = Speed; } + public override void HoldItem(Player player) + { + CalamityPlayer modPlayer = player.Calamity(); + modPlayer.mouseWorldListener = true; + + // Safeguard because focus flurries are currently cross-weapon. + if (modPlayer.focusFlurryAttackCount > FocusFlurryAttacks) + modPlayer.focusFlurryAttackCount = FocusFlurryAttacks; + + // Remainder of behavior should only be called on owning client + if (player.whoAmI != Main.myPlayer) + return; + + // Right click behavior: activate Focus Flurry as applicable + if (modPlayer.mouseRight && modPlayer.StealthStrikeAvailable()) + { + // "Stealth strikes" with Nanoblack Reaper are Focus Flurries: the next 30 attacks come out very, very quickly. + modPlayer.ConsumeStealthByAttacking(); + modPlayer.focusFlurryAttackCount = FocusFlurryAttacks; + + SoundStyle flurryActivationSound1 = new("CalamityMod/Sounds/Item/StygianDash"); + SoundStyle flurryActivationSound2 = new("CalamityMod/Sounds/Item/HeliumFlashCoreImpact"); + float sound2Pitch = Main.rand.NextFloat(0.08f, 0.2f); + SoundEngine.PlaySound(flurryActivationSound1 with { Volume = 1f }, player.Center); + SoundEngine.PlaySound(flurryActivationSound2 with { Volume = 0.3f, Pitch = sound2Pitch }, player.Center); + + // Spawn a dramatic void slash particle over the player when this is activated + { + Color color = NanoblackSlashColor1; + float scale = 0.33f; + Vector2 slashDir = (Main.rand.NextBool() ? -1f : 1f) * Vector2.UnitX; + Vector2 vel = 0.01f * slashDir.RotatedByRandom(MathHelper.Pi / 8f); + + // scale of void sparks is arbitrarily multiplied by 0.357f. thanks! + float voidScale = scale / 0.357f; + Particle blackSpark = new VoidSparkParticle(player.Center, vel, false, 12, voidScale, color, 1f); + GeneralParticleHandler.SpawnParticle(blackSpark); + + float glowScale = scale * 0.333f; + Vector2 squashStretch = new(1.3333f, 0.8f); + Particle innerSpark = new GlowSparkParticle(player.Center, vel, false, 11, glowScale, color, squashStretch, true, true, 1f); + GeneralParticleHandler.SpawnParticle(innerSpark); + } + } + + // Negative-edge left click behavior: attempt light-speed carves + // This will evaluate to true for exactly one frame when the player lets go of the left mouse button. + bool leftMouseJustReleased = Main.mouseLeft && Main.mouseLeftRelease; + if (leftMouseJustReleased) + { + int scytheID = ModContent.ProjectileType(); + for (int i = 0; i < Main.maxProjectiles; ++i) + { + Projectile p = Main.projectile[i]; + if (!p.active || p.type != scytheID || p.owner != player.whoAmI) + continue; + + NanoblackMain nr = p.ModProjectile as NanoblackMain; + nr.AttemptLightspeedCarve(); + } + } + } + + // Nanoblack Reaper's attack speed triples (similar to its classic speed) during a Focus Flurry. + public override float UseSpeedMultiplier(Player player) => player.Calamity().focusFlurryAttackCount > 0 ? 3f : 1f; + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - if (player.Calamity().StealthStrikeAvailable()) + // Focus flurries produce a different sound and set the stealth strike flag to change behavior. + CalamityPlayer modPlayer = player.Calamity(); + bool focusFlurry = modPlayer.focusFlurryAttackCount > 0; + if (focusFlurry) { - int stealth = Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI); - if (stealth.WithinBounds(Main.maxProjectiles)) - Main.projectile[stealth].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); + SoundStyle flurryThrowSound = new("CalamityMod/Sounds/Item/DemonSwordSwing2"); + float pitch = Main.rand.NextFloat(-0.24f, -0.12f) + modPlayer.focusFlurryAttackCount * 0.01f; + SoundEngine.PlaySound(flurryThrowSound with { Volume = 0.2f, Pitch = pitch, MaxInstances = 12 }, player.Center); + + Projectile focusReaper = Projectile.NewProjectileDirect(source, position, velocity, type, damage, knockback, player.whoAmI); + focusReaper.Calamity().stealthStrike = true; + --modPlayer.focusFlurryAttackCount; return false; } + return true; } public override void AddRecipes() { CreateRecipe(). - AddIngredient(). AddIngredient(). + AddIngredient(). AddIngredient(5). AddIngredient(40). AddIngredient(20). diff --git a/Items/Weapons/Rogue/RotBall.cs b/Items/Weapons/Rogue/RotBall.cs index 24d5f0bf51..a915b82bc8 100644 --- a/Items/Weapons/Rogue/RotBall.cs +++ b/Items/Weapons/Rogue/RotBall.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.Weapons.Rogue { Item.width = 30; Item.height = 30; - Item.damage = 20; + Item.damage = 16; Item.noMelee = true; Item.noUseGraphic = true; Item.useAnimation = 16; diff --git a/Items/Weapons/Rogue/SeafoamBomb.cs b/Items/Weapons/Rogue/SeafoamBomb.cs index cc8bf3edc4..d5ee968079 100644 --- a/Items/Weapons/Rogue/SeafoamBomb.cs +++ b/Items/Weapons/Rogue/SeafoamBomb.cs @@ -43,7 +43,6 @@ namespace CalamityMod.Items.Weapons.Rogue } return true; } - public override void ModifyTooltips(List list) => list.FindAndReplace("[GFB]", this.GetLocalizedValue(Main.zenithWorld ? "TooltipGFB" : "TooltipNormal")); public override void AddRecipes() { diff --git a/Items/Weapons/Rogue/ShardofAntumbra.cs b/Items/Weapons/Rogue/ShardofAntumbra.cs index 8afe0a8142..40adf3c663 100644 --- a/Items/Weapons/Rogue/ShardofAntumbra.cs +++ b/Items/Weapons/Rogue/ShardofAntumbra.cs @@ -15,12 +15,11 @@ namespace CalamityMod.Items.Weapons.Rogue { Item.width = 48; Item.height = 48; - Item.damage = 144; + Item.damage = 111; Item.noMelee = true; Item.noUseGraphic = true; - Item.useAnimation = 17; + Item.useTime = Item.useAnimation = 17; Item.useStyle = ItemUseStyleID.Swing; - Item.useTime = 17; Item.knockBack = 8f; Item.UseSound = SoundID.Item1; Item.autoReuse = true; @@ -31,7 +30,7 @@ namespace CalamityMod.Items.Weapons.Rogue Item.DamageType = RogueDamageClass.Instance; } - public override float StealthDamageMultiplier => 0.65f; + public override float StealthDamageMultiplier => 0.7f; public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { diff --git a/Items/Weapons/Rogue/ToothBall.cs b/Items/Weapons/Rogue/ToothBall.cs index fd95ef183a..eada2f3536 100644 --- a/Items/Weapons/Rogue/ToothBall.cs +++ b/Items/Weapons/Rogue/ToothBall.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.Weapons.Rogue { Item.width = 30; Item.height = 30; - Item.damage = 20; + Item.damage = 16; Item.noMelee = true; Item.noUseGraphic = true; Item.useAnimation = 16; diff --git a/Items/Weapons/Summon/DazzlingStabberStaff.cs b/Items/Weapons/Summon/DazzlingStabberStaff.cs index f66a47e2db..4ea967a21e 100644 --- a/Items/Weapons/Summon/DazzlingStabberStaff.cs +++ b/Items/Weapons/Summon/DazzlingStabberStaff.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Items.Weapons.Summon Item.UseSound = SoundID.DD2_DarkMageHealImpact; Item.DamageType = DamageClass.Summon; Item.mana = 10; - Item.damage = 43; + Item.damage = 35; Item.knockBack = 2f; Item.autoReuse = true; Item.useAnimation = Item.useTime = 24; diff --git a/Items/Weapons/Summon/IgneousExaltation.cs b/Items/Weapons/Summon/IgneousExaltation.cs index 2523a46969..3b829ede05 100644 --- a/Items/Weapons/Summon/IgneousExaltation.cs +++ b/Items/Weapons/Summon/IgneousExaltation.cs @@ -14,8 +14,8 @@ namespace CalamityMod.Items.Weapons.Summon { public class IgneousExaltation : ModItem, ILocalizedModType { - public static int ChargeDuration = 30; - public static int ChargeCooldown = 120; + public static int ChargeDuration => 25; + public static int ChargeCooldown => 120; public new string LocalizationCategory => "Items.Weapons.Summon"; private static Texture2D BladeOutline = null; public static Texture2D GetBladeOutlineTex() @@ -45,7 +45,7 @@ namespace CalamityMod.Items.Weapons.Summon { Item.width = 52; Item.height = 50; - Item.damage = 34; + Item.damage = 30; Item.mana = 10; Item.useAnimation = Item.useTime = 36; Item.useStyle = ItemUseStyleID.Shoot; diff --git a/Items/Weapons/Summon/SanctifiedSpark.cs b/Items/Weapons/Summon/SanctifiedSpark.cs index 62798dbb63..0c10f1a1bb 100644 --- a/Items/Weapons/Summon/SanctifiedSpark.cs +++ b/Items/Weapons/Summon/SanctifiedSpark.cs @@ -20,7 +20,7 @@ namespace CalamityMod.Items.Weapons.Summon { Item.width = 66; Item.height = 68; - Item.damage = 128; + Item.damage = 100; Item.DamageType = DamageClass.Summon; Item.sentry = true; Item.mana = 100; diff --git a/Items/Weapons/Summon/Sirius.cs b/Items/Weapons/Summon/Sirius.cs index 3b90737476..9eb6828716 100644 --- a/Items/Weapons/Summon/Sirius.cs +++ b/Items/Weapons/Summon/Sirius.cs @@ -20,7 +20,7 @@ namespace CalamityMod.Items.Weapons.Summon public override void SetDefaults() { Item.width = Item.height = 62; - Item.damage = 150; + Item.damage = 90; Item.useAnimation = Item.useTime = 24; Item.mana = 10; Item.knockBack = 10f; diff --git a/Items/Weapons/Summon/VengefulSunStaff.cs b/Items/Weapons/Summon/VengefulSunStaff.cs index 7152f1617f..14f973ea85 100644 --- a/Items/Weapons/Summon/VengefulSunStaff.cs +++ b/Items/Weapons/Summon/VengefulSunStaff.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Summon { Item.width = 72; Item.height = 72; - Item.damage = 40; + Item.damage = 35; Item.mana = 10; Item.useAnimation = Item.useTime = 36; Item.useStyle = ItemUseStyleID.Swing; diff --git a/Items/Weapons/Typeless/ClaretCannon.cs b/Items/Weapons/Typeless/ClaretCannon.cs index 655a33eefa..f3c630c63e 100644 --- a/Items/Weapons/Typeless/ClaretCannon.cs +++ b/Items/Weapons/Typeless/ClaretCannon.cs @@ -1,23 +1,37 @@ -using CalamityMod.Items.Materials; +using System; +using System.Reflection; +using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Typeless; using CalamityMod.Rarities; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.DataStructures; using Terraria.ID; -using Microsoft.Xna.Framework.Graphics; using Terraria.ModLoader; -using System; namespace CalamityMod.Items.Weapons.Typeless { - public class ClaretCannon : ModItem, ILocalizedModType + public interface IClaretCannonInstance { - public new string LocalizationCategory => "Items.Weapons.Typeless"; + int CooldownMax { get; } + } + public class ClaretCannonPlayer : ModPlayer + { public int ClaretCooldown = 0; - public static int ClaretCooldownMax = 600; + public override void ResetEffects() + { + if (ClaretCooldown > 0) + ClaretCooldown--; + } + } + + public class ClaretCannon : ModItem, IClaretCannonInstance, ILocalizedModType + { + public new string LocalizationCategory => "Items.Weapons.Typeless"; + public int CooldownMax => 600; public float baseUseDir = 0; public override void SetDefaults() @@ -42,12 +56,6 @@ namespace CalamityMod.Items.Weapons.Typeless public override Vector2? HoldoutOffset() => new Vector2(-5, 0); - public override void UpdateInventory(Player player) - { - ClaretCooldown--; - if (ClaretCooldown < 0) - ClaretCooldown = 0; - } public override void AddRecipes() { CreateRecipe(). @@ -58,9 +66,7 @@ namespace CalamityMod.Items.Weapons.Typeless public override bool CanUseItem(Player player) { - if (ClaretCooldown > 0) - return false; - return true; + return player.GetModPlayer().ClaretCooldown <= 0; } public override void UseAnimation(Player player) @@ -77,15 +83,18 @@ namespace CalamityMod.Items.Weapons.Typeless public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - baseUseDir = player.itemRotation; - ClaretCooldown = ClaretCooldownMax; + baseUseDir = player.itemRotation; + player.GetModPlayer().ClaretCooldown = CooldownMax; + Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI); return false; } public override void PostDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) { - float fill = ClaretCooldown / (float)ClaretCooldownMax; + int currentCooldown = Main.LocalPlayer.GetModPlayer().ClaretCooldown; + float fill = currentCooldown / (float)CooldownMax; + if (fill <= 0) return; diff --git a/Items/Weapons/Typeless/RelicOfDeliverance.cs b/Items/Weapons/Typeless/RelicOfDeliverance.cs index 52a8e2e512..8dd3c542b9 100644 --- a/Items/Weapons/Typeless/RelicOfDeliverance.cs +++ b/Items/Weapons/Typeless/RelicOfDeliverance.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Typeless; +using CalamityMod.CalPlayer.Dashes; +using CalamityMod.Projectiles.Typeless; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -40,6 +41,6 @@ namespace CalamityMod.Items.Weapons.Typeless // Terraria seems to really dislike high crit values in SetDefaults public override void ModifyWeaponCrit(Player player, ref float crit) => crit += 55; - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0 && player.Calamity().DashID != GodslayerArmorDash.ID; } } diff --git a/Localization/en-US/Mods.CalamityMod.Buffs.hjson b/Localization/en-US/Mods.CalamityMod.Buffs.hjson index 8a6d3c9d39..ea53971c54 100644 --- a/Localization/en-US/Mods.CalamityMod.Buffs.hjson +++ b/Localization/en-US/Mods.CalamityMod.Buffs.hjson @@ -252,12 +252,22 @@ Plague: { SagePoison: { DisplayName: Sage Poison Description: Poisoned - ItemTooltip: Sickness - DPS scales with summoned Viral Sprout amount + ItemTooltip: + ''' + Sickness - 25 DPS per Viral Sprout / 50 DPS per Virid Vanguard + Ignores 75% of enemy sickness weaknesses and resistances + ''' } SearingLava: { DisplayName: Searing Lava Description: The brimstone lava sears your flesh + ItemTooltip: + ''' + Heat - 20 DPS + Ignores enemy heat weaknesses and resistances + Gains double effect from Heat debuff amplifiers + ''' } ShellfishClaps: { diff --git a/Localization/en-US/Mods.CalamityMod.Configs.hjson b/Localization/en-US/Mods.CalamityMod.Configs.hjson index 36f44ed057..e4eb0c04ad 100644 --- a/Localization/en-US/Mods.CalamityMod.Configs.hjson +++ b/Localization/en-US/Mods.CalamityMod.Configs.hjson @@ -54,8 +54,8 @@ CalamityClientConfig: { Label: "[i:CalamityMod/DraedonPowerCell] Display Charge Meter" Tooltip: ''' - Enables the Charge Meter UI, which displays the current charge of the player's held weapon. - The Charge Meter is always hidden if not holding a weapon which requires charge. + Enables the Charge Meter UI, which displays the current charge of the player's held item. + The Charge Meter is always hidden if not holding an item which requires charge. ''' } @@ -536,15 +536,6 @@ CalamityServerConfig: { ''' } - SimplifyAccessoryReforge: { - Label: "[i:Autohammer] Simplify Accessory Reforging" - Tooltip: - ''' - Makes accessory reforging simpler by restricting options to the following prefixes: - - Warding, Menacing, Lucky, Quick, Violent, Arcane, Silent, Invigorating, Dauntless - ''' - } - TownNPCSpawnRateMultiplier: { Label: "[i:GuideVoodooDoll] Town NPC Spawn Rate Multiplier" Tooltip: diff --git a/Localization/en-US/Mods.CalamityMod.GameTips.hjson b/Localization/en-US/Mods.CalamityMod.GameTips.hjson index d9a4d5bfa2..43ad156217 100644 --- a/Localization/en-US/Mods.CalamityMod.GameTips.hjson +++ b/Localization/en-US/Mods.CalamityMod.GameTips.hjson @@ -13,7 +13,6 @@ BossEnemyTip: Killing the most harmless of enemies can awaken the wrath of a muc RoDAbyssTip: Use the Rod of Discord in the Abyss at your own risk. The light left behind may attract the attention of unwanted foes. TerminusTip: An ancient artifact resides at the bottom of the Abyss. Use with great caution. CodebreakerTip: The Codebreaker can be upgraded, allowing you to decrypt new schematics found in various labs around the world. -ChargeTip: Certain weaponry requires charge to use. Weapons can be charged at a Charging Station with Draedon Power Cells. PowerCellTip: Power Cell Factories generate Draedon Power Cells over time. FactoryChargingTip: Power Cell Factories and Charging Stations can be looted from labs in the Underground. StealthTip: Wearing any rogue class armor lets you build stealth! diff --git a/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson b/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson index 4363d3fd29..c5b05e4e5c 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson @@ -13,7 +13,6 @@ AbyssalDivingGear: { Tooltip: ''' Reduces the damage caused by the pressure of the abyss while out of breath - Removes the bleed effect caused by the abyss Grants the ability to swim and greatly extends underwater breathing Provides light underwater and extra mobility on ice Provides a moderate amount of light and reduces breath loss in the abyss @@ -632,7 +631,7 @@ DynamoStemCells: { ''' 10% increased ranged damage and movement speed Ranged weapons fire a powerful mini swarmer every 3 seconds - Reduces damage taken from Dragonfire and Electrified + Reduces damage taken from Dragonfire ''' } @@ -1089,7 +1088,7 @@ ManaPolarizer: { Increases max mana by 50 Provides life regeneration and magic damage that scales based on how much mana you have Lower mana means more life regeneration, but less magic damage - These scale from -2 to 2 HP/sec, and 15% to 5% damage + These scale from -2 to +2 HP/s, and 15% to 5% damage The provided regeneration is halved when under Mana Sickness Magic projectiles steal enemy life while holding a magic weapon ''' @@ -1526,10 +1525,11 @@ ScionsCurio: { DisplayName: Scions Curio Tooltip: ''' - Ranged hits increase the effectiveness of the Irradiated debuff - Irradiated damage over time scales off of your ranged damage and crit chance - On kill, enemies burst, spreading Irradiated + Ranged hits increase the effectiveness of [cbuff:CalamityMod/Irradiated] + [cbuff:CalamityMod/Irradiated] damage over time scales off of your ranged damage and crit chance + On kill, enemies burst, spreading [cbuff:CalamityMod/Irradiated] Taking damage causes the curio to explode in retaliation + Current [cbuff:CalamityMod/Irradiated] damage: [DAMAGE] ''' } @@ -1851,7 +1851,7 @@ TheAmalgam: { DisplayName: The Amalgam Tooltip: ''' - All attacks inflict a variety of debuffs, 300% increased elemental debuff damage + All attacks inflict a variety of debuffs, 200% increased elemental debuff damage Most buffs last twice as long, and persist after dying Taking damage confuses nearby enemies and spawns a dank creeper The dank creeper flies above you, exploding into several shaderain clouds diff --git a/Localization/en-US/Mods.CalamityMod.Items.Armor.PreHardmode.hjson b/Localization/en-US/Mods.CalamityMod.Items.Armor.PreHardmode.hjson index 2ff879d8a9..257ae19f9b 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Armor.PreHardmode.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Armor.PreHardmode.hjson @@ -123,12 +123,12 @@ SnowRuffianChestplate: { SnowRuffianGreaves: { DisplayName: Snow Ruffian Greaves - Tooltip: "{$CommonItemTooltip.PercentIncreasedRangedCritChance}" + Tooltip: "{$CommonItemTooltip.PercentIncreasedRangedDamage}" } SnowRuffianMask: { DisplayName: Snow Ruffian Mask - Tooltip: "{$CommonItemTooltip.PercentIncreasedRangedCritChance}" + Tooltip: "{$CommonItemTooltip.PercentIncreasedRangedDamage}" SetBonus: ''' You can glide to negate fall damage diff --git a/Localization/en-US/Mods.CalamityMod.Items.Potions.hjson b/Localization/en-US/Mods.CalamityMod.Items.Potions.hjson index 0a1e84e98d..a4c20d91d5 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Potions.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Potions.hjson @@ -272,7 +272,7 @@ Moonshine: { ''' Increases maximum health by {0}% Attacks always take at least half your defense worth of defense damage - Defense damage takes twice as long to recover + Defense damage takes three times as long to recover {$Common.AlcoholWarning} ''' } diff --git a/Localization/en-US/Mods.CalamityMod.Items.SummonItems.hjson b/Localization/en-US/Mods.CalamityMod.Items.SummonItems.hjson index 7b5ef7a2e5..52b51c52c4 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.SummonItems.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.SummonItems.hjson @@ -286,7 +286,7 @@ Teratoma: { Terminus: { DisplayName: Terminus GFBName: Ogscule - Tooltip: Activates Boss Rush Mode, using it again will deactivate Boss Rush Mode + Tooltip: Hold to start or end the Boss Rush } YharonEgg: { diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson index 81ea619ba7..6cf7ba760c 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson @@ -611,11 +611,7 @@ PhoenixFlameBarrage: { Photosynthesis: { DisplayName: Photosynthesis - Tooltip: - ''' - Casts a brilliant ray that dissolves into energy on enemy hits - More energy is created the farther along the ray the hit enemy is - ''' + Tooltip: Casts a brilliant ray that dissolves into energy on enemy hits } PlagueStaff: { diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Melee.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Melee.hjson index bae7ba243a..b6cda13b99 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Melee.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Melee.hjson @@ -629,7 +629,7 @@ GalileoGladius: { GeliticBlade: { DisplayName: Gelitic Blade - Tooltip: Fires a gel wave that slows down on enemy hits + Tooltip: Fires a fast gel wave that speeds up on enemy hits } GildedProboscis: { diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson index 7bd2ed8f9a..0069c9a801 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson @@ -61,7 +61,7 @@ AntiMaterielRifle: { Tooltip: ''' Converts musket balls into .50 caliber sniper rounds that rip apart enemy defense and DR - Critical hits unleash a second swarm of 5 bullets + Unleashes a second swarm of bullets on hit, with additional bullets on critical strikes ''' } @@ -1128,8 +1128,8 @@ SlagfireDouser: { DisplayName: Slagfire Douser Tooltip: ''' - Lobs armor-penetrating lava in bursts - Armor-penetrating lava ignores 10 points of enemy defense + Sprays bursts of molten pollen + Molten pollen ignores 10 points of enemy defense and inflicts [cbuff:CalamityMod/SearingLava] [c/FF9900:Capable of dousing townsfolk in lava too...] ''' } @@ -1321,7 +1321,7 @@ TelluricGlare: { Tooltip: ''' Rapidly fires volleys of arrows - Every other arrow is converted into radiant greatarrows which pierce but quicky dissapear after striking + Every other arrow is converted into radiant greatarrows which pierce but quicky disappear after striking Wooden arrows are converted into more powerful greatarrows that deal increased damage ''' } diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Rogue.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Rogue.hjson index b7269813df..99c38ebcf7 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Rogue.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Rogue.hjson @@ -786,9 +786,13 @@ NanoblackReaper: { DisplayName: Nanoblack Reaper Tooltip: ''' - Unleashes a storm of nanoblack energy blades - Blades target bosses whenever possible - Stealth strikes cause the scythe to create a large amount of homing afterimages instead of energy blades + Throws a scythe which rapidly forms a swarm of nanoblack tesselations from hard light + Nanoblack tesselations each emit an instantaneous zero-point energy strike + Zero-point energy strikes have 150 armor penetration and will target bosses whenever possible + Release just as the scythe begins returning to carve through the enemy closest to your cursor at light speed + Light-speed carves have 150 armor penetration. If timed in a 4-frame window, they supercrit with +100% critical strike chance + with sufficient stealth to massively increase attack speed for a short time + Scythes thrown during flurries emit supercharged energy strikes but cannot be returned manually ''' HoldShiftTooltip: ''' @@ -977,8 +981,7 @@ ScourgeoftheSeas: { SeafoamBomb: { DisplayName: Seafoam Bomb - Tooltip: "[GFB]" - TooltipNormal: + Tooltip: ''' Throws a bomb that explodes into a bubble which deals extra damage to enemies Stealth strikes are faster and explode into 5 bubbles @@ -1127,7 +1130,7 @@ StellarKnife: { DisplayName: Stellar Knife Tooltip: ''' - Throws knives that stop middair and then home into enemies, inflicting [cbuff:CalamityMod/AstralInfectionDebuff] + Throws knives that stop midair and then home into enemies, inflicting [cbuff:CalamityMod/AstralInfectionDebuff] Stealth strikes throw a volley of 10 knives in a spread 'ZA WARUDO' ''' diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson index 75a9314eb4..cb52aafc42 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson @@ -337,7 +337,7 @@ Endogenesis: { Changes attack modes by resummoning or reusing the staff The first mode makes it shoot sweeping lasers aimed at the enemy The second mode sacrifices its limbs to shoot out homing projectiles - The third mode allows it to agressively tackle its enemies + The third mode allows it to aggressively tackle its enemies The fourth mode makes the limbs function as endothermic flamethrowers Requires 10 minion slots to be summoned There can only be one construct at a time @@ -854,7 +854,7 @@ ViralSprout: { Tooltip: ''' Summons a sage spirit to fight for you - Inflicts Sage Poison, a debuff that becomes stronger the more spirits you own + Inflicts [cbuff:CalamityMod/SagePoison], a debuff that becomes stronger the more spirits you own ''' } @@ -865,7 +865,7 @@ ViridVanguard: { Alternates between summoning axes and swords, both laced with a powerful poison Axes orbit the player, dealing high damage at a close range Swords chase down enemies with extreme precision, tearing them to shreds - All weapons inflict Sage Poison, which becomes more powerful the more weapons are summoned + All weapons inflict [cbuff:CalamityMod/Sage Poison], which becomes more powerful the more weapons are summoned When all minion slots are full, again to spin up a flurry of slashes aimed at your cursor This ability has a five-second cooldown that requires holding this item Shift- this item in your inventory to change the rotation direction diff --git a/Localization/en-US/Mods.CalamityMod.Misc.hjson b/Localization/en-US/Mods.CalamityMod.Misc.hjson index 9390417a75..8d617226ec 100644 --- a/Localization/en-US/Mods.CalamityMod.Misc.hjson +++ b/Localization/en-US/Mods.CalamityMod.Misc.hjson @@ -48,7 +48,6 @@ AutocannonHot: OUCH! HOT! NoComputer: No decryption computer installed ArkParry: Parry! BurningSeaBurn: It burns... -LightsWarning: I've gotta give you a flashing lights warning on this one NotSafe: Y O U A R E N O T S A F E HecBoop: boop! ClockworkTick: Tick diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Boss.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Boss.hjson index c42cd49334..068ac73521 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Boss.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Boss.hjson @@ -23,6 +23,7 @@ BigFlare.DisplayName: Big Flare BigFlare2.DisplayName: Big Flare BirbAura.DisplayName: Draconic Aura BirbAuraFlare.DisplayName: Draconic Aura Flare +BloodBombRTS.DisplayName: Blood Bomb BloodGeyser.DisplayName: Blood Geyser BloodScythe.DisplayName: Blood Scythe BrimstoneBall.DisplayName: Brimstone Fireball diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Rogue.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Rogue.hjson index e35a4f3841..27b56d7629 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Rogue.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Rogue.hjson @@ -179,9 +179,16 @@ MoltenAmputatorProj.DisplayName: Molten Amputator MoonSigil.DisplayName: Moon Sigil MycorootProj.DisplayName: Mycoroot MythrilKnifeProjectile.DisplayName: Mythril Knife + +NanoblackLightspeedCarve: { + Perfect: Wrath of the Superluminae + Standard: Light-speed Carve +} + NanoblackMain.DisplayName: Nanoblack Reaper -NanoblackSplit.DisplayName: Nanoblack Blade -NanoblackStealthSplit.DisplayName: Nanoblack Afterimage +NanoblackPiercingStrike.DisplayName: Zero-Point Energy Strike +NanoblackStrike.DisplayName: Zero-Point Energy Strike +NanoblackTesselation.DisplayName: Nanoblack Tesselation NastyChollaBol.DisplayName: Nasty Cholla NastyChollaNeedle.DisplayName: Cactus Needle OrichalcumSpikedGemstoneProjectile.DisplayName: Orichalcum Gemstone @@ -327,3 +334,4 @@ WrathwingCinder.DisplayName: Wrathwing Eruption WrathwingFireball.DisplayName: Wrathwing Fireball WrathwingSpear.DisplayName: Wrathwing WulfrumKnifeProj.DisplayName: Wulfrum Knife +NanoblackLightspeedCarveSlashVisual.DisplayName: Nanoblack Light-speed Carve Visuals diff --git a/Localization/en-US/Mods.CalamityMod.Vanilla.hjson b/Localization/en-US/Mods.CalamityMod.Vanilla.hjson index cee11fbd9b..6d3948119d 100644 --- a/Localization/en-US/Mods.CalamityMod.Vanilla.hjson +++ b/Localization/en-US/Mods.CalamityMod.Vanilla.hjson @@ -147,8 +147,8 @@ EditedTooltip: { ApprenticeTrousers: 10% increased summon damage, 15% increased magic critical strike chance, 20% increased movement speed SquireGreatHelm: Increases your max number of sentries by 1 and grants +2 HP/s life regen SquireGreaves: 10% increased summon damage, 15% increased melee critical strike chance and movement speed - MonkBrows: Increases your max number of sentries by 1 and increases rogue velocity by 15% - MonkShirt: 15% increased summon and rogue damage + MonkBrows: Increases your max number of sentries by 1 and increases rogue velocity by 20% + MonkShirt: 20% increased summon and rogue damage MonkPants: 15% increased rogue critical strike chance and 20% increased movement speed // Valhalla Knight SquireAltShirt: 30% increased summon damage and grants +4 HP/s life regen @@ -156,7 +156,7 @@ EditedTooltip: { MonkAltHead: Increases your max number of sentries by 2 and increases summon & rogue damage by 20% MonkAltShirt0: 20% increased summon damage and rogue velocity MonkAltShirt1: 5% increased rogue critical strike chance - MonkAltPants: 10% increased summon damage and rogue critical strike chance + MonkAltPants: 20% increased summon damage and rogue critical strike chance /* Accessories */ diff --git a/ModSupport/WeakReferenceSupport.cs b/ModSupport/WeakReferenceSupport.cs index 0f2bf130da..0fcbeb04a1 100644 --- a/ModSupport/WeakReferenceSupport.cs +++ b/ModSupport/WeakReferenceSupport.cs @@ -180,9 +180,13 @@ namespace CalamityMod // { "Xeroc", 26f }, }; - public override void PostSetupContent() + public override void Load() { LavaStyleToBiomeLava(); + } + + public override void PostSetupContent() + { BossChecklistSupport(); FargosSupport(); DialogueTweakSupport(); @@ -214,7 +218,7 @@ namespace CalamityMod Func ModifyLightFunc = ModifyLight; Func IsLavaActive = lavaStyle.IsLavaActive; Func lavafallGlowmask = lavaStyle.LavafallGlowmask; - Func InflictDebuffFunc = InflictDebuff; + Action InflictDebuffFunc = InflictDebuff; Func yes = InflictsOnFire; Vector3 ModifyLight(int x, int y, float r, float g, float b) @@ -223,13 +227,12 @@ namespace CalamityMod return new Vector3(r, g, b); } - Action InflictDebuff(Player player, NPC npc, int onfireDuration) + void InflictDebuff(Player player, NPC npc, int onfireDuration) { if (player != null && npc == null) { lavaStyle.InflictDebuff(player, onfireDuration); } - return null; } bool InflictsOnFire() diff --git a/NPCs/BaseWormNPC.cs b/NPCs/BaseWormNPC.cs index 5d8c090d83..94fd866295 100644 --- a/NPCs/BaseWormNPC.cs +++ b/NPCs/BaseWormNPC.cs @@ -655,30 +655,6 @@ namespace CalamityMod.NPCs NPC.aiStyle = -1; } - public override bool? CanBeHitByItem(Player player, Item item) - { - if (!Main.npc.IndexInRange((int)NPC.ai[0])) - { - return base.CanBeHitByItem(player, item); - } - var canhit = Main.npc[(int)NPC.ai[0]].ModNPC.CanBeHitByItem(player, item); - if (canhit.HasValue && !canhit.Value) - return false; - return base.CanBeHitByItem(player, item); - } - - public override bool? CanBeHitByProjectile(Projectile projectile) - { - if (!Main.npc.IndexInRange((int)NPC.ai[0])) - { - return base.CanBeHitByProjectile(projectile); - } - var canhit = Main.npc[(int)NPC.ai[0]].ModNPC.CanBeHitByProjectile(projectile); - if (canhit.HasValue && !canhit.Value) - return false; - return base.CanBeHitByProjectile(projectile); - } - public override void AI() { var headNPC = Main.npc[(int)NPC.ai[0]]; diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index 294fa7d10b..a41d9d117e 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -874,11 +874,6 @@ namespace CalamityMod.NPCs { ActiveWaterDebuffMultiplier += 1; } - - if (npc.HasBuff()) //Searing Lava is so hot it makes cold less strong - { - ActiveColdDebuffMultiplier -= 0.5f; - } if (VulnerableToHeat.HasValue) { if (VulnerableToHeat.Value) diff --git a/NPCs/CalamityGlobalTownNPC.cs b/NPCs/CalamityGlobalTownNPC.cs index fb11fc4903..27fe43410d 100644 --- a/NPCs/CalamityGlobalTownNPC.cs +++ b/NPCs/CalamityGlobalTownNPC.cs @@ -115,6 +115,7 @@ namespace CalamityMod.NPCs "Storm Havik", // <@!1013452363178197072> (fishnotduck) "Magorfis Splunt the Greater Finklejim", // <@!147490809334333440> (eidolbyssus) "Perrin", // <@!253764551139393537> (easyperrin) + "Dorkyy", // <@!427765391662514185> (dorkblaze01) ]; private static readonly string[] CyborgNames = [ @@ -136,6 +137,7 @@ namespace CalamityMod.NPCs "Cybil", // <@!486507232666845185> (Captain Doofus#????) "Ruth", // <@!1001307586068492388> (briny_coffee) "Kanna", // <@!730203712898859018> (cosmoredeathwish) + "Elliada", // <@!865554691345874954> (cti971) ]; private static readonly string[] DyeTraderNames = null; private static readonly string[] GoblinTinkererNames = @@ -278,6 +280,7 @@ namespace CalamityMod.NPCs [ "Emmett", "Bagman", // <@!701831892990820383> (supportcrispy) + "Old Man Scrooge", // <@!1392141158255427655> (vortexgaming18) ]; private static readonly string[] TravelingMerchantNames = [ @@ -302,6 +305,7 @@ namespace CalamityMod.NPCs "Mixcoatl", // <@!284775927294984203> (.sharzz) "Amnesia Wapers", // <@!326821498323075073> (retardedadvicefromaretard) "Tequila", // <@!889175547744239677> (thecrispistofnuggets) + "Bee Movie Script", // <@!407949998173454341> (literally_jesuschrist) ]; private static readonly string[] WizardNames = [ @@ -325,6 +329,7 @@ namespace CalamityMod.NPCs "Fera", // <@!195850711567826945> (juneark_) "Gwenhwyvar", // <@!291342874497515531> (diamondnife) "Daxie", // <@!465438861103988737> (daxie626) + "Zora", // <@!752687500656640030> (oxytoxy365) ]; // Town Slimes private static readonly string[] ClumsySlimeNames = null; @@ -408,7 +413,7 @@ namespace CalamityMod.NPCs [ "Bear", // <@!183424826407518208> (lilac_vrt_olligoci) "Storm", // <@!620383533516718085> (airwaveslr) - "Hognar the Wicked", // <@!766511001356468237> (xzier_tengal) + "Hognar", // <@!766511001356468237> (xzier_tengal) "Saffie", // <@!319753595161411584> (CDMusic) "Willow", // <@!319753595161411584> (CDMusic) "Maine", // <@!731141759484297226> (trianglepixel) @@ -426,7 +431,6 @@ namespace CalamityMod.NPCs private static readonly string[] TownCatSilverNames = [ "Archie", // <@!303022375191183360> (jackshiz) - "Hognar the Wicked", // <@!766511001356468237> (xzier_tengal) ]; private static readonly string[] TownCatWhiteNames = null; @@ -1251,7 +1255,7 @@ namespace CalamityMod.NPCs if (type == NPCID.ArmsDealer) { - shop.AddWithCustomValue(ItemType(), Item.buyPrice(gold: 20), Condition.DownedSkeletron) + shop.Add(Condition.DownedSkeletron) .Add(Condition.Hardmode) .AddWithCustomValue(ItemID.Boomstick, Item.buyPrice(gold: 25), Condition.DownedQueenBee) .AddWithCustomValue(ItemID.Uzi, Item.buyPrice(gold: 50), Condition.DownedPlantera); diff --git a/NPCs/DevourerofGods/DevourerofGodsBody.cs b/NPCs/DevourerofGods/DevourerofGodsBody.cs index c6b3218cf8..96898e2192 100644 --- a/NPCs/DevourerofGods/DevourerofGodsBody.cs +++ b/NPCs/DevourerofGods/DevourerofGodsBody.cs @@ -250,6 +250,9 @@ namespace CalamityMod.NPCs.DevourerofGods NPC.Opacity = Main.npc[(int)NPC.ai[2]].Opacity; } + // Copy the damage state of the head + NPC.damage = Main.npc[(int)NPC.ai[2]].damage == 0 ? 0 : NPC.defDamage; + NPC aheadSegment = Main.npc[(int)NPC.ai[1]]; Vector2 directionToNextSegment = aheadSegment.Center - NPC.Center; if (aheadSegment.rotation != NPC.rotation) @@ -345,7 +348,6 @@ namespace CalamityMod.NPCs.DevourerofGods public override bool CanHitPlayer(Player target, ref int cooldownSlot) { - if (Main.npc[(int)NPC.ai[2]].dontTakeDamage) return false; cooldownSlot = ImmunityCooldownID.Bosses; diff --git a/NPCs/DevourerofGods/DevourerofGodsHead.cs b/NPCs/DevourerofGods/DevourerofGodsHead.cs index 352bf5c3c0..9b1d42e7e7 100644 --- a/NPCs/DevourerofGods/DevourerofGodsHead.cs +++ b/NPCs/DevourerofGods/DevourerofGodsHead.cs @@ -278,7 +278,7 @@ namespace CalamityMod.NPCs.DevourerofGods NPC.velocity = new Vector2(60, 0); if (Main.zenithWorld) NPC.scale *= 1.5f; - if (Main.getGoodWorld) + if (Main.zenithWorld) NPC.takenDamageMultiplier = 2; @@ -798,6 +798,8 @@ namespace CalamityMod.NPCs.DevourerofGods if (NPC.Opacity >= 1f) { + // Don't do contact damage while flying away after laser walls + NPC.damage = 0; NPC.Opacity = 1f; laserWallPhase = (int)LaserWallPhase.SetUp; @@ -2289,6 +2291,11 @@ namespace CalamityMod.NPCs.DevourerofGods { NPC.ai[3] = 4; NPC.SimpleStrikeNPC(10000, 1); + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int bType = Main.rand.Next(0, 2); + Projectile.NewProjectile(NPC.GetSource_FromAI(), player.Center + Main.rand.NextVector2CircularEdge(600, 600), Vector2.Zero, ModContent.ProjectileType(), LaserWallDamage, 0, Main.myPlayer, 0.45f, 300, bType); + } } } else @@ -2299,6 +2306,7 @@ namespace CalamityMod.NPCs.DevourerofGods AwaitingPhase2Teleport = false; NPC.Opacity = 1f - (postTeleportTimer / 255f); NPC.velocity = Vector2.Normalize(AdjustedPlayerCenter(10) - NPC.Center) * chargeVelocity; + NPC.damage = NPC.defDamage; NPC.ForceNetUpdate(false); NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X) + MathHelper.PiOver2; foreach (NPC n in Main.ActiveNPCs) diff --git a/NPCs/DevourerofGods/DevourerofGodsTail.cs b/NPCs/DevourerofGods/DevourerofGodsTail.cs index b420b42454..76374999e1 100644 --- a/NPCs/DevourerofGods/DevourerofGodsTail.cs +++ b/NPCs/DevourerofGods/DevourerofGodsTail.cs @@ -152,7 +152,6 @@ namespace CalamityMod.NPCs.DevourerofGods NPC.life = Main.npc[(int)NPC.ai[2]].life; NPC.lifeMax = Main.npc[(int)NPC.ai[2]].lifeMax; - // Percent life remaining float lifeRatio = Main.npc[(int)NPC.ai[2]].life / (float)Main.npc[(int)NPC.ai[2]].lifeMax; @@ -249,6 +248,9 @@ namespace CalamityMod.NPCs.DevourerofGods NPC.Opacity = Main.npc[(int)NPC.ai[2]].Opacity; } + // Copy the damage state of the head + NPC.damage = Main.npc[(int)NPC.ai[2]].damage == 0 ? 0 : NPC.defDamage; + Vector2 segmentDirection = NPC.Center; float playerXDist = player.position.X + (player.width / 2); float playerYDist = player.position.Y + (player.height / 2); diff --git a/NPCs/DraedonLabThings/Androomba.cs b/NPCs/DraedonLabThings/Androomba.cs index 0685a9f629..fc60264b5f 100644 --- a/NPCs/DraedonLabThings/Androomba.cs +++ b/NPCs/DraedonLabThings/Androomba.cs @@ -151,13 +151,10 @@ namespace CalamityMod.NPCs.DraedonLabThings break; } - foreach (Player player in Main.ActivePlayers) + // Force bestiary unlock + if (Main.netMode != NetmodeID.MultiplayerClient && Main.BestiaryTracker.Kills.GetKillCount(NPC) <= 0) { - if (NPC.Hitbox.Intersects(player.HitboxForBestiaryNearbyCheck)) - { - Main.BestiaryTracker.Kills.RegisterKill(NPC); - break; - } + Main.BestiaryTracker.Kills.RegisterKill(NPC); } } diff --git a/NPCs/DraedonLabThings/RepairUnitCritter.cs b/NPCs/DraedonLabThings/RepairUnitCritter.cs index f523b8cf1c..4aebb02ae2 100644 --- a/NPCs/DraedonLabThings/RepairUnitCritter.cs +++ b/NPCs/DraedonLabThings/RepairUnitCritter.cs @@ -137,13 +137,10 @@ namespace CalamityMod.NPCs.DraedonLabThings } Time++; - foreach (Player player in Main.ActivePlayers) + // Force bestiary unlock + if (Main.netMode != NetmodeID.MultiplayerClient && Main.BestiaryTracker.Kills.GetKillCount(NPC) <= 0) { - if (NPC.Hitbox.Intersects(player.HitboxForBestiaryNearbyCheck)) - { - Main.BestiaryTracker.Kills.RegisterKill(NPC); - break; - } + Main.BestiaryTracker.Kills.RegisterKill(NPC); } } public override bool? CanFallThroughPlatforms() => CurrentState == BehaviorState.WalkOnWalls; diff --git a/NPCs/NormalNPCs/Piggy.cs b/NPCs/NormalNPCs/Piggy.cs index 9782a5d91d..d0df599e78 100644 --- a/NPCs/NormalNPCs/Piggy.cs +++ b/NPCs/NormalNPCs/Piggy.cs @@ -46,19 +46,10 @@ namespace CalamityMod.NPCs.NormalNPCs public override void AI() { - for (int i = 0; i < Main.maxPlayers; i++) + // Force bestiary unlock + if (Main.netMode != NetmodeID.MultiplayerClient && Main.BestiaryTracker.Kills.GetKillCount(NPC) <= 0) { - Player player = Main.player[i]; - if (player is null || !player.active) - continue; - - if (NPC.Hitbox.Intersects(player.HitboxForBestiaryNearbyCheck)) - { - NPC nPC = new NPC(); - nPC.SetDefaults(ModContent.NPCType()); - Main.BestiaryTracker.Kills.RegisterKill(nPC); - break; - } + Main.BestiaryTracker.Kills.RegisterKill(NPC); } } diff --git a/NPCs/NormalNPCs/Shroomble.cs b/NPCs/NormalNPCs/Shroomble.cs index 2b1abdee1b..3dd653a19f 100644 --- a/NPCs/NormalNPCs/Shroomble.cs +++ b/NPCs/NormalNPCs/Shroomble.cs @@ -49,18 +49,12 @@ namespace CalamityMod.NPCs.NormalNPCs public override void AI() { - for (int i = 0; i < Main.maxPlayers; i++) + // Force bestiary unlock + if (Main.netMode != NetmodeID.MultiplayerClient && Main.BestiaryTracker.Kills.GetKillCount(NPC) <= 0) { - Player player = Main.player[i]; - if (player is null || !player.active) - continue; - - if (NPC.Hitbox.Intersects(player.HitboxForBestiaryNearbyCheck)) - { - Main.BestiaryTracker.Kills.RegisterKill(NPC); - break; - } + Main.BestiaryTracker.Kills.RegisterKill(NPC); } + bool walking = NPC.ai[0] == 1; // Do a cute lil' hop randomly int jumpChance = walking ? 600 : 100; diff --git a/NPCs/OldDuke/OldDuke.cs b/NPCs/OldDuke/OldDuke.cs index bacd9e74db..6ed76faa1a 100644 --- a/NPCs/OldDuke/OldDuke.cs +++ b/NPCs/OldDuke/OldDuke.cs @@ -617,6 +617,8 @@ namespace CalamityMod.NPCs.OldDuke CalamityUtils.AddScreenshakeAt(NPC.Center, 14); SoundEngine.PlaySound(SoundID.DD2_BetsyFlameBreath.WithPitchOffset(-0.5f), NPC.Center); SoundEngine.PlaySound(DashSoundP3, NPC.Center); + if (Main.netMode != NetmodeID.MultiplayerClient) + CalamityUtils.BossAwakenMessage(NPC.whoAmI); } if (NPC.ai[2] >= 75f) diff --git a/NPCs/Polterghast/PolterPhantom.cs b/NPCs/Polterghast/PolterPhantom.cs index d1e74b8527..0ec70ed981 100644 --- a/NPCs/Polterghast/PolterPhantom.cs +++ b/NPCs/Polterghast/PolterPhantom.cs @@ -171,6 +171,9 @@ namespace CalamityMod.NPCs.Polterghast acceleration += revenge ? 0.035f : 0.025f; } + // Reset contact damage every frame + NPC.damage = NPC.defDamage; + // Predictiveness Vector2 lookAt = player.Center; Vector2 rotationVector = lookAt - vector; @@ -337,6 +340,9 @@ namespace CalamityMod.NPCs.Polterghast } else { + // Do not deal damage during movement to avoid cheap bullshit + NPC.damage = 0; + // Random location choice if (NPC.ai[0] == 0f) { diff --git a/NPCs/SulphurousSea/AquaticUrchin.cs b/NPCs/SulphurousSea/AquaticUrchin.cs index f794e7757a..a9eaf54c9e 100644 --- a/NPCs/SulphurousSea/AquaticUrchin.cs +++ b/NPCs/SulphurousSea/AquaticUrchin.cs @@ -139,7 +139,7 @@ namespace CalamityMod.NPCs.SulphurousSea return 0f; if ((spawnInfo.Player.Calamity().ZoneSulphur || spawnInfo.Player.Calamity().ZoneAbyssLayer1) && spawnInfo.Water && NPC.CountNPCS(ModContent.NPCType()) < 12) - return 2.2f; + return 1f; return 0f; } diff --git a/NPCs/SulphurousSea/Gnasher.cs b/NPCs/SulphurousSea/Gnasher.cs index 893ea62786..2d654e6152 100644 --- a/NPCs/SulphurousSea/Gnasher.cs +++ b/NPCs/SulphurousSea/Gnasher.cs @@ -5,7 +5,6 @@ using CalamityMod.Items.Placeables.Banners; using CalamityMod.Items.Weapons.Rogue; using CalamityMod.NPCs.NormalNPCs; using CalamityMod.World; -using Microsoft.Xna.Framework; using Terraria; using Terraria.GameContent.Bestiary; using Terraria.ID; @@ -27,19 +26,16 @@ namespace CalamityMod.NPCs.SulphurousSea public override void SetDefaults() { - NPC.noGravity = true; NPC.damage = 25; NPC.width = 50; NPC.height = 36; NPC.defense = 30; NPC.lifeMax = 50; - NPC.knockBackResist = 0.25f; - NPC.aiStyle = -1; - AIType = -1; + NPC.aiStyle = NPCAIStyleID.Fighter; + AIType = NPCID.Crab; NPC.value = Item.buyPrice(copper: 60); NPC.HitSound = SoundID.NPCHit50; NPC.DeathSound = SoundID.NPCDeath54; - NPC.chaseable = false; Banner = NPC.type; BannerItem = ModContent.ItemType(); NPC.Calamity().VulnerableToHeat = false; @@ -57,94 +53,55 @@ namespace CalamityMod.NPCs.SulphurousSea }); } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(NPC.chaseable); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - NPC.chaseable = reader.ReadBoolean(); - } - public override void AI() { - float detectRange = Main.player[NPC.target].Calamity().GetAbyssAggro(120f); - - if (NPC.wet) + NPC.spriteDirection = (NPC.direction > 0) ? -1 : 1; + float targetDist = (Main.player[NPC.target].Center - NPC.Center).Length(); + targetDist *= 0.0025f; + if ((double)targetDist > 1.5) { - CalamityRegularEnemyAI.PassiveSwimmingAI(NPC, Mod, 0, detectRange, 0.15f, 0.1f, 6f, 4f, 0.1f, false); + targetDist = 1.5f; + } + float maxVelocity; + if (Main.expertMode) + { + maxVelocity = 2.5f - targetDist; } else { - NPC.noGravity = false; - - if (NPC.justHit || (!Main.player[NPC.target].dead && (Main.player[NPC.target].Center - NPC.Center).Length() < detectRange && Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height))) - NPC.chaseable = true; - - float deceleration = 0.8f; - - if (NPC.chaseable && Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[NPC.target].position, Main.player[NPC.target].width, Main.player[NPC.target].height) && !Main.player[NPC.target].dead) + maxVelocity = 2.25f - targetDist; + } + maxVelocity *= (CalamityWorld.death ? 1.2f : CalamityWorld.revenge ? 1f : 0.8f); + if (NPC.velocity.X < -maxVelocity || NPC.velocity.X > maxVelocity) + { + if (NPC.velocity.Y == 0f) { - NPC.TargetClosest(); - - NPC.spriteDirection = (NPC.direction > 0) ? -1 : 1; - - float distanceFromTarget = MathHelper.Clamp((Main.player[NPC.target].Center - NPC.Center).Length() * 0.0025f, 0f, 1.5f); - float velocityMultiplier = CalamityWorld.death ? 1.2f : CalamityWorld.revenge ? 1f : 0.8f; - float maxVelocity = ((Main.expertMode ? 2.5f : 2.25f) - distanceFromTarget) * velocityMultiplier; - float accelerationX = CalamityWorld.death ? 0.7f : CalamityWorld.revenge ? 0.6f : 0.5f; - - if (NPC.velocity.X < -maxVelocity || NPC.velocity.X > maxVelocity) - { - if (NPC.velocity.Y == 0f) - NPC.velocity *= deceleration; - } - else if (NPC.velocity.X < maxVelocity && NPC.direction == 1) - { - NPC.velocity.X += accelerationX; - if (NPC.velocity.X > maxVelocity) - NPC.velocity.X = maxVelocity; - } - else if (NPC.velocity.X > -maxVelocity && NPC.direction == -1) - { - NPC.velocity.X -= accelerationX; - if (NPC.velocity.X < -maxVelocity) - NPC.velocity.X = -maxVelocity; - } + NPC.velocity *= 0.8f; } - else + } + else if (NPC.velocity.X < maxVelocity && NPC.direction == 1) + { + NPC.velocity.X = NPC.velocity.X + 1f; + if (NPC.velocity.X > maxVelocity) { - NPC.TargetClosest(false); - - if (NPC.velocity != Vector2.Zero) - { - NPC.velocity *= deceleration; - if (NPC.velocity.Length() < 0.1f) - NPC.velocity = Vector2.Zero; - } + NPC.velocity.X = maxVelocity; + } + } + else if (NPC.velocity.X > -maxVelocity && NPC.direction == -1) + { + NPC.velocity.X = NPC.velocity.X - 1f; + if (NPC.velocity.X < -maxVelocity) + { + NPC.velocity.X = -maxVelocity; } } - } - - public override bool? CanBeHitByProjectile(Projectile projectile) - { - if (projectile.minion && !projectile.Calamity().overridesMinionDamagePrevention) - return NPC.chaseable; - - return null; } public override void FindFrame(int frameHeight) { - if (NPC.velocity == Vector2.Zero) - { - NPC.frame.Y = 0; - return; - } - - NPC.frameCounter += NPC.chaseable ? 0.15f : 0.075f; - NPC.frameCounter %= Main.npcFrameCount[Type]; + NPC.frameCounter += 0.15f; + NPC.frameCounter %= Main.npcFrameCount[NPC.type]; + NPC.frameCounter %= Main.npcFrameCount[NPC.type]; int frame = (int)NPC.frameCounter; NPC.frame.Y = frame * frameHeight; } @@ -160,8 +117,8 @@ namespace CalamityMod.NPCs.SulphurousSea if (spawnInfo.PlayerSafe) return 0f; - if (spawnInfo.Player.Calamity().ZoneSulphur && spawnInfo.Water) - return 0.2f; + if (spawnInfo.Player.Calamity().ZoneSulphur) + return 0.1f; return 0f; } diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhu/BrainOfCthulhuAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhu/BrainOfCthulhuAI.cs index 5ff62a5b08..35fc92c954 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhu/BrainOfCthulhuAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhu/BrainOfCthulhuAI.cs @@ -41,6 +41,7 @@ public class BrainOfCthulhuAI : VanillaAIOverride private static SoundStyle Growl = new SoundStyle("CalamityMod/Sounds/Custom/BrainOfCthulhu/BoC_Rev_Growl", 2) with { PauseBehavior = PauseBehavior.PauseWithGame }; private static SoundStyle Death = new SoundStyle("CalamityMod/Sounds/Custom/BrainOfCthulhu/BoC_Rev_Death_Roar") with { PauseBehavior = PauseBehavior.PauseWithGame }; private static SoundStyle BloodShot = new SoundStyle("CalamityMod/Sounds/Custom/BrainOfCthulhu/BoC_Rev_BloodShot"); + private static SoundStyle BloodBomb = new SoundStyle("CalamityMod/Sounds/Custom/BrainOfCthulhu/BoC_Rev_BloodBomb"); private static SoundStyle BloodExplosion = new SoundStyle("CalamityMod/Sounds/Custom/BrainOfCthulhu/BoC_Rev_Explosion", 2); @@ -151,9 +152,9 @@ public class BrainOfCthulhuAI : VanillaAIOverride #region Bloodletting internal static int BloodlettingDuration => 675; - internal static Vector2 HoverDistance => new (420f, 270f); + internal static Vector2 HoverDistance => new (420f, 300f); internal static float HoverEndHeight => 300f; - internal static int IchorRate => CalamityWorld.death ? 9 : 10; + internal static int IchorRate => CalamityWorld.death ? 10 : 12; internal static float IchorSpread => 1.5f; internal static float IchorVelocity => 3f; internal static int BloodshotRate => 90; @@ -355,10 +356,7 @@ public class BrainOfCthulhuAI : VanillaAIOverride else NPC.defense = (int)(NPC.defDefense * Phase1DefenseMultiplier); - if (AIState <= BrainAIState.SurfaceSpawnAnimation) - NPC.damage = 0; - else - NPC.damage = NPC.defDamage; + NPC.extraValue = 0; #region Targeting if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) @@ -559,6 +557,11 @@ public class BrainOfCthulhuAI : VanillaAIOverride private void SpawnAnimation() { + NPC.damage = 0; + + foreach (Player p in Main.ActivePlayers) + p.Calamity().adrenaline = 0; + if (SpawnTime != 0) //BoC should begin appearing { float d = Main.LocalPlayer.DistanceSQ(NPC.Center); @@ -638,6 +641,7 @@ public class BrainOfCthulhuAI : VanillaAIOverride BrainOfCthulhuSystem.ScreenBlurStrength = 0f; BoCDrawOffset = Vector2.Zero; AIState = BrainAIState.Phase1Idle; + NPC.damage = NPC.defDamage; ResetAttackValues(); Time = -1; SpawnTime = -1; @@ -1041,6 +1045,7 @@ public class BrainOfCthulhuAI : VanillaAIOverride BrainOfCthulhuSystem.ScreenBlurStrength = 0f; NPC.dontTakeDamage = false; + NPC.damage = 0; if (Time <= 15) { @@ -1108,6 +1113,7 @@ public class BrainOfCthulhuAI : VanillaAIOverride OnSecondCreeperPhase = true; AIState = BrainAIState.Phase1Idle; Time = -1; + NPC.damage = NPC.defDamage; } else if (AttackCounter > -1 && wrappedCounter == 0) { @@ -1304,7 +1310,7 @@ public class BrainOfCthulhuAI : VanillaAIOverride NPC.velocity = NPC.DirectionTo(goalPos).SafeNormalize(Vector2.UnitX * -Target.direction) * 8f; #endregion - float delay = OnSecondCreeperPhase ? StrongSwipeDelay : LightSwipeDelay; + int delay = OnSecondCreeperPhase ? StrongSwipeDelay : LightSwipeDelay; if (Time == 0) AttackList.Clear(); @@ -1325,9 +1331,9 @@ public class BrainOfCthulhuAI : VanillaAIOverride crushCount = StrongSwipeAmount; attackDelay = StrongSwipeDuration; } - int attackDur = attackDelay * crushCount; + int attackDur = delay + ((attackDelay + 1) * crushCount); - if (Time < delay + attackDur && Time % attackDelay == 0) + if (Time < attackDur && Time % attackDelay == 0) { List creepers = Main.npc.Where(n => n.active && n.type == NPCID.Creeper && n.AIOverride().Time == -1 && !AttackList.Contains((byte)n.whoAmI)).ToList(); if (creepers.Count > 1 && Main.netMode != NetmodeID.MultiplayerClient) @@ -1369,7 +1375,7 @@ public class BrainOfCthulhuAI : VanillaAIOverride } } - if (Time > delay + attackDur + attackDelay) + if (Time > attackDur + attackDelay) { Time = 0; NPC.damage = NPC.defDamage; @@ -1395,6 +1401,7 @@ public class BrainOfCthulhuAI : VanillaAIOverride { AttackSign = Main.rand.NextBool() ? -1 : 1; AttackPosition = Target.Center; + AttackList.Clear(); NPC.netUpdate = true; NPC.damage = 0; @@ -1555,6 +1562,7 @@ public class BrainOfCthulhuAI : VanillaAIOverride NPC.dontTakeDamage = true; NPC.rotation *= 0.9f; TeleportTime = 0; + NPC.damage = 0; float animCounter = Time - 60; if (animCounter >= 0) @@ -1620,6 +1628,7 @@ public class BrainOfCthulhuAI : VanillaAIOverride ResetAttackValues(); AIState = BrainAIState.Phase2Idle; NPC.dontTakeDamage = false; + NPC.damage = NPC.defDamage; } } else @@ -1655,6 +1664,7 @@ public class BrainOfCthulhuAI : VanillaAIOverride if (Time <= ChaseTime) { + NPC.damage = NPC.defDamage; float speedUp = MathHelper.Clamp((Time - 10) / 10f, 0f, 1f); float slowDown = 1 - MathHelper.Clamp((Time - (ChaseTime - 15)) / 15f, 0f, 1f); float angleChange = MathHelper.Lerp(MathHelper.Pi / 24f, 0f, MathHelper.Clamp(Time / (ChaseTime * 0.666f), 0f, 1f)); @@ -1667,6 +1677,7 @@ public class BrainOfCthulhuAI : VanillaAIOverride Vector2 direction = Target.velocity.SafeNormalize(Vector2.UnitX * Target.direction).RotatedBy(Main.rand.NextFloat(-MathHelper.Pi / 3f, MathHelper.Pi / 3f)); AttackPosition = Target.Center + (direction * DefaultTeleportDistance); BoCAfterImages = []; + NPC.damage = 0; NPC.netUpdate = true; } else @@ -1678,6 +1689,7 @@ public class BrainOfCthulhuAI : VanillaAIOverride else { TeleportDuration = IdleTeleportDuration; + NPC.damage = 0; Vector2 endPoint = AttackPosition; @@ -1707,6 +1719,7 @@ public class BrainOfCthulhuAI : VanillaAIOverride else if (Time == ChaseTime + (TeleportDuration / 2f) && !AttackFlag) { NPC.Center = endPoint; + NPC.damage = NPC.defDamage; DisableMultiplayerSmoothing = true; AttackFlag = true; NPC.netUpdate = true; @@ -1854,7 +1867,7 @@ public class BrainOfCthulhuAI : VanillaAIOverride else if (endTime < DashPrepTime) { if (endTime == 0) - NPC.velocity = Vector2.UnitX * AttackSign * 8f; + NPC.velocity = Vector2.UnitX * AttackSign * 10f; else { Vector2 goalPos = Target.Center - Vector2.UnitY * HoverEndHeight; @@ -1878,20 +1891,29 @@ public class BrainOfCthulhuAI : VanillaAIOverride { if (Time % IchorRate == 0) { - if (Time % (IchorRate * 2) == 0) - SoundEngine.PlaySound(SoundID.Item17, NPC.Center); - - if(Main.netMode == NetmodeID.SinglePlayer) - Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center + NPC.velocity + Main.rand.NextVector2Circular(72, 72), new Vector2(Main.rand.NextFloat(-IchorSpread, IchorSpread), -IchorVelocity), ModContent.ProjectileType(), IchorShotDamage, 0.5f); - else if(Main.dedServ) + if (Time > BloodshotRate + 30 && Time % (IchorRate * 10) == 0) { - Player furthestLeft = Main.player[AttackList[0]]; - Player furthestRight = Main.player[AttackList[1]]; - float xDist = furthestRight.Center.X - furthestLeft.Center.X; - int projCount = 1 + (int)(xDist / 360); + SoundEngine.PlaySound(BloodBomb, NPC.Center); + if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.NewNPC(NPC.GetSource_FromThis(), (int)NPC.Center.X, (int)NPC.Center.Y, ModContent.NPCType(), NPC.whoAmI); + } + else + { + if (Time % (IchorRate * 2) == 0) + SoundEngine.PlaySound(SoundID.Item17, NPC.Center); - for(int i = 0; i < projCount; i++) + if (Main.netMode == NetmodeID.SinglePlayer) Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center + NPC.velocity + Main.rand.NextVector2Circular(72, 72), new Vector2(Main.rand.NextFloat(-IchorSpread, IchorSpread), -IchorVelocity), ModContent.ProjectileType(), IchorShotDamage, 0.5f); + else if (Main.dedServ) + { + Player furthestLeft = Main.player[AttackList[0]]; + Player furthestRight = Main.player[AttackList[1]]; + float xDist = furthestRight.Center.X - furthestLeft.Center.X; + int projCount = 1 + (int)(xDist / 360); + + for (int i = 0; i < projCount; i++) + Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center + NPC.velocity + Main.rand.NextVector2Circular(72, 72), new Vector2(Main.rand.NextFloat(-IchorSpread, IchorSpread), -IchorVelocity), ModContent.ProjectileType(), IchorShotDamage, 0.5f); + } } } @@ -1931,6 +1953,7 @@ public class BrainOfCthulhuAI : VanillaAIOverride if (endTime == 0) SoundEngine.PlaySound(Roar, NPC.Center); + if (endTime >= DashPrepTime) { if (endTime < DashPrepTime + DashReelbackTime) @@ -1966,6 +1989,8 @@ public class BrainOfCthulhuAI : VanillaAIOverride private void SanguineScythes() { + NPC.damage = 0; + #region Attack Ending if (AttackCounter > SanguineTeleportCount) { @@ -2270,6 +2295,8 @@ public class BrainOfCthulhuAI : VanillaAIOverride private void IllusionDash() { + NPC.damage = 0; + #region Attack Start if (Time < IllusionDashTeleportDuration) { @@ -2465,24 +2492,26 @@ public class BrainOfCthulhuAI : VanillaAIOverride NPC.Opacity = 1 - (TeleportTime / (TeleportDuration / 2f)); } - else if (startTime < 90 + IllusionDashSpinDuration + 30 + IllusionDashFakeoutTeleportDuration + 30) + else if (startTime <= 150 + IllusionDashSpinDuration + 30 + IllusionDashFakeoutTeleportDuration + 30) { NPC.velocity *= 0.9f; - if (startTime % 15 == 0 && startTime > 45 + IllusionDashSpinDuration + 30 + IllusionDashFakeoutTeleportDuration) + if (startTime % 15 == 5 && startTime > 60 + IllusionDashSpinDuration + 30 + IllusionDashFakeoutTeleportDuration) { - for (int i = 0; i < 2; i++) + Vector2 dir = NPC.DirectionTo(Target.Center); + + for (int i = 0; i < (CalamityWorld.death ? 2 : 1); i++) { - Vector2 dir = NPC.DirectionTo(Target.Center); if (Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 initialDir = dir.RotatedBy(Main.rand.NextFloat(-MathHelper.Pi / 4f, MathHelper.Pi / 4f)); - Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, initialDir * Main.rand.NextFloat(10f, 25f), ProjectileID.BloodNautilusShot, BloodShotDamage, 0.5f, ai0: dir.ToRotation() + MathHelper.TwoPi, ai1: initialDir.ToRotation()); + Vector2 initialDir = dir.RotatedBy(MathHelper.Pi + Main.rand.NextFloat(-0.01f, 0.01f)); + Vector2 spawnPos = NPC.Center + (dir.RotatedBy(MathHelper.PiOver2) * Main.rand.NextFloat(-NPC.width, NPC.width) - (dir * 48)); + Projectile.NewProjectile(NPC.GetSource_FromThis(), spawnPos, initialDir * Main.rand.NextFloat(6f, 8f), ProjectileID.BloodNautilusShot, BloodShotDamage, 0.5f, ai0: dir.ToRotation() + MathHelper.TwoPi, ai1: initialDir.ToRotation()); } - NPC.velocity -= dir * 2f; + NPC.velocity -= dir; } } } - else if (startTime >= 135 + IllusionDashSpinDuration + 30 + IllusionDashFakeoutTeleportDuration + 30) + else if (startTime >= 180 + IllusionDashSpinDuration + 30 + IllusionDashFakeoutTeleportDuration + 30) { foreach (NPC n in Main.ActiveNPCs) if (n.type == ModContent.NPCType()) @@ -2569,20 +2598,20 @@ public class BrainOfCthulhuAI : VanillaAIOverride } NPC.damage = 0; + NPC.dontTakeDamage = false; if (AttackFlag) { if (AttackCounter == 0) { NPC.ShowNameOnHover = true; - NPC.velocity = NPC.DirectionFrom(Target.Center) * 8f; + NPC.velocity = NPC.DirectionFrom(Target.Center) * 4f; } else NPC.velocity *= 0.95f; if (AttackCounter >= IllusionTrickStunDuration) { - NPC.damage = NPC.defDamage; SetupForNextAttack(); NPC.Opacity = 1f; TeleportTime = 0; @@ -2607,6 +2636,7 @@ public class BrainOfCthulhuAI : VanillaAIOverride continue; n.ModNPC().BeenHit = true; + n.netUpdate = true; } for (int i = 1; i <= 3; i++) @@ -2628,7 +2658,7 @@ public class BrainOfCthulhuAI : VanillaAIOverride if (AttackList.Count > 0) { if (Main.netMode != NetmodeID.MultiplayerClient) - Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, -1, AttackList[0], 2f); + Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, -1, AttackList[0], 0, NPC.whoAmI); AttackList.RemoveAt(0); } @@ -2636,12 +2666,12 @@ public class BrainOfCthulhuAI : VanillaAIOverride { Vector2 direction = Target.velocity.SafeNormalize(Vector2.UnitX * Target.direction).RotatedBy(Main.rand.NextFloat(-MathHelper.Pi / 3f, MathHelper.Pi / 3f)); float distance = DefaultTeleportDistance; + NPC.damage = NPC.defDamage; AttackPosition = Target.Center + (direction * distance); BoCAfterImages = []; NPC.Opacity = 1f; TeleportTime = 0; Time = ChaseTime - 1; - NPC.damage = NPC.defDamage; NPC.netUpdate = true; ResetAttackValues(); @@ -2697,6 +2727,8 @@ public class BrainOfCthulhuAI : VanillaAIOverride { NPC.Opacity = 0f; BoCAfterImages = []; + NPC.damage = 0; + NPC.dontTakeDamage = true; } if (Time >= 180) diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhu/CreeperAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhu/CreeperAI.cs index b8c3e0dad8..8ad34c50b4 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhu/CreeperAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhu/CreeperAI.cs @@ -525,6 +525,7 @@ public class CreeperAI : VanillaAIOverride CachedValue1 = MathHelper.TwoPi / creeperCount * localCreeperID; AttackPosition = NPC.Center; AttackAngle = 0; + Time = -1; NPC.netUpdate = true; } } @@ -586,7 +587,7 @@ public class CreeperAI : VanillaAIOverride ConnectionOpacity = BringOpacityTo(ConnectionOpacity, 0f, 0.05f); float slowDown = (1 - MathHelper.Clamp((bossCounter - OrbitDuration) / 30f, 0f, 1f)); - AttackAngle += (BaseRotationSpeed * (MathHelper.Lerp(1f, 0.5f, CreeperAmountRatio) + (bocAI.OnSecondCreeperPhase ? 1f : 0.5f))) * slowDown * bocAI.AttackSign; + AttackAngle += (BaseRotationSpeed * (MathHelper.Lerp(1f, 0.5f, CreeperAmountRatio) + (bocAI.OnSecondCreeperPhase ? 0.75f : 0.5f))) * slowDown * bocAI.AttackSign; Vector2 rotation = Vector2.UnitX.RotatedBy(CachedValue1 + AttackAngle) * dist; if (bossCounter < OrbitSetupDuration) diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhu/FalseBrain.cs b/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhu/FalseBrain.cs index c0e5090a4b..c69afe955c 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhu/FalseBrain.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhu/FalseBrain.cs @@ -1,10 +1,15 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Packets; +using CalamityMod.Packets.Entities; using CalamityMod.Particles; +using CalamityMod.Projectiles.Boss.BrainOfCthulhu; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -13,6 +18,7 @@ using Terraria.DataStructures; using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; +using Terraria.ModLoader.IO; namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses.BrainOfCthulhu; @@ -47,15 +53,15 @@ public class FalseBrain : ModNPC, ILocalizedModType Music = MusicID.Boss3; SceneEffectPriority = (SceneEffectPriority)(-1); - NPC.localAI[0] = Main.rand.Next(6); + NPC.localAI[0] = Main.rand.Next(Main.getGoodWorld ? 7 : 6); NPC.localAI[1] = 1 + Main.rand.NextFloat(-0.25f, 0.25f); } private int Variant => (int)NPC.localAI[0]; private float Angle => NPC.ai[0]; private ref float Time => ref NPC.ai[1]; + int AttackTime { get => (int)NPC.ai[2]; set => NPC.ai[2] = value; } internal bool BeenHit = false; - int AttackTime = 0; int SpawnTime = 60; internal static float TimeDivisor => 360f; @@ -80,10 +86,8 @@ public class FalseBrain : ModNPC, ILocalizedModType { NPC.dontTakeDamage = true; - if (AttackTime == 60) + if (AttackTime++ >= 60) NPC.active = false; - - AttackTime++; } else { @@ -100,61 +104,47 @@ public class FalseBrain : ModNPC, ILocalizedModType } if (SpawnTime > 0) + SpawnTime--; + else if (SpawnTime >= -30) { - if (--SpawnTime == 0) + Time += --SpawnTime / -30f; + if(SpawnTime <= -30) NPC.dontTakeDamage = false; } - else if (SpawnTime > -30) - Time += --SpawnTime / -30f; else Time++; } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(BeenHit); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + BeenHit = reader.ReadBoolean(); + } + public override void OnHitByItem(Player player, Item item, NPC.HitInfo hit, int damageDone) { - SmiteFool(player); + if (!BeenHit) + { + if (Main.netMode == NetmodeID.SinglePlayer) + Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, Vector2.Zero, ModContent.ProjectileType(), 50, 0.5f, -1, player.whoAmI, 8, NPC.whoAmI); + else + BrainIllusionHitPacket.Send(NPC.whoAmI, player.whoAmI); + NPC.dontTakeDamage = true; + } } public override void OnHitByProjectile(Projectile projectile, NPC.HitInfo hit, int damageDone) { - if (!projectile.Calamity().IgnoreBoCIllusions && projectile.owner != -1) - SmiteFool(Main.player[projectile.owner]); - } - - private void SmiteFool(Player fool) - { - if (!BeenHit) + if (!BeenHit && !projectile.Calamity().IgnoreBoCIllusions && projectile.owner != -1) { - for (int i = 0; i < 6; i++) - { - Vector2 dir = fool.Center - NPC.Center; - int lifeTime = 24; - dir /= lifeTime / 2f * 5f; - dir *= i; - DirectionalPulseRing pulse = new(NPC.Center, dir, i % 2 == 0 ? Color.Red : Color.Orange, new Vector2(0.5f, 1), dir.ToRotation(), 0f, i / 5f, lifeTime + 8); - GeneralParticleHandler.SpawnParticle(pulse); - } - - BeenHit = true; - SoundEngine.PlaySound(BrainOfCthulhuAI.Laugh, NPC.Center); - fool.AddBuff(BuffID.Darkness, 900); - fool.AddBuff(BuffID.Bleeding, 900); - fool.AddBuff(BuffID.Confused, 60); - int timeToAdd = 300; - int bbIndex = fool.buffType.ToList().IndexOf(ModContent.BuffType()); - if (bbIndex != -1) - { - timeToAdd /= 2; - timeToAdd += fool.buffTime[bbIndex]; - } - - if (timeToAdd > 3600) - timeToAdd = 3600; - - fool.AddBuff(ModContent.BuffType(), timeToAdd); - - fool.Hurt(PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.BrainIllusion" + Main.rand.Next(1, 3 + 1)).ToNetworkText(fool.name)), 50, NPC.Center.X > fool.Center.X ? -1 : 1, cooldownCounter: 0, dodgeable: false, scalingArmorPenetration: 1f); - + if(Main.netMode == NetmodeID.SinglePlayer) + Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, Vector2.Zero, ModContent.ProjectileType(), 50, 0.5f, -1, projectile.owner, 8, NPC.whoAmI); + else + BrainIllusionHitPacket.Send(NPC.whoAmI, projectile.owner); NPC.dontTakeDamage = true; } } diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/MoonLordAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/MoonLordAI.cs index 5ba3fc0e7e..aeadc6ab19 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/MoonLordAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/MoonLordAI.cs @@ -193,10 +193,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses switch (aggressionLevel) { case 6: - velocity += 4f; + velocity += 3f; break; case 5: - velocity += 2f; + velocity += 1.5f; break; case 4: break; @@ -273,10 +273,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses switch (aggressionLevel) { case 6: - velocity += 4f; + velocity += 3f; break; case 5: - velocity += 2f; + velocity += 1.5f; break; case 4: break; @@ -711,10 +711,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses switch (aggressionLevel) { case 6: - calamityGlobalNPC.newAI[1] -= 180f; + calamityGlobalNPC.newAI[1] -= 120f; break; case 5: - calamityGlobalNPC.newAI[1] -= 90f; + calamityGlobalNPC.newAI[1] -= 60f; break; case 4: break; @@ -835,13 +835,8 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses bool shootThirdBolt = attackTimer == phaseAttackTime; switch (aggressionLevel) { - // Higher aggression gives the phantasmal bolts predictive aim case 6: - aimDirection = Main.player[NPC.target].Center + Main.player[NPC.target].velocity * 30f - NPC.Center; - break; case 5: - aimDirection = Main.player[NPC.target].Center + Main.player[NPC.target].velocity * 20f - NPC.Center; - break; case 4: break; case 3: @@ -874,8 +869,13 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float velocity = 6.25f; switch (aggressionLevel) { + // Higher aggression increases the speed of phantasmal bolts case 6: + velocity += 1.5f; + break; case 5: + velocity += 0.75f; + break; case 4: break; // Lower aggression reduces the speed of phantasmal bolts @@ -1074,10 +1074,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses switch (aggressionLevel) { case 6: - divisor = 3f; + divisor = 4f; break; case 5: - divisor = 4f; + divisor = 5f; break; case 4: break; @@ -1200,10 +1200,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses switch (aggressionLevel) { case 6: - velocity += 4f; + velocity += 3f; break; case 5: - velocity += 2f; + velocity += 1.5f; break; case 4: break; @@ -1233,10 +1233,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses switch (aggressionLevel) { case 6: - divisor = 15; + divisor = 20; break; case 5: - divisor = 20; + divisor = 25; break; case 4: break; @@ -1276,10 +1276,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses switch (aggressionLevel) { case 6: - velocity += 4f; + velocity += 3f; break; case 5: - velocity += 2f; + velocity += 1.5f; break; case 4: break; @@ -1372,10 +1372,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses switch (aggressionLevel) { case 6: - velocity += 4f; + velocity += 3f; break; case 5: - velocity += 2f; + velocity += 1.5f; break; case 4: break; @@ -1410,10 +1410,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses switch (aggressionLevel) { case 6: - velocity += 4f; + velocity += 3f; break; case 5: - velocity += 2f; + velocity += 1.5f; break; case 4: break; @@ -1450,13 +1450,8 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses bool shootThirdBolt = handAttackTimer == phaseAttackTime; switch (aggressionLevel) { - // Higher aggression gives the phantasmal bolts predictive aim case 6: - aimDirection = Main.player[NPC.target].Center + Main.player[NPC.target].velocity * 30f - NPC.Center; - break; case 5: - aimDirection = Main.player[NPC.target].Center + Main.player[NPC.target].velocity * 20f - NPC.Center; - break; case 4: break; // Lower aggression fires less phantasmal bolts @@ -1489,8 +1484,13 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float velocity = 6.25f; switch (aggressionLevel) { + // Higher aggression increases the speed of phantasmal bolts case 6: + velocity += 1.5f; + break; case 5: + velocity += 0.75f; + break; case 4: break; // Lower aggression reduces the speed of phantasmal bolts diff --git a/Packets/Entities/BrainIllusionHitPacket.cs b/Packets/Entities/BrainIllusionHitPacket.cs new file mode 100644 index 0000000000..04bb437c72 --- /dev/null +++ b/Packets/Entities/BrainIllusionHitPacket.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CalamityMod.Projectiles.Boss.BrainOfCthulhu; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; +using Terraria.ModLoader.IO; + +namespace CalamityMod.Packets.Entities; + +internal class BrainIllusionHitPacket : CalamityPacket +{ + public static BrainIllusionHitPacket Instance { get; private set; } + + public static void Send(int illusionIndex, int foolIndex) + { + // Only Client should send to Server + if (Main.dedServ) + return; + + var packet = Instance.CreateBasePacket(); + + packet.Write((byte)illusionIndex); + packet.Write((byte)foolIndex); + + packet.Send(); + } + + public override void HandlePacket(BinaryReader packet, int sender) + { + var bytes = packet.ReadBytes(2); + NPC illusion = Main.npc[(int)bytes[0]]; + Player fool = Main.player[(int)bytes[1]]; + if(Main.dedServ) + Projectile.NewProjectile(illusion.GetSource_FromThis(), illusion.Center, Vector2.Zero, ModContent.ProjectileType(), 50, 0.5f, -1, fool.whoAmI, 8, illusion.whoAmI); + illusion.dontTakeDamage = true; + illusion.netUpdate = true; + } +} diff --git a/Particles/StaticGlowLine.cs b/Particles/StaticGlowLine.cs new file mode 100644 index 0000000000..8dc0aab381 --- /dev/null +++ b/Particles/StaticGlowLine.cs @@ -0,0 +1,86 @@ +using System; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Particles +{ + public class StaticGlowLine : Particle + { + internal Asset texAsset; + // 1660 / 2048 is the size of the actual spark on the asset, roughly. + private const float approximateSparkHeight = 1660f; + + internal Vector2 destination; + internal Color InitialColor; + internal bool usesGlow; + internal float xScale = 1f; + internal float xShrink = 0.99f; + private float currentYScale = 1f; + + public override bool SetLifetime => true; + public override bool UseCustomDraw => true; + public override bool UseAdditiveBlend => true; + + public override string Texture => "CalamityMod/Particles/GlowSpark"; + + public StaticGlowLine(Vector2 start, Vector2 dest, Vector2 velocity, int lifetime, float xScale, float xShrink, Color color, bool glow = true) + { + Position = start; + destination = dest; + Velocity = velocity; + Lifetime = lifetime; + + Scale = 1f; // unused for this particle + this.xScale = xScale; + this.xShrink = xShrink; + + Color = InitialColor = color; + usesGlow = glow; + + Rotation = (dest - start).ToRotation() + MathHelper.PiOver2; + texAsset = ModContent.Request(Texture); + } + + public override void Update() + { + // Color lerping to transparent matches the behavior of Glow Sparks. + Color = Color.Lerp(InitialColor, Color.Transparent, (float)Math.Pow(LifetimeCompletion, 3D)); + + // Line shrinks horizontally continuously while existing. + xScale *= xShrink; + + // Recalculate current Y scale every frame. + Vector2 delta = destination - Position; + currentYScale = delta.Length() / approximateSparkHeight; + + // The Glow Spark asset is vertically oriented. + // However, this particle's velocity and orientation are completely independent of one another. + Rotation = (destination - Position).ToRotation() + MathHelper.PiOver2; + } + + public override void CustomDraw(SpriteBatch spriteBatch) + { + Texture2D texture = texAsset.Value; + Vector2 texSize = texture.Size() * 0.5f; + Vector2 scaleThisFrame = new(xScale, currentYScale); + + // Adjust the origin towards the target to compensate for the empty edges of the Glow Spark texture. + // Add a little extra so the edges of the beam go through the source and destination slightly. + float adjustmentDistance = 2f * currentYScale * (texture.Height - approximateSparkHeight); + Vector2 toDest = (destination - Position).SafeNormalize(-Vector2.UnitY); + Vector2 drawPos = Position + toDest * adjustmentDistance - Main.screenPosition; + + spriteBatch.Draw(texture, drawPos, null, Color, Rotation, texSize, scaleThisFrame, 0, 0f); + + if (usesGlow) + { + float glowInteriorWidth = 0.45f; + Vector2 glowScale = new(glowInteriorWidth, 1f); + spriteBatch.Draw(texture, drawPos, null, Color.White, Rotation, texSize, scaleThisFrame * glowScale, 0, 0f); + } + } + } +} diff --git a/Particles/XykWing1.png b/Particles/XykWingBlue1.png similarity index 100% rename from Particles/XykWing1.png rename to Particles/XykWingBlue1.png diff --git a/Particles/XykWing2.png b/Particles/XykWingBlue2.png similarity index 100% rename from Particles/XykWing2.png rename to Particles/XykWingBlue2.png diff --git a/Particles/XykWing3.png b/Particles/XykWingBlue3.png similarity index 100% rename from Particles/XykWing3.png rename to Particles/XykWingBlue3.png diff --git a/Particles/XykWingOrange1.png b/Particles/XykWingOrange1.png new file mode 100644 index 0000000000..4d5bc084b3 Binary files /dev/null and b/Particles/XykWingOrange1.png differ diff --git a/Particles/XykWingOrange2.png b/Particles/XykWingOrange2.png new file mode 100644 index 0000000000..2d0af0067e Binary files /dev/null and b/Particles/XykWingOrange2.png differ diff --git a/Particles/XykWingOrange3.png b/Particles/XykWingOrange3.png new file mode 100644 index 0000000000..fd6e3f8d78 Binary files /dev/null and b/Particles/XykWingOrange3.png differ diff --git a/Prefixes/ReforgeChange.cs b/Prefixes/ReforgeChange.cs index f76274b5e9..5a42927f66 100644 --- a/Prefixes/ReforgeChange.cs +++ b/Prefixes/ReforgeChange.cs @@ -1,4 +1,6 @@ -using System.Linq; +using System; +using System.Linq; +using CalamityMod.Items.Weapons.Melee; using CalamityMod.NPCs.TownNPCs; using CalamityMod.Packets; using CalamityMod.World; @@ -39,14 +41,8 @@ namespace CalamityMod.Prefixes if (Main.gameMenu) return -1; - if (item.accessory && CalamityServerConfig.Instance.SimplifyAccessoryReforge) - { - return GetSimplifiedAccessoryReforge(item, rand, storedPrefix); - } - else if (storedPrefix != -1 && CalamityServerConfig.Instance.RemoveReforgeRNG) - { + if (storedPrefix != -1 && !item.accessory && CalamityServerConfig.Instance.RemoveReforgeRNG) return GetReworkedReforge(item, rand, storedPrefix); - } return -1; } @@ -79,6 +75,7 @@ namespace CalamityMod.Prefixes } #region Prefix Definition + [Obsolete("No longer used with the removal of the Simplify Accessory Reforge config")] public static int[] SimplifiedAccessoryPrefixes = [ PrefixID.Warding, @@ -92,6 +89,7 @@ namespace CalamityMod.Prefixes PrefixType() ]; + [Obsolete("No longer used with the removal of the Simplify Accessory Reforge config")] public static int[][] AccessoryPrefixTiers = [ /* 0 */ [PrefixID.Hard, PrefixID.Jagged, PrefixID.Brisk, PrefixID.Wild], @@ -194,26 +192,9 @@ namespace CalamityMod.Prefixes int prefix = -1; bool supportsLegendary = PrefixLegacy.ItemSets.SwordsHammersAxesPicks[item.type] || (item.ModItem != null && item.ModItem.MeleePrefix()); - // ACCESSORIES - if (item.accessory) - { - int accRerolls = 0; - // Try to prevent the player from rolling the same modifier twice - do - { - int newPrefix = IteratePrefix(rand, AccessoryPrefixTiers, currentPrefix); - if (newPrefix != currentPrefix) - { - prefix = newPrefix; - break; - } - accRerolls++; - } while (accRerolls < 20); - } - // MELEE (includes tools and whips) // Melee-ranged hybrid weapons prioritize Legendary if available, otherwise go for Unreal - else if ((item.CountsAsClass() || item.CountsAsClass()) && !(item.CountsAsClass() && !supportsLegendary)) + if ((item.CountsAsClass() || item.CountsAsClass()) && !(item.CountsAsClass() && !supportsLegendary) && !(item.type == ItemType())) { // Terrarian (has its own special "Legendary" for marketing reasons) // Other items that want to use Legendary2 are also compatible @@ -238,8 +219,8 @@ namespace CalamityMod.Prefixes } } - // RANGED - else if (item.CountsAsClass()) + // RANGED (and also Burning Sky) + else if (item.CountsAsClass() || item.type == ItemType()) { prefix = IteratePrefix(rand, RangedPrefixTiers, currentPrefix); } @@ -290,13 +271,5 @@ namespace CalamityMod.Prefixes return rand.Next(reforgeTiers[newTier]); } #endregion - - #region Simplified Accessory Reforge - internal static int GetSimplifiedAccessoryReforge(Item item, UnifiedRandom rand, int currentPrefix) - { - var pool = SimplifiedAccessoryPrefixes.Where(id => id != currentPrefix); - return pool.ElementAt(rand.Next(0, pool.Count())); - } - #endregion } } diff --git a/Projectiles/Boss/BrainOfCthulhu/BloodBomb.cs b/Projectiles/Boss/BrainOfCthulhu/BloodBomb.cs new file mode 100644 index 0000000000..686fb8adac --- /dev/null +++ b/Projectiles/Boss/BrainOfCthulhu/BloodBomb.cs @@ -0,0 +1,267 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CalamityMod.Items.Placeables.Banners; +using CalamityMod.Particles; +using CalamityMod.Projectiles.Typeless; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Boss.BrainOfCthulhu; + +public class BloodBomb : ModNPC, ILocalizedModType +{ + public new string LocalizationCategory => "NPCs"; + + internal static Asset BloodBombYellow; + internal static Texture2D BloodBombGlow; + + public override void SetStaticDefaults() + { + NPCID.Sets.ProjectileNPC[Type] = true; + BloodBombYellow = ModContent.Request("CalamityMod/Projectiles/Boss/BrainOfCthulhu/BloodBomb2"); + } + + internal static Texture2D GetBombGlow() + { + if (BloodBombGlow == null) + { + var tex = new Texture2D(Main.graphics.GraphicsDevice, BloodBombYellow.Value.Width, BloodBombYellow.Value.Height); + + var BaseArray = new Color[tex.Width * tex.Height]; + var ColorArray = new Color[tex.Width * tex.Height]; + BloodBombYellow.Value.GetData(BaseArray); + for (var i = 0; i < BaseArray.Length; i++) + { + ColorArray[i] = new Color(255, 255, 255) * (((float)BaseArray[i].A) / 255f); + } + tex.SetData(ColorArray); + BloodBombGlow = tex; + } + + return BloodBombGlow; + } + + public override void SetDefaults() + { + NPC.width = 30; + NPC.height = 30; + NPC.noGravity = true; + NPC.damage = 10; + NPC.defense = 5; + NPC.lifeMax = 60; + NPC.Calamity().canBreakPlayerDefense = true; + NPC.lavaImmune = true; + NPC.aiStyle = -1; + AIType = -1; + NPC.value = 0; + NPC.HitSound = SoundID.NPCHit1; + NPC.DeathSound = SoundID.NPCHit1 with { Pitch = 0.5f }; + NPC.knockBackResist = 0f; + NPC.chaseable = false; + NPC.noTileCollide = true; + NPC.ShowNameOnHover = false; + } + + public override void OnSpawn(IEntitySource source) + { + if (source is EntitySource_Parent { Entity: NPC n }) + NPC.ai[1] = n.whoAmI; + else + NPC.ai[1] = -1; + + Vector2 goal = Main.player[0].Center - NPC.Center; + + float vyi = 6; + float vyisq = 36; + float g = 0.2f; + + float vyf = -MathF.Sqrt(vyisq + 2 * g * goal.Y); + float t = Math.Abs((vyf - vyi) / g); + + float vxi = goal.X / t; + + NPC.velocity = new Vector2(float.IsNaN(vxi) ? (goal.X > 0 ? 10 : -10) : vxi, -vyi); + + for (int i = 0; i < 3; i++) + { + BloodParticle p = new(NPC.Center, NPC.velocity.RotatedBy(Main.rand.NextFloat(-MathHelper.Pi / 6f, MathHelper.Pi / 6f)) * Main.rand.NextFloat(2f, 3f), 32, 1f, Color.Red); + GeneralParticleHandler.SpawnParticle(p); + } + BloodParticle2 p2 = new(NPC.Center, NPC.velocity * 2.5f, 16, 0.5f, Color.Red); + GeneralParticleHandler.SpawnParticle(p2); + } + + public override void AI() + { + if (NPC.ai[0] > 1200) + NPC.active = false; + + NPC.velocity.Y += 0.2f; + + NPC.rotation += Math.Sign(NPC.velocity.X) * (NPC.velocity.Length()) * 0.01f; + + if (NPC.ai[0] % 3 == 0) + { + float deathRatio = 1 - (NPC.life / NPC.lifeMax); + float time = Main.GlobalTimeWrappedHourly * (10f + (10f * deathRatio)); + float lerp = MathF.Sin(time) / 2f + 0.5f; + Color color = Color.Lerp(Color.Red, Color.Yellow, lerp); + + BloodParticle p = new(NPC.Center + Main.rand.NextVector2Circular(NPC.width, NPC.height), (-NPC.velocity).RotatedBy(Main.rand.NextFloat(-MathHelper.Pi / 6f, MathHelper.Pi / 6f)) * Main.rand.NextFloat(0.25f, 0.75f), Main.rand.Next(10, 17), Main.rand.NextFloat(0.5f, 1f), color); + GeneralParticleHandler.SpawnParticle(p); + } + + NPC.ai[0]++; + } + + public override void ModifyHitByItem(Player player, Item item, ref NPC.HitModifiers modifiers) + { + if (modifiers.DamageType == TrueMeleeDamageClass.Instance) + { + modifiers.FinalDamage *= 1.5f; + return; + } + + float dist = player.DistanceSQ(NPC.Center); + dist = MathHelper.Clamp(dist - 10000, 0, 160000); + if (dist > 160000) + modifiers.FinalDamage *= 0; + else + modifiers.FinalDamage *= MathHelper.Lerp(1f, 0f, dist / 160000f); + } + + public override void ModifyHitByProjectile(Projectile projectile, ref NPC.HitModifiers modifiers) + { + if (modifiers.DamageType == TrueMeleeDamageClass.Instance) + { + modifiers.FinalDamage *= 1.5f; + return; + } + + if (projectile.owner == -1) + { + modifiers.FinalDamage *= 0; + return; + } + + float dist = Main.player[projectile.owner].DistanceSQ(NPC.Center); + dist = MathHelper.Clamp(dist - 10000, 0, 160000); + if (dist > 160000f) + modifiers.FinalDamage *= 0; + else + modifiers.FinalDamage *= MathHelper.Lerp(1f, 0f, dist / 160000f); + } + + public override void HitEffect(NPC.HitInfo hit) + { + if(NPC.life <= 0) + { + if (NPC.ai[1] == -1) + NPC.ai[1] = NPC.Center.ClosestNPCAt(1200, true, true).whoAmI; + Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, NPC.DirectionTo(Main.npc[(int)NPC.ai[1]].Center) * 16f, ModContent.ProjectileType(), 40, 1f, -1, NPC.ai[1]); + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + float deathRatio = 1 - (NPC.life / NPC.lifeMax); + float time = Main.GlobalTimeWrappedHourly * (10f + (10f * deathRatio)); + float lerp = MathF.Sin(time) / 2f + 0.5f; + + Texture2D baseTex = TextureAssets.Npc[Type].Value; + Texture2D overlayTex = BloodBombYellow.Value; + + Vector2 drawPos = NPC.Center - Main.screenPosition + Main.rand.NextVector2CircularEdge((2 * deathRatio), (2 * deathRatio)); + float scale = 1.5f + (MathF.Sin(time) * 0.25f); + + if (Main.LocalPlayer.HasBuff(BuffID.Hunter)) + spriteBatch.Draw(GetBombGlow(), drawPos, null, Color.OrangeRed, NPC.rotation, BloodBombGlow.Size() * 0.5f, scale + 0.15f, 0, 0); + + spriteBatch.Draw(baseTex, drawPos, null, Color.White, NPC.rotation, baseTex.Size() * 0.5f, scale, 0, 0); + spriteBatch.Draw(overlayTex, drawPos, null, Color.White * lerp, NPC.rotation, overlayTex.Size() * 0.5f, scale, 0, 0); + return false; + } +} + +public class BloodBombRTS : ModProjectile, ILocalizedModType +{ + public new string LocalizationCategory => "Projectiles.Boss"; + public override string Texture => "CalamityMod/Projectiles/Boss/BrainOfCthulhu/BloodBomb"; + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Type] = 8; + ProjectileID.Sets.TrailingMode[Type] = 2; + } + + public override void SetDefaults() + { + Projectile.width = 30; + Projectile.height = 30; + Projectile.penetrate = 1; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + Projectile.damage = 10; + Projectile.friendly = true; + Projectile.hostile = false; + Projectile.tileCollide = false; + Projectile.timeLeft = 360; + } + + public override void AI() + { + NPC npc = Main.npc[(int)Projectile.ai[0]]; + if(npc.active && !npc.dontTakeDamage) + Projectile.velocity = Projectile.DirectionTo(npc.Center) * 16f; + } + + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + modifiers.SetCrit(); + } + + public override void OnKill(int timeLeft) + { + SoundEngine.PlaySound(SoundID.DD2_ExplosiveTrapExplode, Projectile.Center); + + CustomPulse explosion1 = new(Projectile.Center, Vector2.Zero, Color.OrangeRed, "CalamityMod/Particles/FlameExplosion", Vector2.One, Main.rand.NextFloat(0f, MathHelper.Pi), 0f, 0.1f, 24); + GeneralParticleHandler.SpawnParticle(explosion1); + + CustomPulse explosion2 = new(Projectile.Center, Vector2.Zero, Color.Red, "CalamityMod/Particles/FlameExplosion", Vector2.One, Main.rand.NextFloat(0f, MathHelper.Pi), 0f, 0.075f, 24); + GeneralParticleHandler.SpawnParticle(explosion2); + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D tex = TextureAssets.Projectile[Type].Value; + Texture2D overlayTex = BloodBomb.BloodBombYellow.Value; + + + for (int i = 0; i < (CalamityClientConfig.Instance.Afterimages ? Projectile.oldPos.Length : 1); ++i) + { + float time = (Main.GlobalTimeWrappedHourly * 30) - (i / 2f); + float lerp = MathF.Sin(time) / 2f + 0.5f; + Color color = Color.White; + float afterimageRot = Projectile.oldRot[i]; + Vector2 drawPos = Projectile.oldPos[i] + (Projectile.Size / 2f) - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY); + if (i != 0) + color *= 0.75f; + + // DO NOT REMOVE THESE "UNNECESSARY" FLOAT CASTS. THIS WILL BREAK THE AFTERIMAGES. + float interpolant = ((float)(Projectile.oldPos.Length - i) / (float)Projectile.oldPos.Length); + Main.spriteBatch.Draw(tex, drawPos, null, color * (1 - lerp), afterimageRot, tex.Size() * 0.5f, (Projectile.scale + MathF.Sin(time) / 2f + 0.5f) * interpolant, SpriteEffects.None, 0f); + Main.spriteBatch.Draw(overlayTex, drawPos, null, color * lerp, afterimageRot, overlayTex.Size() * 0.5f, (Projectile.scale + MathF.Sin(time) / 2f + 0.5f) * interpolant, SpriteEffects.None, 0f); + + } + return false; + } +} diff --git a/Projectiles/Boss/BrainOfCthulhu/BloodBomb.png b/Projectiles/Boss/BrainOfCthulhu/BloodBomb.png new file mode 100644 index 0000000000..ab2860fe7b Binary files /dev/null and b/Projectiles/Boss/BrainOfCthulhu/BloodBomb.png differ diff --git a/Projectiles/Boss/BrainOfCthulhu/BloodBomb2.png b/Projectiles/Boss/BrainOfCthulhu/BloodBomb2.png new file mode 100644 index 0000000000..47c4444e55 Binary files /dev/null and b/Projectiles/Boss/BrainOfCthulhu/BloodBomb2.png differ diff --git a/Projectiles/Boss/BrainOfCthulhu/BloodScythe.cs b/Projectiles/Boss/BrainOfCthulhu/BloodScythe.cs index 2a05b796be..c956e3bf77 100644 --- a/Projectiles/Boss/BrainOfCthulhu/BloodScythe.cs +++ b/Projectiles/Boss/BrainOfCthulhu/BloodScythe.cs @@ -97,22 +97,17 @@ public class BloodScythe : ModProjectile, ILocalizedModType if (!ChildSafety.Disabled) drawColor = Main.DiscoColor; - if (CalamityClientConfig.Instance.Afterimages) + for (int i = 0; i < (CalamityClientConfig.Instance.Afterimages ? Projectile.oldPos.Length : 1); ++i) { - for (int i = 0; i < Projectile.oldPos.Length; ++i) - { - float afterimageRot = Projectile.oldRot[i]; - drawPos = Projectile.oldPos[i] + (Projectile.Size / 2f) - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY); - if (i != 0) - drawColor *= 0.9f; + float afterimageRot = Projectile.oldRot[i]; + drawPos = Projectile.oldPos[i] + (Projectile.Size / 2f) - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY); + if (i != 0) + drawColor *= 0.9f; - // DO NOT REMOVE THESE "UNNECESSARY" FLOAT CASTS. THIS WILL BREAK THE AFTERIMAGES. - float interpolant = ((float)(Projectile.oldPos.Length - i) / (float)Projectile.oldPos.Length); - Main.spriteBatch.Draw(tex, drawPos, null, drawColor, afterimageRot, tex.Size() * 0.5f, Projectile.scale * interpolant, SpriteEffects.None, 0f); - } + // DO NOT REMOVE THESE "UNNECESSARY" FLOAT CASTS. THIS WILL BREAK THE AFTERIMAGES. + float interpolant = ((float)(Projectile.oldPos.Length - i) / (float)Projectile.oldPos.Length); + Main.spriteBatch.Draw(tex, drawPos, null, drawColor, afterimageRot, tex.Size() * 0.5f, Projectile.scale * interpolant, SpriteEffects.None, 0f); } - //else - // Main.EntitySpriteDraw(tex, drawPos, tex.Frame(), drawColor, Projectile.rotation, tex.Size() * 0.5f, Projectile.scale, SpriteEffects.None, 0); Main.spriteBatch.SetBlendState(BlendState.AlphaBlend); diff --git a/Projectiles/Boss/BrainOfCthulhu/TelekineticBlast.cs b/Projectiles/Boss/BrainOfCthulhu/TelekineticBlast.cs index 779b55153e..d4da41798a 100644 --- a/Projectiles/Boss/BrainOfCthulhu/TelekineticBlast.cs +++ b/Projectiles/Boss/BrainOfCthulhu/TelekineticBlast.cs @@ -27,17 +27,40 @@ public class TelekineticBlast : ModProjectile, ILocalizedModType Projectile.penetrate = -1; Projectile.Opacity = 1f; Projectile.tileCollide = false; - Projectile.timeLeft = 1; + Projectile.timeLeft = 10; Projectile.damage = 0; Projectile.scale = 1; Projectile.hostile = true; + Projectile.netImportant = true; } Player target => Main.player[(int)Projectile.ai[0]]; - float debuffMultiplier => Projectile.ai[1]; + float debuffMultiplier => Main.npc[NPCSource].type == NPCID.BrainofCthulhu ? 2f : 1f; + int delay { get => (int)Projectile.ai[1]; set => Projectile.ai[1] = value; } + int NPCSource => (int)Projectile.ai[2]; + + public override void OnSpawn(IEntitySource source) + { + Projectile.netUpdate = true; + } public override void AI() { + if (Main.npc[NPC.crimsonBoss].AIOverride().AttackFlag || Main.npc[NPC.crimsonBoss].AIOverride().AIState == BrainOfCthulhuAI.BrainAIState.DeathAnimation) + { + Projectile.active = false; + return; + } + + if (--delay > 0) + return; + + if (Main.npc[NPCSource].ModNPC is FalseBrain illusion) + { + illusion.BeenHit = true; + Main.npc[NPCSource].netUpdate = true; + } + for (int i = 0; i < 6; i++) { Vector2 dir = target.Center - Projectile.Center; diff --git a/Projectiles/CalamityGlobalProjectile.cs b/Projectiles/CalamityGlobalProjectile.cs index 1dbb096249..5f598db756 100644 --- a/Projectiles/CalamityGlobalProjectile.cs +++ b/Projectiles/CalamityGlobalProjectile.cs @@ -18,8 +18,10 @@ using CalamityMod.Items.Armor.Daedalus; using CalamityMod.Items.Armor.Reaver; using CalamityMod.Items.Fishing.FishingRods; using CalamityMod.Items.Potions.Alcohol; +using CalamityMod.Items.SummonItems; using CalamityMod.Items.VanillaArmorChanges; using CalamityMod.NPCs; +using CalamityMod.NPCs.OldDuke; using CalamityMod.NPCs.PlagueEnemies; using CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses; using CalamityMod.Packets.Entities; @@ -336,7 +338,7 @@ namespace CalamityMod.Projectiles { if (player.Calamity().grapeBeer && (item.useAmmo == AmmoID.Bullet || item.useAmmo == AmmoID.Arrow || item.useAmmo == AmmoID.Dart || item.useAmmo == AmmoID.Rocket)) { - if (player.heldProj != projectile.whoAmI && projectile.aiStyle != ProjAIStyleID.HeldProjectile && projectile.damage > 0 && player.Calamity().grapeBeerTimer < 5 && !CalamityProjectileSets.DoesNotGetHomingWithGrapeBeer[projectile.type]) + if (player.heldProj != projectile.whoAmI && projectile.aiStyle != ProjAIStyleID.HeldProjectile && projectile.damage > 0 && !CalamityProjectileSets.DoesNotGetHomingWithGrapeBeer[projectile.type]) ApplyGrapeBeer(); else grapeBeer = true; @@ -357,12 +359,15 @@ namespace CalamityMod.Projectiles //Grape Beer homing if (parent.Calamity().grapeBeer) { - if (Main.player[projectile.owner].heldProj != projectile.whoAmI && projectile.aiStyle != ProjAIStyleID.HeldProjectile && projectile.damage > 0 && Main.player[projectile.owner].Calamity().grapeBeerTimer < 5 && !CalamityProjectileSets.DoesNotGetHomingWithGrapeBeer[projectile.type]) + if (Main.player[projectile.owner].heldProj != projectile.whoAmI && projectile.aiStyle != ProjAIStyleID.HeldProjectile && projectile.damage > 0 && !CalamityProjectileSets.DoesNotGetHomingWithGrapeBeer[projectile.type]) ApplyGrapeBeer(); else grapeBeer = true; } + if (parent.Calamity().IgnoreBoCIllusions) + IgnoreBoCIllusions = true; + // Nerf Crystal bullet shard damage by 45% // Vanilla crystal shards deal 50% of the bullet's damage which is absurd, this nerfs them to 27.5% if (parent.type == ProjectileID.CrystalBullet && projectile.type == ProjectileID.CrystalShard) @@ -2959,6 +2964,10 @@ namespace CalamityMod.Projectiles { NPC.SpawnOnPlayer(owner.whoAmI, 370); } + else + { + NetMessage.SendData(MessageID.SpawnBossUseLicenseStartEvent, -1, -1, null, owner.whoAmI, 370f); + } projectile.ai[0] = 2f; } else if (projectile.localAI[1] < 1) @@ -3305,7 +3314,29 @@ namespace CalamityMod.Projectiles if (cplayer.mouseRight && projectile.ai[1] == 0 && owner.miscCounter % 10 == 0) { owner.lifeRegenCount -= 600; // -5 health per 10 ticks - var projID = Projectile.NewProjectile(projectile.GetSource_FromThis(), Main.npc[(int)PersistentFishingData].Center, Vector2.Zero, ModContent.ProjectileType(), (int)owner.GetBestClassDamage().ApplyTo(owner.HeldItem.fishingPole + owner.fishingSkill + owner.ChooseAmmo(owner.HeldItem).bait), 0f, owner.whoAmI, Main.npc[(int)PersistentFishingData].whoAmI); + owner.Fishing_GetBait(out Item baitItem); + + // Diminishing returns on bait power beyond 75 + int baitPower = baitItem?.bait ?? 0; + if (baitItem?.type == ItemID.TruffleWorm) + { + projectile.ai[0] = 1; + projectile.localAI[1] = 1; + ReelTheBobberChecks(); + } + else if (baitItem?.type == ItemType()) + { + projectile.ai[0] = 1; + projectile.localAI[1] = NPCType() * -1; + baitPower = BloodwormItem.SpoofBaitNumber; // Manually set the power to the displayed value + ReelTheBobberChecks(); + } + else if (baitPower > 75) + { + baitPower = (int)Math.Pow((baitPower - 75), 0.5f) + 75; + } + + var projID = Projectile.NewProjectile(projectile.GetSource_FromThis(), Main.npc[(int)PersistentFishingData].Center, Vector2.Zero, ModContent.ProjectileType(), (int)owner.GetBestClassDamage().ApplyTo(owner.HeldItem.fishingPole + owner.fishingSkill + baitPower), 0f, owner.whoAmI, Main.npc[(int)PersistentFishingData].whoAmI); if (Main.projectile.IndexInRange(projID)) { Main.projectile[projID].ArmorPenetration = 100; //This should ignore almost all armor @@ -3586,9 +3617,10 @@ namespace CalamityMod.Projectiles if (TimerToCatch <= 0) { projectile.FishingCheck(); - if (projectile.ai[1] < 0 && !(projectile.lavaWet && !owner.accLavaFishing)) + var fishingCond = Main.player[projectile.owner].GetFishingConditions(); + bool canLavaFish = ItemID.Sets.CanFishInLava[fishingCond.PoleItemType] || ItemID.Sets.IsLavaBait[fishingCond.BaitItemType] || Main.player[projectile.owner].accLavaFishing; + if (projectile.ai[1] < 0 && !(projectile.lavaWet && !canLavaFish)) { - CaughtItemID = (int)projectile.localAI[1]; projectile.ai[1] = 0; projectile.localAI[1] = 0; @@ -4693,7 +4725,7 @@ namespace CalamityMod.Projectiles { var player = Main.player[projectile.owner]; float burnRatio = (-player.statMana / 100) * ChaosStone.DamageMultPer100Mana; - target.Calamity().manaBurn += damageDone * burnRatio * (player.Calamity().oldFashioned ? OldFashioned.DamageBoostMultiplier : 1) * (player.Calamity().ivDrip ? IVDripOnTheRocks.DamageBoostMultiplier : 1); + target.Calamity().manaBurn += damageDone * burnRatio * (player.Calamity().oldFashioned ? OldFashioned.DamageBoostMultiplier : 1) * (player.Calamity().ivDrip ? IVDripOnTheRocks.DamageBoostMultiplier : 1) * (player.Calamity().vodka ? 1+Vodka.DebuffBoost : 1); target.Calamity().playerManaBurnIntensity = -player.statMana / (float)player.statManaMax2; if (Main.netMode != NetmodeID.SinglePlayer) ManaBurnSyncPacket.Send(target); diff --git a/Projectiles/CalamityGlobalProjectileTweaks.cs b/Projectiles/CalamityGlobalProjectileTweaks.cs index 9d21db0c48..e906bedf4b 100644 --- a/Projectiles/CalamityGlobalProjectileTweaks.cs +++ b/Projectiles/CalamityGlobalProjectileTweaks.cs @@ -138,7 +138,7 @@ namespace CalamityMod.Projectiles { ProjectileID.ClusterFragmentsII, Do(IDStaticIFrames(15)) }, { ProjectileID.ClusterSnowmanRocketI, Do(LocalIFrames(15)) }, { ProjectileID.ClusterSnowmanRocketII, Do(LocalIFrames(15)) }, - { ProjectileID.DangerousSpider, Do( ExtraUpdatesExact(2), LocalIFrames(45)) }, //Spider Staff spiders. It has Venom, Dangerous, and Jumping spiders. + { ProjectileID.DangerousSpider, Do( ExtraUpdatesExact(2), LocalIFrames(90)) }, //Spider Staff spiders. It has Venom, Dangerous, and Jumping spiders. { ProjectileID.DD2SquireSonicBoom, Do(PiercingExact(3), DefaultIDStaticIFrames) }, // Flying Dragon { ProjectileID.DeadlySphere, Do(LocalIFrames(30)) }, { ProjectileID.EmeraldBolt, Do(NoPiercing) }, @@ -165,7 +165,7 @@ namespace CalamityMod.Projectiles { ProjectileID.InfluxWaver, Do(ExtraUpdatesExact(1)) }, { ProjectileID.InfernoFriendlyBolt, Do(ExtraUpdatesExact(1), DefaultIDStaticIFrames) }, { ProjectileID.InfernoFriendlyBlast, Do(ExtraUpdatesExact(2), DefaultIDStaticIFrames) }, - { ProjectileID.JumperSpider, Do( ExtraUpdatesExact(2), LocalIFrames(45)) }, //Spider Staff spiders. It has Venom, Dangerous, and Jumping spiders. + { ProjectileID.JumperSpider, Do( ExtraUpdatesExact(2), LocalIFrames(90)) }, //Spider Staff spiders. It has Venom, Dangerous, and Jumping spiders. { ProjectileID.LaserDrill, Do(ArmorPenetrationDelta(+25), LocalIFrames(5)) }, { ProjectileID.LightDisc, Do(MaxUpdatesExact(3), DefaultIDStaticIFrames) }, { ProjectileID.LostSoulHostile, Do(TileCollide) }, // Ragged Caster @@ -209,7 +209,7 @@ namespace CalamityMod.Projectiles { ProjectileID.Trimarang, Do(ExtraUpdatesExact(1), DefaultIDStaticIFrames) }, { ProjectileID.TrueNightsEdge, Do(PiercingExact(4)) }, { ProjectileID.VenomBullet, Do(ExtraUpdatesDelta(+2), DefaultIDStaticIFrames) }, - { ProjectileID.VenomSpider, Do( ExtraUpdatesExact(2), LocalIFrames(45)) }, //Spider Staff spiders. It has Venom, Dangerous, and Jumping spiders. + { ProjectileID.VenomSpider, Do( ExtraUpdatesExact(2), LocalIFrames(90)) }, //Spider Staff spiders. It has Venom, Dangerous, and Jumping spiders. { ProjectileID.VortexDrill, standardDrillTweaks }, { ProjectileID.Wasp, Do(PiercingExact(2)) }, { ProjectileID.WeatherPainShot, Do(ExtraUpdatesExact(3), TimeLeftExact(1920)) }, @@ -328,7 +328,7 @@ namespace CalamityMod.Projectiles { ProjectileID.CrimsandBallGun, defaultIFrames }, { ProjectileID.CrimsonHeart, defaultIFrames }, { ProjectileID.CrimsonSpray, defaultIFrames }, - { ProjectileID.CrystalDart, Do( ExtraUpdatesExact(2), LocalIFrames(-1)) }, + { ProjectileID.CrystalDart, Do(ExtraUpdatesExact(2), LocalIFrames(-1)) }, { ProjectileID.CrystalLeaf, defaultIFrames }, { ProjectileID.CrystalLeafShot, defaultIFrames }, { ProjectileID.CrystalPulse, defaultIFrames }, @@ -338,7 +338,7 @@ namespace CalamityMod.Projectiles { ProjectileID.CrystalVileShardHead, defaultIFrames }, { ProjectileID.CrystalVileShardShaft, defaultIFrames }, { ProjectileID.CursedArrow, defaultIFrames }, - { ProjectileID.CursedDart, Do( ExtraUpdatesExact(1), LocalIFrames(20)) }, + { ProjectileID.CursedDart, Do(ExtraUpdatesExact(1), LocalIFrames(20)) }, { ProjectileID.CursedDartFlame, defaultIFrames }, { ProjectileID.CursedFlameFriendly, defaultIFrames }, { ProjectileID.CursedFlare, defaultIFrames }, @@ -397,7 +397,7 @@ namespace CalamityMod.Projectiles { ProjectileID.IceBlock, defaultIFrames }, { ProjectileID.IceBolt, defaultIFrames }, { ProjectileID.IchorArrow, defaultIFrames }, - { ProjectileID.IchorDart, Do( ExtraUpdatesExact(1), DefaultIDStaticIFrames) }, + { ProjectileID.IchorDart, Do(ExtraUpdatesExact(1), DefaultIDStaticIFrames) }, { ProjectileID.JackOLantern, defaultIFrames }, { ProjectileID.JavelinFriendly, defaultIFrames }, { ProjectileID.JestersArrow, defaultIFrames }, @@ -412,13 +412,13 @@ namespace CalamityMod.Projectiles { ProjectileID.LavaSnowmanRocket, defaultIFrames }, { ProjectileID.Leaf, defaultIFrames }, { ProjectileID.LifeCrystalBoulder, defaultIFrames }, - { ProjectileID.MagicMissile, Do(IDStaticIFrames(8)) }, // Has an exception in Vanilla iframe code, uses 8 iframes + { ProjectileID.MagicMissile, Do(IDStaticIFrames(8), SingleHitImmunity) }, // Has an exception in Vanilla iframe code, uses 8 iframes { ProjectileID.MagnetSphereBolt, defaultIFrames }, { ProjectileID.MedusaHead, defaultIFrames }, { ProjectileID.MedusaHeadRay, defaultIFrames }, - { ProjectileID.Meteor1, Do(IDStaticIFrames(5)) }, // Has an exception in Vanilla iframe code, uses 5 iframes - { ProjectileID.Meteor2, Do(IDStaticIFrames(5)) }, // Has an exception in Vanilla iframe code, uses 5 iframes - { ProjectileID.Meteor3, Do(IDStaticIFrames(5)) }, // Has an exception in Vanilla iframe code, uses 5 iframes + { ProjectileID.Meteor1, Do(IDStaticIFrames(5), SingleHitImmunity) }, // Has an exception in Vanilla iframe code, uses 5 iframes + { ProjectileID.Meteor2, Do(IDStaticIFrames(5), SingleHitImmunity) }, // Has an exception in Vanilla iframe code, uses 5 iframes + { ProjectileID.Meteor3, Do(IDStaticIFrames(5), SingleHitImmunity) }, // Has an exception in Vanilla iframe code, uses 5 iframes { ProjectileID.MinecartMechLaser, defaultIFrames }, { ProjectileID.MiniBoulder, defaultIFrames }, { ProjectileID.MiniMinotaur, defaultIFrames }, @@ -441,8 +441,8 @@ namespace CalamityMod.Projectiles { ProjectileID.NailFriendly, Do(IDStaticIFrames(1)) }, // Has an exception in Vanilla iframe code, uses 1 iframe { ProjectileID.NebulaArcanumExplosionShot, defaultIFrames }, { ProjectileID.NebulaArcanumExplosionShotShard, defaultIFrames }, - { ProjectileID.NebulaBlaze1, Do(IDStaticIFrames(5)) }, // Has an exception in Vanilla iframe code, uses 5 iframes - { ProjectileID.NebulaBlaze2, Do(IDStaticIFrames(5)) }, // Has an exception in Vanilla iframe code, uses 5 iframes + { ProjectileID.NebulaBlaze1, Do(IDStaticIFrames(5), SingleHitImmunity) }, // Has an exception in Vanilla iframe code, uses 5 iframes + { ProjectileID.NebulaBlaze2, Do(IDStaticIFrames(5), SingleHitImmunity) }, // Has an exception in Vanilla iframe code, uses 5 iframes { ProjectileID.NettleBurstEnd, defaultIFrames }, { ProjectileID.NettleBurstLeft, defaultIFrames }, { ProjectileID.NettleBurstRight, defaultIFrames }, @@ -466,7 +466,7 @@ namespace CalamityMod.Projectiles { ProjectileID.PhantasmArrow, defaultIFrames }, { ProjectileID.PineNeedleFriendly, defaultIFrames }, { ProjectileID.PlatinumCoin, defaultIFrames }, - { ProjectileID.PoisonDart, Do( ExtraUpdatesExact(1), DefaultIDStaticIFrames) }, + { ProjectileID.PoisonDart, Do(ExtraUpdatesExact(1), DefaultIDStaticIFrames) }, { ProjectileID.PoisonDartBlowgun, defaultIFrames }, { ProjectileID.PoisonDartTrap, defaultIFrames }, { ProjectileID.PoisonedKnife, defaultIFrames }, @@ -549,7 +549,7 @@ namespace CalamityMod.Projectiles { ProjectileID.StickyDynamite, defaultIFrames }, { ProjectileID.StickyGrenade, defaultIFrames }, { ProjectileID.StormTigerGem, defaultIFrames }, - { ProjectileID.Stynger, Do(IDStaticIFrames(7)) }, // Has an exception in Vanilla iframe code, uses 7 iframes + { ProjectileID.Stynger, Do(IDStaticIFrames(7), SingleHitImmunity) }, // Has an exception in Vanilla iframe code, uses 7 iframes { ProjectileID.StyngerShrapnel, defaultIFrames }, { ProjectileID.TentacleSpike, defaultIFrames }, { ProjectileID.ThornChakram, defaultIFrames }, @@ -566,7 +566,6 @@ namespace CalamityMod.Projectiles { ProjectileID.ToxicFlask, defaultIFrames }, { ProjectileID.Truffle, defaultIFrames }, { ProjectileID.TruffleSpore, defaultIFrames }, - { ProjectileID.Typhoon, Do(IDStaticIFrames(6)) }, // Has an exception in Vanilla iframe code, uses 6 iframes { ProjectileID.UFOLaser, defaultIFrames }, { ProjectileID.UFOMinion, defaultIFrames }, { ProjectileID.UnholyArrow, defaultIFrames }, @@ -866,6 +865,18 @@ namespace CalamityMod.Projectiles internal static IProjectileTweak ScaleRatio(float f) => new ScaleRatioRule(f); #endregion + #region Single Hit Immunity + internal class SingleHitImmunityRule : IProjectileTweak + { + internal readonly bool flag = false; + + public SingleHitImmunityRule(bool imm) => flag = imm; + public bool AppliesTo(Projectile proj) => true; + public void ApplyTweak(Projectile proj) => proj.appliesImmunityTimeOnSingleHits = flag; + } + internal static IProjectileTweak SingleHitImmunity => new SingleHitImmunityRule(true); + #endregion + #region Tile Collide internal class TileCollideRule : IProjectileTweak { diff --git a/Projectiles/DraedonsArsenal/CountermeasureMittHoldout.cs b/Projectiles/DraedonsArsenal/CountermeasureMittHoldout.cs index 1afbee1b94..aae9fd3773 100644 --- a/Projectiles/DraedonsArsenal/CountermeasureMittHoldout.cs +++ b/Projectiles/DraedonsArsenal/CountermeasureMittHoldout.cs @@ -103,7 +103,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal Vector2 handPos = Owner.GetBackHandPosition(CompositeArmStretchAmount.None, Owner.compositeBackArm.rotation) + (Owner.compositeBackArm.rotation + MathHelper.PiOver2).ToRotationVector2() * 9; // Every laser has collision for the single hitbox, so it works more like a large wide piercing single beam - float beamLength = 1500 * Projectile.scale; + float beamLength = 2000 * Projectile.scale; float beamThickness = 20 * Projectile.scale; float fingerLength = 6 * Projectile.scale; float _ = float.NaN; @@ -562,8 +562,9 @@ namespace CalamityMod.Projectiles.DraedonsArsenal Main.EntitySpriteDraw(finger, basePosition - Main.screenPosition, null, fingerColor, alteredRotation + rot, fingerOrgin, fingerScale, SpriteEffects.None); Vector2 velocity = (alteredRotation + rot).ToRotationVector2(); - Main.EntitySpriteDraw(laser, basePosition - Main.screenPosition + velocity * 545 * Projectile.scale, null, Effects.ArsenalEffects.ArsenalLaserColor with { A = 0 } * fx, velocity.ToRotation() + MathHelper.PiOver2, laser.Size() / 2, new Vector2(2.5f * randSize * fx, 55f) * Projectile.scale * 0.01f, SpriteEffects.FlipVertically); - Main.EntitySpriteDraw(laser2, basePosition - Main.screenPosition + velocity * 545 * Projectile.scale, null, Color.Lerp(Effects.ArsenalEffects.ArsenalLaserColor, Color.White, 0.3f) with { A = 0 } * fx, velocity.ToRotation() + MathHelper.PiOver2, laser2.Size() / 2, new Vector2(0.4f * Math.Min(fx, 1), 55f) * Projectile.scale * 0.01f, SpriteEffects.FlipVertically); + float laserLength = 2.5f; + Main.EntitySpriteDraw(laser, basePosition - Main.screenPosition + velocity * 542 * laserLength * Projectile.scale, null, Effects.ArsenalEffects.ArsenalLaserColor with { A = 0 } * fx, velocity.ToRotation() + MathHelper.PiOver2, laser.Size() / 2, new Vector2(2.5f * randSize * fx, 55 * laserLength) * Projectile.scale * 0.01f, SpriteEffects.FlipVertically); + Main.EntitySpriteDraw(laser2, basePosition - Main.screenPosition + velocity * 542 * laserLength * Projectile.scale, null, Color.Lerp(Effects.ArsenalEffects.ArsenalLaserColor, Color.White, 0.3f) with { A = 0 } * fx, velocity.ToRotation() + MathHelper.PiOver2, laser2.Size() / 2, new Vector2(0.4f * Math.Min(fx, 1), 55 * laserLength) * Projectile.scale * 0.01f, SpriteEffects.FlipVertically); for (int y = 0; y < 2; y++) Main.EntitySpriteDraw(bloom, basePosition - Main.screenPosition + velocity * 7 * Projectile.scale, null, Color.Lerp(Effects.ArsenalEffects.ArsenalLaserColor, Color.White, y) with { A = 0 } * (fx - 1), velocity.ToRotation() + MathHelper.PiOver2, bloom.Size() / 2, new Vector2(2 + 0.05f * (fx + 25), 1) * Projectile.scale * MathHelper.Lerp(fx, 1, 0.7f) * (0.03f - 0.01f * y), SpriteEffects.FlipVertically); diff --git a/Projectiles/Healing/BloodstoneHealOrb.cs b/Projectiles/Healing/BloodstoneHealOrb.cs index c0073ab719..ea9f4b67c6 100644 --- a/Projectiles/Healing/BloodstoneHealOrb.cs +++ b/Projectiles/Healing/BloodstoneHealOrb.cs @@ -2,6 +2,7 @@ using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; +using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; @@ -106,7 +107,7 @@ namespace CalamityMod.Projectiles.Healing player.lifeRegenTime += 3*PotionTime; //if Potion Sickness is full, each orb speeds up natural regen } - Particle ring = new CustomPulse(player.Center, Vector2.Zero, new Color(255, 32, 32)*0.75f, "CalamityMod/Particles/DustyCircleHardEdge", Vector2.One, 0, 0.01f, 0.05f, 20); + Particle ring = new CustomPulse(player.Center, Vector2.Zero, (!ChildSafety.Disabled ? Color.CornflowerBlue : new Color(255, 32, 32)) * 0.75f, "CalamityMod/Particles/DustyCircleHardEdge", Vector2.One, 0, 0.01f, 0.05f, 20); GeneralParticleHandler.SpawnParticle(ring); } diff --git a/Projectiles/Magic/HyperdeathRiftScepterBeam.cs b/Projectiles/Magic/HyperdeathRiftScepterBeam.cs index 284db13562..3a44dcb13b 100644 --- a/Projectiles/Magic/HyperdeathRiftScepterBeam.cs +++ b/Projectiles/Magic/HyperdeathRiftScepterBeam.cs @@ -45,6 +45,7 @@ namespace CalamityMod.Projectiles.Magic Projectile.scale = 2; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = -1; + Projectile.DamageType = DamageClass.Magic; } public override void AI() { diff --git a/Projectiles/Magic/SanguineFlareProj.cs b/Projectiles/Magic/SanguineFlareProj.cs index 10dd0573ca..3bc8b0fa71 100644 --- a/Projectiles/Magic/SanguineFlareProj.cs +++ b/Projectiles/Magic/SanguineFlareProj.cs @@ -7,6 +7,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; +using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; @@ -74,12 +75,12 @@ namespace CalamityMod.Projectiles.Magic } float particleSize = (dmgMult * 5 + 5)/2f; - Particle beam3 = new CustomSpark(Projectile.Center, -Projectile.velocity * 0.1f, "CalamityMod/Particles/PearlParticleGlow", false, 10, 0.05f * particleSize, Color.DarkRed, new Vector2(0.5f, 1), false, false, 0, false, false, 0f); + Particle beam3 = new CustomSpark(Projectile.Center, -Projectile.velocity * 0.1f, "CalamityMod/Particles/PearlParticleGlow", false, 10, 0.05f * particleSize, (!ChildSafety.Disabled ? Color.CornflowerBlue : Color.DarkRed), new Vector2(0.5f, 1), false, false, 0, false, false, 0f); GeneralParticleHandler.SpawnParticle(beam3); if (Main.rand.NextBool(8)) { - Particle beam4 = new CustomSpark(Projectile.Center, Projectile.velocity * 0.1f, "CalamityMod/Particles/WaterFoam", false, 5, 0.01f * particleSize, Color.Red, new Vector2(1f, 1), true, false, Main.rand.NextFloat(-10, 10), false, false, 0f); + Particle beam4 = new CustomSpark(Projectile.Center, Projectile.velocity * 0.1f, "CalamityMod/Particles/WaterFoam", false, 5, 0.01f * particleSize, (!ChildSafety.Disabled ? Color.CornflowerBlue : Color.Red), new Vector2(1f, 1), true, false, Main.rand.NextFloat(-10, 10), false, false, 0f); GeneralParticleHandler.SpawnParticle(beam4); } } @@ -101,7 +102,7 @@ namespace CalamityMod.Projectiles.Magic Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); for (int i = 0; i < 3; i++) { - int brimDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1.2f); + int brimDust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, (!ChildSafety.Disabled ? DustID.Cloud : (int)CalamityDusts.Brimstone), 0f, 0f, 100, default, 1.2f); Main.dust[brimDust].velocity *= 3f; if (Main.rand.NextBool()) { @@ -111,10 +112,10 @@ namespace CalamityMod.Projectiles.Magic } for (int j = 0; j < 6; j++) { - int brimDust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1.7f); + int brimDust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, (!ChildSafety.Disabled ? DustID.Cloud : (int)CalamityDusts.Brimstone), 0f, 0f, 100, default, 1.7f); Main.dust[brimDust2].noGravity = true; Main.dust[brimDust2].velocity *= 5f; - brimDust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1f); + brimDust2 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, (!ChildSafety.Disabled ? DustID.Cloud : (int)CalamityDusts.Brimstone), 0f, 0f, 100, default, 1f); Main.dust[brimDust2].velocity *= 2f; } } @@ -140,9 +141,9 @@ namespace CalamityMod.Projectiles.Magic Projectile.timeLeft = 2; Projectile.velocity *= 0; Projectile.damage /= 2; - Particle bloodsplosion = new CustomPulse(Projectile.Center, Vector2.Zero, Color.DarkRed*0.75f, "CalamityMod/Particles/DetailedExplosion", Vector2.One, Main.rand.NextFloat(-15f, 15f), 0.16f*dmgMult/5f, 0.87f * dmgMult / 5f, (int)(40 * 0.38f), false); + Particle bloodsplosion = new CustomPulse(Projectile.Center, Vector2.Zero, (!ChildSafety.Disabled ? Color.CornflowerBlue : Color.DarkRed) * 0.75f, "CalamityMod/Particles/DetailedExplosion", Vector2.One, Main.rand.NextFloat(-15f, 15f), 0.16f*dmgMult/5f, 0.87f * dmgMult / 5f, (int)(40 * 0.38f), false); GeneralParticleHandler.SpawnParticle(bloodsplosion); - Particle bloodsplosion2 = new CustomPulse(Projectile.Center, Vector2.Zero, new Color(255, 32, 32)*0.5f, "CalamityMod/Particles/DustyCircleHardEdge", Vector2.One, Main.rand.NextFloat(-15f, 15f), 0.03f * dmgMult / 5f, 0.155f * dmgMult / 5f, 40); + Particle bloodsplosion2 = new CustomPulse(Projectile.Center, Vector2.Zero, (!ChildSafety.Disabled ? Color.CornflowerBlue : new Color(255, 32, 32)) * 0.5f, "CalamityMod/Particles/DustyCircleHardEdge", Vector2.One, Main.rand.NextFloat(-15f, 15f), 0.03f * dmgMult / 5f, 0.155f * dmgMult / 5f, 40); GeneralParticleHandler.SpawnParticle(bloodsplosion2); } } @@ -158,7 +159,7 @@ namespace CalamityMod.Projectiles.Magic for (int i = 0; i < 1; i++) { //Photoviscerator drawcode, edited slightly - Color color = Color.DarkRed * (dmgMult/5f); + Color color = (!ChildSafety.Disabled ? Color.CornflowerBlue : Color.DarkRed) * (dmgMult/5f); color.A = 0; Vector2 drawPosition = Projectile.oldPos[i]+Projectile.Size /2f + lightTexture.Size() * 0.5f - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY) + new Vector2(-32.5f, -32.5f); //Last vector is to offset the circle so that it is displayed where the hitbox actually is, instead of a bit down and to the right. Color outerColor = color; diff --git a/Projectiles/Magic/VisceraBeam.cs b/Projectiles/Magic/VisceraBeam.cs index b68e52be1a..f726ce6b28 100644 --- a/Projectiles/Magic/VisceraBeam.cs +++ b/Projectiles/Magic/VisceraBeam.cs @@ -1,12 +1,13 @@ -using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Items.Weapons.Magic; using CalamityMod.Particles; +using CalamityMod.Projectiles.Healing; using Microsoft.Xna.Framework; using Terraria; +using Terraria.Audio; +using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; -using Terraria.Audio; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Projectiles.Healing; namespace CalamityMod.Projectiles.Magic { @@ -15,6 +16,7 @@ namespace CalamityMod.Projectiles.Magic public new string LocalizationCategory => "Projectiles.Magic"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + private int storedPenetrate; public override void SetStaticDefaults() { ProjectileID.Sets.TrailCacheLength[Type] = 20; @@ -28,7 +30,7 @@ namespace CalamityMod.Projectiles.Magic Projectile.friendly = true; Projectile.DamageType = DamageClass.Magic; Projectile.ignoreWater = true; - Projectile.penetrate = 7; + storedPenetrate = Projectile.penetrate = 7; Projectile.MaxUpdates = 100; Projectile.timeLeft = 900; Projectile.usesLocalNPCImmunity = true; @@ -47,7 +49,7 @@ namespace CalamityMod.Projectiles.Magic } for (int i = 0; i <= 15; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool() ? 60 : DustID.Blood); + Dust dust = Dust.NewDustPerfect(Projectile.Center, (!ChildSafety.Disabled ? DustID.Cloud : (Main.rand.NextBool() ? 60 : DustID.Blood))); dust.position = Projectile.Center; dust.scale = Main.rand.NextFloat(0.8f, 1.3f); dust.velocity = new Vector2(7, 7).RotatedByRandom(100) * Main.rand.NextFloat(0.1f, 0.9f); @@ -62,41 +64,15 @@ namespace CalamityMod.Projectiles.Magic if (Projectile.ai[1] > 0) { - SoundStyle hitSound = new("CalamityMod/Sounds/NPCKilled/PerfLargeDeath"); - SoundEngine.PlaySound(hitSound with { Volume = 0.5f }, Projectile.Center); - for (int i = 0; i <= 14; i++) - { - BloodParticle blood = new BloodParticle(Projectile.Center, new Vector2(15, 15).RotatedByRandom(100) * Main.rand.NextFloat(0.1f, 0.9f) + new Vector2(0, -7), 60, Main.rand.NextFloat(0.4f, 0.65f), Color.Red); - GeneralParticleHandler.SpawnParticle(blood); - } - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 0.75f), Projectile.knockBack * 4, Projectile.owner, 0f, Projectile.ai[1]); - - Particle bloodsplosion = new CustomPulse(Projectile.Center, Vector2.Zero, Color.DarkRed, "CalamityMod/Particles/DetailedExplosion", Vector2.One, Main.rand.NextFloat(-15f, 15f), 0.16f, 0.87f, (int)(Viscera.BoomLifetime * 0.38f), false); - GeneralParticleHandler.SpawnParticle(bloodsplosion); - Particle bloodsplosion2 = new CustomPulse(Projectile.Center, Vector2.Zero, new Color(255, 32, 32), "CalamityMod/Particles/DustyCircleHardEdge", Vector2.One, Main.rand.NextFloat(-15f, 15f), 0.03f, 0.155f, Viscera.BoomLifetime); - GeneralParticleHandler.SpawnParticle(bloodsplosion2); - } - else - { - SoundStyle hitSound = new("CalamityMod/Sounds/NPCHit/PerfLargeHit", 3); - SoundEngine.PlaySound(hitSound with { Volume = 0.7f }, Projectile.Center); - - for (int i = 0; i <= 6; i++) - { - Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool() ? 60 : DustID.Blood); - dust.scale = Main.rand.NextFloat(0.7f, 1.4f); - dust.velocity = Projectile.velocity.RotatedByRandom(0.5) * Main.rand.NextFloat(0.8f, 1.9f); - dust.noGravity = true; - } - } - if (Projectile.ai[2] < 1){ - for (int i = 0; i < 2; i++) { - Projectile.NewProjectile(Projectile.GetSource_OnHit(target), Projectile.Center, -Projectile.velocity.SafeNormalize(Vector2.Zero).RotatedByRandom(0.5f) * Main.rand.NextFloat(3, 5), ModContent.ProjectileType(), 5, 0f, Projectile.owner); - } - Projectile.ai[2]++; } + if (Projectile.ai[2] < 1) + { + for (int i = 0; i < 2; i++) + Projectile.NewProjectile(Projectile.GetSource_OnHit(target), Projectile.Center, -Projectile.velocity.SafeNormalize(Vector2.Zero).RotatedByRandom(0.5f) * Main.rand.NextFloat(3, 5), ModContent.ProjectileType(), 5, 0f, Projectile.owner); + Projectile.ai[2]++; + } } public override void AI() @@ -107,6 +83,22 @@ namespace CalamityMod.Projectiles.Magic if (Projectile.ai[1] > 0) Projectile.penetrate = 1; + // On-hit effects of piercing beams + if (Projectile.ai[1] == 0f && Projectile.penetrate != storedPenetrate) + { + SoundStyle hitSound = new("CalamityMod/Sounds/NPCHit/PerfLargeHit", 3); + SoundEngine.PlaySound(hitSound with { Volume = 0.7f }, Projectile.Center); + + for (int i = 0; i <= 6; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, (!ChildSafety.Disabled ? DustID.Cloud : (Main.rand.NextBool() ? 60 : DustID.Blood))); + dust.scale = Main.rand.NextFloat(0.7f, 1.4f); + dust.velocity = Projectile.velocity.RotatedByRandom(0.5) * Main.rand.NextFloat(0.8f, 1.9f); + dust.noGravity = true; + } + storedPenetrate = Projectile.penetrate; + } + Projectile.localAI[0] += 1f; if (Projectile.localAI[0] == 16f) { @@ -114,7 +106,7 @@ namespace CalamityMod.Projectiles.Magic { for (int i = 0; i <= 25; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool() ? 60 : DustID.Blood); + Dust dust = Dust.NewDustPerfect(Projectile.Center, (!ChildSafety.Disabled ? DustID.Cloud : (Main.rand.NextBool() ? 60 : DustID.Blood))); dust.scale = Main.rand.NextFloat(0.9f, 1.9f); dust.velocity = Projectile.velocity.RotatedByRandom(0.6) * Main.rand.NextFloat(1.8f, 2.9f); dust.noGravity = true; @@ -124,7 +116,7 @@ namespace CalamityMod.Projectiles.Magic { for (int i = 0; i <= 10; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool() ? 60 : DustID.Blood); + Dust dust = Dust.NewDustPerfect(Projectile.Center, (!ChildSafety.Disabled ? DustID.Cloud : (Main.rand.NextBool() ? 60 : DustID.Blood))); dust.scale = Main.rand.NextFloat(0.7f, 1.4f); dust.velocity = Projectile.velocity.RotatedByRandom(0.6) * Main.rand.NextFloat(0.8f, 1.9f); dust.noGravity = true; @@ -133,16 +125,16 @@ namespace CalamityMod.Projectiles.Magic } if (Projectile.localAI[0] > 16f) { - int bloody = Dust.NewDust(Projectile.Center, 1, 1, DustID.Blood); + int bloody = Dust.NewDust(Projectile.Center, 1, 1, (!ChildSafety.Disabled ? DustID.Cloud : DustID.Blood)); Main.dust[bloody].position = Projectile.Center + Main.rand.NextVector2Circular(8, 8); Main.dust[bloody].scale = Main.rand.NextFloat(0.3f, 0.8f); Main.dust[bloody].velocity = -Projectile.velocity * Main.rand.NextFloat(0.3f, 0.6f); Main.dust[bloody].noGravity = true; if (Projectile.localAI[0] % 3 == 0 && targetDist < 1400f) { - AltSparkParticle spark = new AltSparkParticle(Projectile.Center - Projectile.velocity * 0.5f, Projectile.velocity * 0.01f, false, 7, 0.8f, Color.DarkRed); + AltSparkParticle spark = new AltSparkParticle(Projectile.Center - Projectile.velocity * 0.5f, Projectile.velocity * 0.01f, false, 7, 0.8f, (!ChildSafety.Disabled ? Color.CornflowerBlue : Color.DarkRed)); GeneralParticleHandler.SpawnParticle(spark); - SparkParticle spark2 = new SparkParticle(Projectile.Center - Projectile.velocity * 0.5f, Projectile.velocity * 0.01f, false, 4, 0.65f, Color.Red); + SparkParticle spark2 = new SparkParticle(Projectile.Center - Projectile.velocity * 0.5f, Projectile.velocity * 0.01f, false, 4, 0.65f, (!ChildSafety.Disabled ? Color.CornflowerBlue : Color.Red)); GeneralParticleHandler.SpawnParticle(spark2); } } diff --git a/Projectiles/Magic/VisceraBoom.cs b/Projectiles/Magic/VisceraBoom.cs index 4bfebc2c25..016ca5fa36 100644 --- a/Projectiles/Magic/VisceraBoom.cs +++ b/Projectiles/Magic/VisceraBoom.cs @@ -1,9 +1,12 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; -using Terraria.ModLoader; +using Terraria.Audio; +using Terraria.GameContent; using Terraria.ID; +using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { @@ -24,10 +27,28 @@ namespace CalamityMod.Projectiles.Magic } public override void AI() { + // Visual effects + if (Projectile.ai[0] == 0f) + { + SoundStyle hitSound = new("CalamityMod/Sounds/NPCKilled/PerfLargeDeath"); + SoundEngine.PlaySound(hitSound with { Volume = 0.5f }, Projectile.Center); + for (int i = 0; i <= 14; i++) + { + BloodParticle blood = new BloodParticle(Projectile.Center, new Vector2(15, 15).RotatedByRandom(100) * Main.rand.NextFloat(0.1f, 0.9f) + new Vector2(0, -7), 60, Main.rand.NextFloat(0.4f, 0.65f), (!ChildSafety.Disabled ? Color.CornflowerBlue : Color.Red)); + GeneralParticleHandler.SpawnParticle(blood); + } + Particle bloodsplosion = new CustomPulse(Projectile.Center, Vector2.Zero, (!ChildSafety.Disabled ? Color.CornflowerBlue : Color.DarkRed), "CalamityMod/Particles/DetailedExplosion", Vector2.One, Main.rand.NextFloat(-15f, 15f), 0.16f, 0.87f, (int)(Viscera.BoomLifetime * 0.38f), false); + GeneralParticleHandler.SpawnParticle(bloodsplosion); + Particle bloodsplosion2 = new CustomPulse(Projectile.Center, Vector2.Zero, (!ChildSafety.Disabled ? Color.CornflowerBlue : new Color(255, 32, 32)), "CalamityMod/Particles/DustyCircleHardEdge", Vector2.One, Main.rand.NextFloat(-15f, 15f), 0.03f, 0.155f, Viscera.BoomLifetime); + GeneralParticleHandler.SpawnParticle(bloodsplosion2); + + Projectile.ai[0] = 1f; + } + for (int i = 0; i <= 2; i++) { float speed = Projectile.ai[1] > 0 ? 25 : 15; - Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool() ? 60 : DustID.Blood); + Dust dust = Dust.NewDustPerfect(Projectile.Center, (!ChildSafety.Disabled ? DustID.Cloud : (Main.rand.NextBool() ? 60 : DustID.Blood))); dust.scale = Main.rand.NextFloat(1f, 2f) * Utils.GetLerpValue(0, Viscera.BoomLifetime, Projectile.timeLeft, true); dust.velocity = new Vector2(speed, speed).RotatedByRandom(100) * Main.rand.NextFloat(0.1f, 0.9f); dust.noGravity = true; diff --git a/Projectiles/Magic/VortexElementalBeam.cs b/Projectiles/Magic/VortexElementalBeam.cs index d1ee143217..eb629f3b49 100644 --- a/Projectiles/Magic/VortexElementalBeam.cs +++ b/Projectiles/Magic/VortexElementalBeam.cs @@ -23,7 +23,6 @@ namespace CalamityMod.Projectiles.Magic public override void SetStaticDefaults() { - ProjectileID.Sets.MinionShot[Type] = true; ProjectileID.Sets.TrailCacheLength[Type] = 30; ProjectileID.Sets.TrailingMode[Type] = 1; } diff --git a/Projectiles/Melee/DevilsDevastationHoldout.cs b/Projectiles/Melee/DevilsDevastationHoldout.cs index 4afc753248..501bccd737 100644 --- a/Projectiles/Melee/DevilsDevastationHoldout.cs +++ b/Projectiles/Melee/DevilsDevastationHoldout.cs @@ -119,7 +119,7 @@ namespace CalamityMod.Projectiles.Melee Vector2 vel = (MathHelper.TwoPi * i / 4f).ToRotationVector2() * 2; Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), lastHitTarget.Center, vel.RotatedBy(MathHelper.ToRadians(45)), ModContent.ProjectileType(), 0, 0f, Owner.whoAmI, 1, 0); } - Projectile strike = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), lastHitTarget.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 1.5f), 0f, Owner.whoAmI, lastHitTarget.whoAmI, 0); + Projectile strike = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), lastHitTarget.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 1.666f), 0f, Owner.whoAmI, lastHitTarget.whoAmI, 0); strike.DamageType = DamageClass.Melee; SoundStyle dieSound = new("CalamityMod/Sounds/Item/LanceofDestinyStrong"); SoundEngine.PlaySound(dieSound with { Volume = 0.9f, Pitch = 0.3f }, lastHitTarget.Center); @@ -207,6 +207,9 @@ namespace CalamityMod.Projectiles.Melee AnimationProgress = Animation % useAnim; + if (isOwner && !holding && Main.netMode != NetmodeID.SinglePlayer && (int)Animation % 3 == 0) + Projectile.netUpdate = true; + if (CanHit || postSwing) mousePos = Owner.Center - aimVel; else @@ -514,6 +517,7 @@ namespace CalamityMod.Projectiles.Melee writer.Write7BitEncodedInt(lastHitTargetIndex); writer.Write7BitEncodedInt(postSwingCooldown); writer.WriteVector2(aimVel); + writer.Write(Animation); } public override void ReceiveExtraAI(BinaryReader reader) @@ -523,6 +527,7 @@ namespace CalamityMod.Projectiles.Melee lastHitTargetIndex = reader.Read7BitEncodedInt(); postSwingCooldown = reader.Read7BitEncodedInt(); aimVel = reader.ReadVector2(); + Animation = reader.ReadSingle(); mousePos = Owner.Center - aimVel; } } diff --git a/Projectiles/Melee/ForbiddenOathbladeHoldout.cs b/Projectiles/Melee/ForbiddenOathbladeHoldout.cs index 53d71b3602..b4088066bc 100644 --- a/Projectiles/Melee/ForbiddenOathbladeHoldout.cs +++ b/Projectiles/Melee/ForbiddenOathbladeHoldout.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.IO; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Cooldowns; @@ -156,6 +156,9 @@ namespace CalamityMod.Projectiles.Melee AnimationProgress = Animation % useAnim; + if (isOwner && !holding && Main.netMode != NetmodeID.SinglePlayer && (int)Animation % 3 == 0) + Projectile.netUpdate = true; + if (CanHit || postSwing) mousePos = Owner.Center - aimVel; else @@ -394,15 +397,19 @@ namespace CalamityMod.Projectiles.Melee public override void SendExtraAI(BinaryWriter writer) { writer.Write(willDie); + writer.Write7BitEncodedInt(useAnim); writer.Write7BitEncodedInt(postSwingCooldown); writer.WriteVector2(aimVel); + writer.Write(Animation); } public override void ReceiveExtraAI(BinaryReader reader) { willDie = reader.ReadBoolean(); + useAnim = reader.Read7BitEncodedInt(); postSwingCooldown = reader.Read7BitEncodedInt(); aimVel = reader.ReadVector2(); + Animation = reader.ReadSingle(); mousePos = Owner.Center - aimVel; } } diff --git a/Projectiles/Melee/GrandDadHoldout.cs b/Projectiles/Melee/GrandDadHoldout.cs index f1151eec3a..cd7d39d564 100644 --- a/Projectiles/Melee/GrandDadHoldout.cs +++ b/Projectiles/Melee/GrandDadHoldout.cs @@ -250,14 +250,14 @@ namespace CalamityMod.Projectiles.Melee // Launch the suckers Vector2 launchVel = Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld); - float launchPower = (Main.zenithWorld ? 50 : 30) * (rightClicked ? 2 : 1); + float launchPower = 30 * (rightClicked ? 2 : 1); target.MoveNPC(launchVel, launchPower * 0.5f, true); // Remove knockback resist, just like it used to target.knockBackResist = 1; - // Apply tile collison damage (is boosted on GFB and even further if both final bosses are gone) - float damageMults = ((DownedBossSystem.downedCalamitas && DownedBossSystem.downedExoMechs) ? 5 : 1) * (Main.zenithWorld ? 77 : 1) * (rightClicked ? 3 : 1); + // Apply tile collison damage (is boosted even further if both final bosses are gone) + float damageMults = ((DownedBossSystem.downedCalamitas && DownedBossSystem.downedExoMechs) ? 5 : 1) * (rightClicked ? 3 : 1); int damage = (int)(Projectile.damage * damageMults); target.GetGlobalNPC().ApplyCollisionDamage(target, Owner, damage, launchVel * launchPower, 5f, true); } diff --git a/Projectiles/Melee/HellkiteHoldout.cs b/Projectiles/Melee/HellkiteHoldout.cs index a9a8633e1d..07c121065c 100644 --- a/Projectiles/Melee/HellkiteHoldout.cs +++ b/Projectiles/Melee/HellkiteHoldout.cs @@ -36,9 +36,6 @@ namespace CalamityMod.Projectiles.Melee public int useAnim; // Used as your use time stat since checking the held item use time gets jank if your attack speed changes mid swing public int storedUseAnim; // Used to check your use time when you began using the item and to reset use time when needed public int swingCount = 0; - public float GFBMulti = 1; // GFB infinite charge particle and damage multiplier - public int GFBCharge = 0; // GFB charge counter - public bool GFBFlashWarning = false; public int pierceReduction = 0; // Used to reduce damage when striking many enemies with a single swing public bool chargedSwing = false; // True if you have a charged swing fully charged @@ -135,19 +132,15 @@ namespace CalamityMod.Projectiles.Melee if (chargeTimer < chargeTimerMax && !chargedSwing) chargeTimer++; - if (Main.zenithWorld) - { - GFBCharge++; - } Vector2 particleVel = (Owner.Center - particlePos).SafeNormalize(Vector2.UnitX) * -15; particlePos += Main.rand.NextVector2Circular(20, 20); Dust dust2 = Dust.NewDustPerfect(particlePos, DustID.RainbowMk2, particleVel * Main.rand.NextFloat(0.2f, 1)); - dust2.scale = Main.rand.NextFloat(0.65f, 1.15f) * fadeIn * GFBMulti; + dust2.scale = Main.rand.NextFloat(0.65f, 1.15f) * fadeIn; dust2.noGravity = true; dust2.color = Main.rand.NextBool(3) ? Color.Orange : Color.OrangeRed; - Particle spark3 = new GlowOrbParticle(particlePos, particleVel * Main.rand.NextFloat(0.2f, 1.5f), false, 22, Main.rand.NextFloat(0.2f, 0.4f) * fadeIn * GFBMulti, Main.rand.NextBool(3) ? Color.Red : Color.OrangeRed); + Particle spark3 = new GlowOrbParticle(particlePos, particleVel * Main.rand.NextFloat(0.2f, 1.5f), false, 22, Main.rand.NextFloat(0.2f, 0.4f) * fadeIn, Main.rand.NextBool(3) ? Color.Red : Color.OrangeRed); GeneralParticleHandler.SpawnParticle(spark3); if (SoundEngine.TryGetActiveSound(AudSlot, out var ChargeSound) && ChargeSound.IsPlaying) @@ -161,7 +154,7 @@ namespace CalamityMod.Projectiles.Melee AudSlot = SoundEngine.PlaySound(Hellkite.ChargeSound with { Volume = 0.01f, Pitch = 0, IsLooped = true }, Projectile.Center); } } - if (chargeTimer == chargeTimerMax || GFBCharge >= (MathHelper.Clamp(chargeTimerMax - (GFBMulti * GFBMulti * 2), 12, 80)) && GFBCharge > 0) + if (chargeTimer == chargeTimerMax) { particlePos = Owner.Center + (bladePos).RotatedBy(FinalRotation + MathHelper.ToRadians(-45)); SoundEngine.PlaySound(Hellkite.FullChargeSound with { Volume = 0.9f, PitchVariance = 0.2f }, Projectile.Center); @@ -169,20 +162,6 @@ namespace CalamityMod.Projectiles.Melee useAnim = storedUseAnim / 3; chargeTimer++; - if (Main.zenithWorld) - { - if (chargeTimerMax - (GFBMulti * GFBMulti * 2) <= 12 && !GFBFlashWarning) - { - SoundStyle w = new("CalamityMod/Sounds/Custom/PlagueSounds/PBGNukeWarning"); - SoundEngine.PlaySound(w with { Volume = 0.5f, Pitch = 1f }, Projectile.Center); - Main.NewText(CalamityUtils.GetTextValue("Misc.LightsWarning"), Color.Orange); - GFBFlashWarning = true; - } - GFBMulti += 0.5f; - Projectile.scale += 0.03f; - GFBCharge = 0; - } - for (int i = 0; i < 20; i++) { Particle spark2 = new LineParticle(particlePos, new Vector2(8, 8).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1f), false, 30, Main.rand.NextFloat(0.3f, 0.8f), Main.rand.NextBool(3) ? Color.Red : Color.OrangeRed); @@ -232,8 +211,6 @@ namespace CalamityMod.Projectiles.Melee postSwing = false; if (AnimationProgress == 0) { - GFBMulti = 1; - GFBCharge = 0; Projectile.scale = 1; Animation = 0; doSwing = false; @@ -376,36 +353,36 @@ namespace CalamityMod.Projectiles.Melee if (Projectile.numHits == 0) { SoundEngine.PlaySound(Hellkite.HitSoundBig with { Volume = 1f }, Projectile.Center); - Owner.SetScreenshake(8.5f * GFBMulti); + Owner.SetScreenshake(8.5f); bool photos = CalamityClientConfig.Instance.Photosensitivity; if (!photos) { for (int i = 0; i < 3; i++) { - Particle blastRing = new CustomPulse(target.Center, Vector2.Zero, Color.OrangeRed, "CalamityMod/Particles/BloomCircle", Vector2.One, Main.rand.NextFloat(-10, 10), 2f * (i + 1) * GFBMulti, 1f, (GFBFlashWarning && !photos) ? (int)(18 * GFBMulti) : 18, true); + Particle blastRing = new CustomPulse(target.Center, Vector2.Zero, Color.OrangeRed, "CalamityMod/Particles/BloomCircle", Vector2.One, Main.rand.NextFloat(-10, 10), 2f * (i + 1), 1f, 18, true); GeneralParticleHandler.SpawnParticle(blastRing); - Particle blastRing2 = new CustomPulse(target.Center, Vector2.Zero, Color.White, "CalamityMod/Particles/BloomCircle", Vector2.One, Main.rand.NextFloat(-10, 10), 1f * (i + 1) * GFBMulti, 0.5f, (GFBFlashWarning && !photos) ? (int)(18 * GFBMulti) : 18, true); + Particle blastRing2 = new CustomPulse(target.Center, Vector2.Zero, Color.White, "CalamityMod/Particles/BloomCircle", Vector2.One, Main.rand.NextFloat(-10, 10), 1f * (i + 1), 0.5f, 18, true); GeneralParticleHandler.SpawnParticle(blastRing2); } } for (int i = 0; i < 2; i++) { - Particle spark = new GlowSparkParticle(target.Center, (Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitY) * -25 * (i == 0 ? -1 : 1), false, 12, 0.08f * (photos ? 1f : GFBMulti), Color.OrangeRed, new Vector2(3, 0.8f), true); + Particle spark = new GlowSparkParticle(target.Center, (Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitY) * -25 * (i == 0 ? -1 : 1), false, 12, 0.08f, Color.OrangeRed, new Vector2(3, 0.8f), true); GeneralParticleHandler.SpawnParticle(spark); } for (int i = 0; i < 15; i++) { - Particle spark2 = new SparkParticle(target.Center, ((Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitY) * -40).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 1f), true, 40, Main.rand.NextFloat(0.5f, 1.2f) * GFBMulti, Main.rand.NextBool(3) ? Color.Orange : Color.OrangeRed); + Particle spark2 = new SparkParticle(target.Center, ((Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitY) * -40).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 1f), true, 40, Main.rand.NextFloat(0.5f, 1.2f), Main.rand.NextBool(3) ? Color.Orange : Color.OrangeRed); GeneralParticleHandler.SpawnParticle(spark2); if (Main.rand.NextBool()) { - Particle spark3 = new AltSparkParticle(target.Center, ((Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitY) * -40).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 1f), true, 40, Main.rand.NextFloat(0.5f, 1.2f) * GFBMulti, Color.DarkRed); + Particle spark3 = new AltSparkParticle(target.Center, ((Owner.Center - Owner.Calamity().mouseWorld).SafeNormalize(Vector2.UnitY) * -40).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 1f), true, 40, Main.rand.NextFloat(0.5f, 1.2f), Color.DarkRed); GeneralParticleHandler.SpawnParticle(spark3); } Dust dust2 = Dust.NewDustPerfect(target.Center, DustID.FireworksRGB, new Vector2(20, 20).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 1)); - dust2.scale = Main.rand.NextFloat(0.55f, 0.85f) * GFBMulti; + dust2.scale = Main.rand.NextFloat(0.55f, 0.85f); dust2.noGravity = true; dust2.color = Main.rand.NextBool(3) ? Color.Orange : Color.OrangeRed; } @@ -424,7 +401,7 @@ namespace CalamityMod.Projectiles.Melee float minMult = 0.25f; int hitsToMinMult = 10; float damageMult = Utils.Remap(pierceReduction, 0, hitsToMinMult, 1, minMult, true); - modifiers.SourceDamage *= (chargedSwing ? (2.9f * GFBMulti + critDamage) : 1) * damageMult; + modifiers.SourceDamage *= (chargedSwing ? (2.9f + critDamage) : 1) * damageMult; } public override bool PreDraw(ref Color lightColor) { diff --git a/Projectiles/Melee/MonstrousKnife.cs b/Projectiles/Melee/MonstrousKnife.cs index 7cfb2d2d45..8f2abedb44 100644 --- a/Projectiles/Melee/MonstrousKnife.cs +++ b/Projectiles/Melee/MonstrousKnife.cs @@ -45,6 +45,6 @@ namespace CalamityMod.Projectiles.Melee } } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => Main.player[Projectile.owner].SpawnLifeStealProjectile(target, Projectile, ProjectileID.VampireHeal, 1, 3f); + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => Main.player[Projectile.owner].SpawnLifeStealProjectile(target, Projectile, ProjectileID.VampireHeal, 1, 4f); //4x cooldown = 23.3 HP bank, 2.25 hp/s refill } } diff --git a/Projectiles/Melee/PrismRay.cs b/Projectiles/Melee/PrismRay.cs index d5a055a2f1..52f1fa29b8 100644 --- a/Projectiles/Melee/PrismRay.cs +++ b/Projectiles/Melee/PrismRay.cs @@ -19,11 +19,6 @@ namespace CalamityMod.Projectiles.Melee public const int Lifetime = 30; public override string Texture => "CalamityMod/Projectiles/StarProj"; - public override void SetStaticDefaults() - { - ProjectileID.Sets.MinionShot[Type] = true; - } - public override void SetDefaults() { Projectile.width = Projectile.height = 14; diff --git a/Projectiles/Melee/RemsRevengeExplosion.cs b/Projectiles/Melee/RemsRevengeExplosion.cs index 9b13c24d12..6289b62d1e 100644 --- a/Projectiles/Melee/RemsRevengeExplosion.cs +++ b/Projectiles/Melee/RemsRevengeExplosion.cs @@ -3,6 +3,7 @@ using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; +using Terraria.GameContent; using Terraria.ModLoader; using static CalamityMod.CalamityUtils; @@ -38,12 +39,12 @@ namespace CalamityMod.Projectiles.Melee for (int i = 0; i < 5; i++) { - Particle explosion = new CustomPulse(Projectile.Center, Vector2.Zero, Color.Lerp(Color.DarkRed, Color.Red, Utils.GetLerpValue(0, 5, i, true)), "CalamityMod/Particles/DetailedExplosion", Vector2.One, Main.rand.NextFloat(MathHelper.TwoPi), 0f, 0.5f + 0.03f * i, (int)(20 - i * 1.5f)); + Particle explosion = new CustomPulse(Projectile.Center, Vector2.Zero, (!ChildSafety.Disabled ? Color.CornflowerBlue : (Color.Lerp(Color.DarkRed, Color.Red, Utils.GetLerpValue(0, 5, i, true)))), "CalamityMod/Particles/DetailedExplosion", Vector2.One, Main.rand.NextFloat(MathHelper.TwoPi), 0f, 0.5f + 0.03f * i, (int)(20 - i * 1.5f)); GeneralParticleHandler.SpawnParticle(explosion); } for (int i = 0; i < 3; i++) { - Particle explosion = new CustomPulse(Projectile.Center, Vector2.Zero, Color.Lerp(Color.DarkRed, Color.Red, Utils.GetLerpValue(0, 3, i, true)), "CalamityMod/Projectiles/FireProj", Vector2.One, Main.rand.NextFloat(MathHelper.TwoPi), 0f, 2f + 0.22f * i, (int)(20 - i * 2f)); + Particle explosion = new CustomPulse(Projectile.Center, Vector2.Zero, (!ChildSafety.Disabled ? Color.CornflowerBlue : (Color.Lerp(Color.DarkRed, Color.Red, Utils.GetLerpValue(0, 3, i, true)))), "CalamityMod/Projectiles/FireProj", Vector2.One, Main.rand.NextFloat(MathHelper.TwoPi), 0f, 2f + 0.22f * i, (int)(20 - i * 2f)); GeneralParticleHandler.SpawnParticle(explosion); } @@ -54,7 +55,7 @@ namespace CalamityMod.Projectiles.Melee { Vector2 velocity = Vector2.UnitX.RotatedByRandom(MathHelper.Pi) * Main.rand.NextFloat(8f, 12f); float scale = Main.rand.NextFloat(0.6f, 2f); - Particle blood = new BloodParticle(Projectile.Center, velocity, 30, scale, Color.DarkRed); + Particle blood = new BloodParticle(Projectile.Center, velocity, 30, scale, !ChildSafety.Disabled ? Color.CornflowerBlue : Color.DarkRed); GeneralParticleHandler.SpawnParticle(blood); } } diff --git a/Projectiles/Melee/Shortswords/GalileoGladiusThrown.cs b/Projectiles/Melee/Shortswords/GalileoGladiusThrown.cs index 83f946ec7a..ae618ec5b3 100644 --- a/Projectiles/Melee/Shortswords/GalileoGladiusThrown.cs +++ b/Projectiles/Melee/Shortswords/GalileoGladiusThrown.cs @@ -140,7 +140,7 @@ namespace CalamityMod.Projectiles.Melee.Shortswords { for (var i = 0; i < 10; i++) GeneralParticleHandler.SpawnParticle(new SparkParticle(Projectile.Center, (Projectile.rotation-MathHelper.PiOver4).ToRotationVector2().RotatedByRandom(0.4f) * -Main.rand.Next(10,20), false, 30, 2, new Color(69, 69, 200))); - Projectile.damage = (int)(Projectile.damage*15f); + Projectile.damage = (int)(Projectile.damage*10f); Projectile.Damage(); Owner.Calamity().StratusStarburst -= 10; for (int i = 0; i < 3; i++) @@ -153,6 +153,7 @@ namespace CalamityMod.Projectiles.Melee.Shortswords Main.projectile[proj].usesIDStaticNPCImmunity = false; Main.projectile[proj].usesLocalNPCImmunity = true; Main.projectile[proj].localNPCHitCooldown = 20; + Main.projectile[proj].timeLeft = Main.projectile[proj].MaxUpdates * 600; } } Projectile.velocity = (Projectile.rotation - MathHelper.PiOver4).ToRotationVector2() * -15; @@ -184,7 +185,7 @@ namespace CalamityMod.Projectiles.Melee.Shortswords Projectile.damage = Projectile.originalDamage; if (Owner.Calamity().AvaliableStarburst >= 20) { - Projectile.damage = (int)(Projectile.damage* 30f); + Projectile.damage = (int)(Projectile.damage*20f); Owner.SetImmuneTimeForAllTypes(Owner.longInvince ? 40 : 20); Owner.Calamity().StratusStarburst -= 20; SoundEngine.PlaySound(SoundID.DD2_MonkStaffGroundImpact, Owner.Center); @@ -201,6 +202,8 @@ namespace CalamityMod.Projectiles.Melee.Shortswords Main.projectile[proj].usesIDStaticNPCImmunity = false; Main.projectile[proj].usesLocalNPCImmunity = true; Main.projectile[proj].localNPCHitCooldown = 20; + Main.projectile[proj].timeLeft = Main.projectile[proj].MaxUpdates * 600; + } } } diff --git a/Projectiles/Melee/TerratomereMeleeSlash.cs b/Projectiles/Melee/TerratomereMeleeSlash.cs index 50dc9223d7..b2f2369edb 100644 --- a/Projectiles/Melee/TerratomereMeleeSlash.cs +++ b/Projectiles/Melee/TerratomereMeleeSlash.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using CalamityMod.Graphics.Primitives; using Microsoft.Xna.Framework; using Terraria; diff --git a/Projectiles/Melee/TerratomereSlash.cs b/Projectiles/Melee/TerratomereSlash.cs index 4dcd4bc317..e41a5df07b 100644 --- a/Projectiles/Melee/TerratomereSlash.cs +++ b/Projectiles/Melee/TerratomereSlash.cs @@ -1,4 +1,4 @@ -using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Items.Weapons.Melee; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; diff --git a/Projectiles/Melee/TheMutilatorHoldoutProjectile.cs b/Projectiles/Melee/TheMutilatorHoldoutProjectile.cs index 843103b40d..13d64dee45 100644 --- a/Projectiles/Melee/TheMutilatorHoldoutProjectile.cs +++ b/Projectiles/Melee/TheMutilatorHoldoutProjectile.cs @@ -1,15 +1,16 @@ using System; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Items.Weapons.Melee; -using Microsoft.Xna.Framework; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.ModLoader; -using Terraria; +using CalamityMod.Particles; using CalamityMod.Projectiles.BaseProjectiles; using CalamityMod.Projectiles.Healing; +using Microsoft.Xna.Framework; +using Terraria; using Terraria.Audio; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Particles; +using Terraria.DataStructures; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { @@ -99,7 +100,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.NewProjectile(Projectile.GetSource_OnHit(target), target.Center, -angle.RotatedByRandom(spreadAmount) * 3.5f * Main.rand.NextFloat(0.75f, 1.25f), ModContent.ProjectileType(), 20, 0f, player.whoAmI); } - Particle bloodsplosion2 = new CustomPulse(target.Center, Vector2.Zero, new Color(255, 32, 32) * 0.75f, "CalamityMod/Particles/DustyCircleHardEdge", Vector2.One, Main.rand.NextFloat(-15f, 15f), 0.03f, 0.155f, 40); + Particle bloodsplosion2 = new CustomPulse(target.Center, Vector2.Zero, (!ChildSafety.Disabled ? Color.CornflowerBlue : new Color(255, 32, 32)) * 0.75f, "CalamityMod/Particles/DustyCircleHardEdge", Vector2.One, Main.rand.NextFloat(-15f, 15f), 0.03f, 0.155f, 40); GeneralParticleHandler.SpawnParticle(bloodsplosion2); SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/BloodPactCrit") { Volume = 0.5f }, player.Center); } diff --git a/Projectiles/Melee/Yoyos/LaceratorYoyo.cs b/Projectiles/Melee/Yoyos/LaceratorYoyo.cs index fb0fb6b52a..96c173fec5 100644 --- a/Projectiles/Melee/Yoyos/LaceratorYoyo.cs +++ b/Projectiles/Melee/Yoyos/LaceratorYoyo.cs @@ -48,18 +48,17 @@ namespace CalamityMod.Projectiles.Melee.Yoyos Projectile.MaxUpdates = MaxUpdates; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 6 * MaxUpdates; - } public override void SendExtraAI(BinaryWriter writer) { writer.Write(chargeProgress); } - public override void ReceiveExtraAI(BinaryReader reader) { - chargeProgress = reader.ReadInt32(); + chargeProgress = reader.ReadSingle(); } + public override void AI() { if (sawDir == 0) diff --git a/Projectiles/Melee/Yoyos/OracleYoyo.cs b/Projectiles/Melee/Yoyos/OracleYoyo.cs index 3d4fce1963..3c3f9778c5 100644 --- a/Projectiles/Melee/Yoyos/OracleYoyo.cs +++ b/Projectiles/Melee/Yoyos/OracleYoyo.cs @@ -20,7 +20,7 @@ namespace CalamityMod.Projectiles.Melee.Yoyos private Player Owner => Main.player[Projectile.owner]; // projectile.localAI[1] is the Aura Charge of the red lightning aura - // Minimum value is zero. Maximum value is 200. + // Minimum value is zero. Maximum value is 150. // The aura turns on and begins damaging enemies at 20 charge. // The yoyo "supercharges" at 50 charge. // Its size caps out at 100 charge. @@ -176,7 +176,7 @@ namespace CalamityMod.Projectiles.Melee.Yoyos { // The aura's direct damage scales with its charge and with melee stats. float chargeRatio = AuraCharge / MaxCharge; - int auraDamage = TheOracle.AuraBaseDamage + (int)(chargeRatio * (TheOracle.AuraMaxDamage - TheOracle.AuraBaseDamage)); + int auraDamage = (int)(Projectile.damage * MathHelper.Lerp(TheOracle.AuraBaseDamageMult, TheOracle.AuraMaxDamageMult, chargeRatio)); DealAuraDamage(auraRadius, auraDamage); } @@ -301,7 +301,7 @@ namespace CalamityMod.Projectiles.Melee.Yoyos } } - private void DealAuraDamage(float radius, int baseDamage) + private void DealAuraDamage(float radius, int damage) { if (Projectile.owner != Main.myPlayer) return; @@ -324,10 +324,9 @@ namespace CalamityMod.Projectiles.Melee.Yoyos if (dist <= radius) { target.AddBuff(ModContent.BuffType(), 300); - int finalDamage = (int)owner.GetTotalDamage().ApplyTo(baseDamage); if (Projectile.owner == Main.myPlayer) { - Projectile p = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), target.Center, Vector2.Zero, ModContent.ProjectileType(), finalDamage, 0f, Projectile.owner, target.whoAmI); + Projectile p = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), target.Center, Vector2.Zero, ModContent.ProjectileType(), damage, 0f, Projectile.owner, target.whoAmI); if (p.whoAmI.WithinBounds(Main.maxProjectiles)) p.DamageType = DamageClass.MeleeNoSpeed; } @@ -338,9 +337,6 @@ namespace CalamityMod.Projectiles.Melee.Yoyos private void FireAuricOrbs() { int numOrbs = 3; - int orbID = ModContent.ProjectileType(); - int orbDamage = Projectile.damage; - float orbKB = 8f; float angleVariance = MathHelper.TwoPi / numOrbs; float spinOffsetAngle = MathHelper.Pi / (2f * numOrbs); Vector2 posVec = new Vector2(2f, 0f).RotatedByRandom(MathHelper.TwoPi); @@ -351,8 +347,7 @@ namespace CalamityMod.Projectiles.Melee.Yoyos Vector2 velocity = new Vector2(posVec.X, posVec.Y).RotatedBy(spinOffsetAngle); velocity.Normalize(); velocity *= 18f; - if (Projectile.owner == Main.myPlayer) - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center + posVec, velocity, orbID, orbDamage, orbKB, Main.myPlayer, 0.0f, 0.0f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center + posVec, velocity, ModContent.ProjectileType(), Projectile.damage, 8f, Main.myPlayer, 0.0f, 0.0f); } } public override void OnKill(int timeLeft) diff --git a/Projectiles/Ranged/BlissfulBombardierHoldout.cs b/Projectiles/Ranged/BlissfulBombardierHoldout.cs index be1fd02fbb..5fcbb6ddc3 100644 --- a/Projectiles/Ranged/BlissfulBombardierHoldout.cs +++ b/Projectiles/Ranged/BlissfulBombardierHoldout.cs @@ -1,4 +1,5 @@ using System; +using System.IO; using CalamityMod.Dusts; using CalamityMod.Items.Potions.Alcohol; using CalamityMod.Items.Weapons.Ranged; @@ -33,10 +34,21 @@ namespace CalamityMod.Projectiles.Ranged public ref float shootingTimer => ref Projectile.ai[0]; public ref float PostFireCooldown => ref Projectile.ai[1]; public bool hasFired = false; + + public override void SendExtraAIHoldout(BinaryWriter writer) + { + writer.Write(shootingTimer); + } + public override void ReceiveExtraAIHoldout(BinaryReader reader) + { + shootingTimer = reader.ReadSingle(); + } + public override void KillHoldoutLogic() { } + public override void ManageHoldout() { // The center of the player, taking into account if they have a mount or not. diff --git a/Projectiles/Ranged/BlissfulBombardierSplitProjectile.cs b/Projectiles/Ranged/BlissfulBombardierSplitProjectile.cs index 14adc0efa3..88a9e7ac4b 100644 --- a/Projectiles/Ranged/BlissfulBombardierSplitProjectile.cs +++ b/Projectiles/Ranged/BlissfulBombardierSplitProjectile.cs @@ -61,8 +61,8 @@ namespace CalamityMod.Projectiles.Ranged public override void OnKill(int timeLeft) { - // Only do rocket effects for the owner client side - if (Projectile.owner != Main.myPlayer) + // Don't do rocket effects on the server + if (Main.dedServ) return; var info = new CalamityUtils.RocketBehaviorInfo((int)RocketID) diff --git a/Projectiles/Ranged/BloodBoilerFire.cs b/Projectiles/Ranged/BloodBoilerFire.cs index 6f66d1d97f..e69a582b32 100644 --- a/Projectiles/Ranged/BloodBoilerFire.cs +++ b/Projectiles/Ranged/BloodBoilerFire.cs @@ -1,12 +1,13 @@ using System; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Particles; +using CalamityMod.Projectiles.Healing; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; +using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; -using CalamityMod.Projectiles.Healing; namespace CalamityMod.Projectiles.Ranged { @@ -52,7 +53,7 @@ namespace CalamityMod.Projectiles.Ranged { int bloodLifetime = Main.rand.Next(22, 36); float bloodScale = Main.rand.NextFloat(0.6f, 0.8f); - Color bloodColor = Main.rand.NextBool() ? Color.Firebrick : Color.Red; + Color bloodColor = (!ChildSafety.Disabled ? Color.CornflowerBlue : (Main.rand.NextBool() ? Color.Firebrick : Color.Red)); float randomSpeedMultiplier = Main.rand.NextFloat(0.8f, 1.55f); Vector2 bloodVelocity = Projectile.velocity.RotatedByRandom(0.5) * randomSpeedMultiplier + new Vector2(0, -3); @@ -65,19 +66,19 @@ namespace CalamityMod.Projectiles.Ranged //BloodBoilerMetaball2.SpawnParticle(Projectile.Center, particleSize * 2.3f); //BloodBoilerMetaball.SpawnParticle(Projectile.Center, particleSize * 1.7f); - Particle beam3 = new CustomSpark(Projectile.Center, -Projectile.velocity * 0.1f, "CalamityMod/Particles/PearlParticleGlow", false, 10, 0.05f * particleSize, Color.DarkRed, new Vector2(0.5f, 1), false, false, 0, false, false, 0f); + Particle beam3 = new CustomSpark(Projectile.Center, -Projectile.velocity * 0.1f, "CalamityMod/Particles/PearlParticleGlow", false, 10, 0.05f * particleSize, (!ChildSafety.Disabled ? Color.CornflowerBlue : Color.DarkRed), new Vector2(0.5f, 1), false, false, 0, false, false, 0f); GeneralParticleHandler.SpawnParticle(beam3); if (Main.rand.NextBool(8)) { - Particle beam4 = new CustomSpark(Projectile.Center, Projectile.velocity * 0.1f, "CalamityMod/Particles/WaterFoam", false, 5, 0.01f * particleSize, Color.Red, new Vector2(1f, 1), true, false, Main.rand.NextFloat(-10, 10), false, false, 0f); + Particle beam4 = new CustomSpark(Projectile.Center, Projectile.velocity * 0.1f, "CalamityMod/Particles/WaterFoam", false, 5, 0.01f * particleSize, (!ChildSafety.Disabled ? Color.CornflowerBlue : Color.Red), new Vector2(1f, 1), true, false, Main.rand.NextFloat(-10, 10), false, false, 0f); GeneralParticleHandler.SpawnParticle(beam4); } if (Main.rand.NextBool(6) && Projectile.ai[1] == 0f) { - Color smokeColor = Main.rand.NextBool() ? Color.Red : Color.Firebrick; + Color smokeColor = (!ChildSafety.Disabled ? Color.CornflowerBlue : (Main.rand.NextBool() ? Color.Firebrick : Color.Red)); Vector2 smokePosition = Projectile.Center + Main.rand.NextVector2Circular(5 + Time * 0.3f, 5 + Time * 0.3f); float smokeScale = Main.rand.NextFloat(0.5f, 1.6f); float smokeOpacity = 170 + -Time * 0.6f; @@ -90,7 +91,7 @@ namespace CalamityMod.Projectiles.Ranged { if (Main.rand.NextBool(9)) { - DirectionalPulseRing pulse = new DirectionalPulseRing(Projectile.Center + Main.rand.NextVector2Circular(7 + Time * 0.4f, 7 + Time * 0.4f), Vector2.Zero, Main.rand.NextBool(3) ? Color.Red : Color.Firebrick, new Vector2(1, 1), 0, Main.rand.NextFloat(0.02f, 0.07f) + Time * 0.0006f, 0f, 35); + DirectionalPulseRing pulse = new DirectionalPulseRing(Projectile.Center + Main.rand.NextVector2Circular(7 + Time * 0.4f, 7 + Time * 0.4f), Vector2.Zero, (!ChildSafety.Disabled ? Color.CornflowerBlue : (Main.rand.NextBool(3) ? Color.Red : Color.Firebrick)), new Vector2(1, 1), 0, Main.rand.NextFloat(0.02f, 0.07f) + Time * 0.0006f, 0f, 35); GeneralParticleHandler.SpawnParticle(pulse); } } @@ -115,10 +116,10 @@ namespace CalamityMod.Projectiles.Ranged Projectile.velocity = -bloodCloudReturn.RotatedBy(Projectile.ai[2] == 5 ? -0.7f : 0.7f) * 1.2f; for (int i = 0; i <= 5; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center - Projectile.velocity * 2 + Main.rand.NextVector2Circular(35, 35), Main.rand.NextBool(3) ? 60 : 296, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(0.5f)) * Main.rand.NextFloat(1.7f, 3.2f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center - Projectile.velocity * 2 + Main.rand.NextVector2Circular(35, 35), !ChildSafety.Disabled ? DustID.Cloud : Main.rand.NextBool(3) ? 60 : 296, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(0.5f)) * Main.rand.NextFloat(1.7f, 3.2f)); dust.noGravity = true; dust.scale = Main.rand.NextFloat(1.2f, 2f); - Dust dust2 = Dust.NewDustPerfect(Projectile.Center - Projectile.velocity * 2 + Main.rand.NextVector2Circular(35, 35), Main.rand.NextBool(3) ? 60 : 296, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(35f)) * Main.rand.NextFloat(0.1f, 1.7f)); + Dust dust2 = Dust.NewDustPerfect(Projectile.Center - Projectile.velocity * 2 + Main.rand.NextVector2Circular(35, 35), !ChildSafety.Disabled ? DustID.Cloud : Main.rand.NextBool(3) ? 60 : 296, Projectile.velocity.RotatedByRandom(MathHelper.ToRadians(35f)) * Main.rand.NextFloat(0.1f, 1.7f)); dust2.noGravity = true; dust2.scale = Main.rand.NextFloat(1.2f, 2f); } @@ -139,7 +140,7 @@ namespace CalamityMod.Projectiles.Ranged Projectile.extraUpdates = 5; bool dustEffect = Main.rand.NextBool(3) ? false : true; - int dustColor = dustEffect ? 296 : 60; + int dustColor = (!ChildSafety.Disabled ? DustID.Cloud : (dustEffect ? 296 : 60)); Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(dustEffect ? 0 : 5, dustEffect ? 0 : 5), dustColor); dust.scale = dustEffect ? Main.rand.NextFloat(1.1f, 1.45f) : Main.rand.NextFloat(0.9f, 1.2f); dust.velocity = dustEffect ? Projectile.velocity * Main.rand.NextFloat(0.2f, 0.4f) : Vector2.One.RotatedByRandom(100) * Main.rand.NextFloat(0.7f, 1.2f); diff --git a/Projectiles/Ranged/BloodfireArrowProj.cs b/Projectiles/Ranged/BloodfireArrowProj.cs index 2ab87f6171..359c21e2e0 100644 --- a/Projectiles/Ranged/BloodfireArrowProj.cs +++ b/Projectiles/Ranged/BloodfireArrowProj.cs @@ -3,6 +3,7 @@ using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; +using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; @@ -47,7 +48,8 @@ namespace CalamityMod.Projectiles.Ranged { Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.UnitX) * 9; - } else + } + else { Projectile.damage = (int)(Projectile.damage * 1.3f); // damage boost player.statLife -= 1; @@ -65,7 +67,7 @@ namespace CalamityMod.Projectiles.Ranged float targetDist = Vector2.Distance(Owner.Center, Projectile.Center); // Lighting - Lighting.AddLight(Projectile.Center, Color.Red.ToVector3() * 0.7f); + Lighting.AddLight(Projectile.Center, (!ChildSafety.Disabled ? Color.CornflowerBlue : Color.Red).ToVector3() * 0.7f); // Dust Projectile.localAI[0] += 1f; @@ -81,7 +83,7 @@ namespace CalamityMod.Projectiles.Ranged } if (Projectile.localAI[0] % 2 == 0) { - Particle spark = new CustomSpark(Projectile.Center - Projectile.velocity * 2, -Projectile.velocity * 0.01f, "CalamityMod/Particles/BloomLineFade", false, 6, 0.025f, Color.Firebrick, new Vector2(1, 1), true, true, shrinkSpeed: 1.4f, glowOpacity: 0.4f); + Particle spark = new CustomSpark(Projectile.Center - Projectile.velocity * 2, -Projectile.velocity * 0.01f, "CalamityMod/Particles/BloomLineFade", false, 6, 0.025f, (!ChildSafety.Disabled ? Color.CornflowerBlue : Color.Firebrick), new Vector2(1, 1), true, true, shrinkSpeed: 1.4f, glowOpacity: 0.4f); GeneralParticleHandler.SpawnParticle(spark); } } @@ -96,7 +98,7 @@ namespace CalamityMod.Projectiles.Ranged Dust dust = Dust.NewDustPerfect(Projectile.Center, dustType, (Projectile.velocity * 2).RotatedByRandom(0.3) * velMulti); dust.noGravity = true; dust.scale = Main.rand.NextFloat(0.75f, 0.95f); - dust.color = Color.Firebrick; + dust.color = (!ChildSafety.Disabled ? Color.CornflowerBlue : Color.Firebrick); dust.noLightEmittence = true; dust.noLight = true; dust.fadeIn = 15; diff --git a/Projectiles/Ranged/BloodfireBulletProj.cs b/Projectiles/Ranged/BloodfireBulletProj.cs index 287413b0ff..282ab21c53 100644 --- a/Projectiles/Ranged/BloodfireBulletProj.cs +++ b/Projectiles/Ranged/BloodfireBulletProj.cs @@ -2,6 +2,7 @@ using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; +using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; @@ -42,7 +43,7 @@ namespace CalamityMod.Projectiles.Ranged float targetDist = Vector2.Distance(Owner.Center, Projectile.Center); // Lighting - Lighting.AddLight(Projectile.Center, Color.Red.ToVector3() * 0.5f); + Lighting.AddLight(Projectile.Center, (!ChildSafety.Disabled ? Color.CornflowerBlue : Color.Red).ToVector3() * 0.5f); // Dust Projectile.localAI[0] += 1f; @@ -50,7 +51,7 @@ namespace CalamityMod.Projectiles.Ranged { if (Main.rand.NextBool(3)) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(3) ? 130 : 60, -Projectile.velocity.RotatedByRandom(0.1f) * Main.rand.NextFloat(0.01f, 0.3f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center, !ChildSafety.Disabled ? DustID.Cloud : (Main.rand.NextBool(3) ? 130 : 60), -Projectile.velocity.RotatedByRandom(0.1f) * Main.rand.NextFloat(0.01f, 0.3f)); dust.noGravity = true; dust.scale = Main.rand.NextFloat(0.5f, 0.9f); if (dust.type == 130) @@ -58,7 +59,7 @@ namespace CalamityMod.Projectiles.Ranged } if (targetDist < 1400f) { - SparkParticle spark = new SparkParticle(Projectile.Center - Projectile.velocity, -Projectile.velocity * 0.01f, false, 4, 0.4f, Color.Firebrick); + SparkParticle spark = new SparkParticle(Projectile.Center - Projectile.velocity, -Projectile.velocity * 0.01f, false, 4, 0.4f, !ChildSafety.Disabled ? Color.CornflowerBlue : Color.Firebrick); GeneralParticleHandler.SpawnParticle(spark); } } @@ -71,7 +72,7 @@ namespace CalamityMod.Projectiles.Ranged { if (Projectile.localAI[0] > 6f) { - CalamityUtils.DrawAfterimagesFromEdge(Projectile, 0, Color.Red); + CalamityUtils.DrawAfterimagesFromEdge(Projectile, 0, (!ChildSafety.Disabled ? Color.CornflowerBlue : Color.Red)); } return true; } @@ -92,7 +93,7 @@ namespace CalamityMod.Projectiles.Ranged { for (int k = 0; k < 3; k++) { - BloodParticle blood = new BloodParticle(Projectile.Center, new Vector2(6.5f, 6.5f).RotatedByRandom(100) * Main.rand.NextFloat(0.8f, 1.2f), Main.rand.Next(8, 10 + 1), Main.rand.NextFloat(0.7f, 0.9f), Color.Red); + BloodParticle blood = new BloodParticle(Projectile.Center, new Vector2(6.5f, 6.5f).RotatedByRandom(100) * Main.rand.NextFloat(0.8f, 1.2f), Main.rand.Next(8, 10 + 1), Main.rand.NextFloat(0.7f, 0.9f), !ChildSafety.Disabled ? Color.CornflowerBlue : Color.Red); GeneralParticleHandler.SpawnParticle(blood); int dustType = ModContent.DustType(); @@ -100,7 +101,7 @@ namespace CalamityMod.Projectiles.Ranged Dust dust = Dust.NewDustPerfect(Projectile.Center, dustType, (-Projectile.velocity * 4).RotatedByRandom(0.4) * velMulti); dust.noGravity = true; dust.scale = Main.rand.NextFloat(0.55f, 0.65f); - dust.color = Color.Firebrick; + dust.color = !ChildSafety.Disabled ? Color.CornflowerBlue : Color.Firebrick; dust.noLightEmittence = true; dust.noLight = true; dust.fadeIn = 15; @@ -113,12 +114,12 @@ namespace CalamityMod.Projectiles.Ranged { for (int k = 0; k < 3; k++) { - SparkParticle spark = new SparkParticle(Projectile.Center, -Projectile.velocity.RotatedByRandom(0.5) * Main.rand.NextFloat(1f, 3f), false, Main.rand.Next(5, 7 + 1), Main.rand.NextFloat(0.4f, 0.6f), Color.Red); + SparkParticle spark = new SparkParticle(Projectile.Center, -Projectile.velocity.RotatedByRandom(0.5) * Main.rand.NextFloat(1f, 3f), false, Main.rand.Next(5, 7 + 1), Main.rand.NextFloat(0.4f, 0.6f), !ChildSafety.Disabled ? Color.CornflowerBlue : Color.Red); GeneralParticleHandler.SpawnParticle(spark); } for (int k = 0; k < 8; k++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(3) ? 130 : 60, new Vector2(3, 3).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1.5f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center, (!ChildSafety.Disabled ? DustID.Cloud : (Main.rand.NextBool(3) ? 130 : 60)), new Vector2(3, 3).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 1.5f)); dust.noGravity = true; dust.scale = Main.rand.NextFloat(0.5f, 0.9f); if (dust.type == 130) diff --git a/Projectiles/Ranged/CosmicFire.cs b/Projectiles/Ranged/CosmicFire.cs index 1b8c93bc9f..6105c72c87 100644 --- a/Projectiles/Ranged/CosmicFire.cs +++ b/Projectiles/Ranged/CosmicFire.cs @@ -108,10 +108,11 @@ namespace CalamityMod.Projectiles.Ranged Particle blastRing = new CustomPulse(Projectile.Center, Vector2.Zero, Color.Black, "CalamityMod/Particles/LargeBloom", Vector2.One, Main.rand.NextFloat(-10, 10), 0.35f, 0.4f, 38, false); GeneralParticleHandler.SpawnParticle(blastRing); } - for (int i = 0; i < 5; i++) + for (int i = 0; i < 3; i++) { Particle blastRing = new CustomPulse(Projectile.Center, Vector2.Zero, InnerColor, "CalamityMod/Particles/BloomCircle", Vector2.One, Main.rand.NextFloat(-10, 10), 0.48f, 0.52f, 38); GeneralParticleHandler.SpawnParticle(blastRing); + blastRing.DrawLayer = GeneralDrawLayer.AfterEverything; } float numberOfDusts = 10; diff --git a/Projectiles/Ranged/DragonsBreathHoldout.cs b/Projectiles/Ranged/DragonsBreathHoldout.cs index 8b11715fbe..5ee69fd17a 100644 --- a/Projectiles/Ranged/DragonsBreathHoldout.cs +++ b/Projectiles/Ranged/DragonsBreathHoldout.cs @@ -64,7 +64,7 @@ namespace CalamityMod.Projectiles.Ranged SoundEngine.PlaySound(bigShot with { PitchVariance = 0.15f, Volume = 0.75f }, Projectile.Center); if (Main.myPlayer == Projectile.owner) - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, (Projectile.velocity.SafeNormalize(Vector2.UnitX) * 6).RotatedBy(-2.3f * Projectile.direction), ModContent.ProjectileType(), Main.zenithWorld ? 250000 : 1, Projectile.knockBack, Projectile.owner, 1); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, (Projectile.velocity.SafeNormalize(Vector2.UnitX) * 6).RotatedBy(-2.3f * Projectile.direction), ModContent.ProjectileType(), 1, Projectile.knockBack, Projectile.owner, 1); hasLaunchedMag = true; } } diff --git a/Projectiles/Ranged/FlashRoundProj.cs b/Projectiles/Ranged/FlashRoundProj.cs index 51615c3a6a..f5e18e683d 100644 --- a/Projectiles/Ranged/FlashRoundProj.cs +++ b/Projectiles/Ranged/FlashRoundProj.cs @@ -18,6 +18,7 @@ namespace CalamityMod.Projectiles.Ranged public float shineRot = 0; public bool onSpawn = true; public ref float time => ref Projectile.ai[2]; + private const int MaxTime = 600; public override void SetStaticDefaults() { ProjectileID.Sets.TrailCacheLength[Type] = 15; @@ -31,7 +32,7 @@ namespace CalamityMod.Projectiles.Ranged Projectile.friendly = true; Projectile.DamageType = DamageClass.Ranged; Projectile.penetrate = 2; - Projectile.timeLeft = 600; + Projectile.timeLeft = MaxTime; Projectile.extraUpdates = 3; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = -1; @@ -62,6 +63,11 @@ namespace CalamityMod.Projectiles.Ranged shineRot = Main.rand.NextFloat(-5, 5); onSpawn = false; } + // Handles spawning flash effect when bouncing off enemies/tiles + if (time == 0 && Projectile.timeLeft < MaxTime) + { + MakeFlash(false); + } shineRot += Math.Sign(shineRot) * 0.05f; Player Owner = Main.player[Projectile.owner]; @@ -81,6 +87,53 @@ namespace CalamityMod.Projectiles.Ranged time++; } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + float damageMult = Projectile.numHits == 0 ? 1 : 0.3f; + modifiers.SourceDamage *= damageMult; + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + time = 0; + Projectile.velocity = Vector2.Lerp(Utils.DirectionFrom(Projectile.Center, target.Center) * 12, Vector2.UnitY * -7, 0.75f).RotatedByRandom(0.25f); + Projectile.netUpdate = true; + } + public override bool OnTileCollide(Vector2 oldVelocity) + { + time = 0; + if (Projectile.velocity.X != oldVelocity.X) + { + Projectile.velocity.X = -oldVelocity.X; + } + if (Projectile.velocity.Y != oldVelocity.Y) + { + Projectile.velocity.Y = -oldVelocity.Y; + } + if (Projectile.velocity.X < 2 && Projectile.velocity.X > 0) + Projectile.velocity.X = 2; + if (Projectile.velocity.X > -2 && Projectile.velocity.X < 0) + Projectile.velocity.X = -2; + if (Projectile.velocity.Y < 2 && Projectile.velocity.Y > 0) + Projectile.velocity.Y = 2; + if (Projectile.velocity.Y > -2 && Projectile.velocity.Y < 0) + Projectile.velocity.Y = -2; + + Projectile.velocity *= 0.97f; + + int expectedDamage = Math.Max((int)(Projectile.damage * 1.13f), Projectile.damage + 2); + Projectile.damage = expectedDamage; + + if (bounces <= 0) + { + Projectile.Kill(); + return false; + } + for (int i = 0; i < Main.maxNPCs; i++) + Projectile.localNPCImmunity[i] = 0; + bounces--; + return false; + } + public override bool PreDraw(ref Color lightColor) { float sine = (float)Math.Sin(Projectile.timeLeft * 0.175f / MathHelper.Pi); @@ -92,13 +145,8 @@ namespace CalamityMod.Projectiles.Ranged Main.EntitySpriteDraw(shine.Value, Projectile.Center - Main.screenPosition, null, Color.White with { A = 0 } * 0.6f, Projectile.rotation + shineRot, shine.Size() / 2f, new Vector2(1 + 0.9f * -trueSine, 1 + 0.9f * trueSine) * Projectile.scale * 0.13f, SpriteEffects.None, 0); return false; } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) - { - time = 0; - Projectile.velocity = Vector2.Lerp(Utils.DirectionFrom(Projectile.Center, target.Center) * 12, Vector2.UnitY * -7, 0.75f).RotatedByRandom(0.25f); - makeDust(false); - } - public void makeDust(bool onlyFlash) // This is basically the tile/hit effects + + public void MakeFlash(bool onlyFlash) // This is basically the tile/hit effects { if (!onlyFlash) { @@ -127,51 +175,8 @@ namespace CalamityMod.Projectiles.Ranged dust.noLightEmittence = true; } // Doesn't actually do damage, just an aoe for knockback - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), 5, 0f, Projectile.owner); - } - public override bool OnTileCollide(Vector2 oldVelocity) - { - time = 0; - if (Projectile.velocity.X != oldVelocity.X) - { - Projectile.velocity.X = -oldVelocity.X; - } - if (Projectile.velocity.Y != oldVelocity.Y) - { - Projectile.velocity.Y = -oldVelocity.Y; - } - if (Projectile.velocity.X < 2 && Projectile.velocity.X > 0) - Projectile.velocity.X = 2; - if (Projectile.velocity.X > -2 && Projectile.velocity.X < 0) - Projectile.velocity.X = -2; - if (Projectile.velocity.Y < 2 && Projectile.velocity.Y > 0) - Projectile.velocity.Y = 2; - if (Projectile.velocity.Y > -2 && Projectile.velocity.Y < 0) - Projectile.velocity.Y = -2; - - Projectile.velocity *= 0.97f; - - int expectedDamage = Math.Max((int)(Projectile.damage * 1.13f), Projectile.damage + 2); - Projectile.damage = expectedDamage; - - makeDust(false); - if (bounces <= 0) - { - Projectile.Kill(); - return false; - } - for (int i = 0; i < Main.maxNPCs; i++) - Projectile.localNPCImmunity[i] = 0; - bounces--; - return false; - } - public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) - { - float damageMult = (Projectile.numHits == 0 ? 1 : 0.3f); - modifiers.SourceDamage *= damageMult; - } - public override void OnKill(int timeLeft) - { + if (Main.myPlayer == Projectile.owner) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), 5, 0f, Projectile.owner); } } } diff --git a/Projectiles/Ranged/HalleysInfernoHoldout.cs b/Projectiles/Ranged/HalleysInfernoHoldout.cs index 166b8d838d..9d09b629f1 100644 --- a/Projectiles/Ranged/HalleysInfernoHoldout.cs +++ b/Projectiles/Ranged/HalleysInfernoHoldout.cs @@ -69,7 +69,7 @@ namespace CalamityMod.Projectiles.Ranged } else if (Owner.controlUseTile) { - if (ShotTimer <= 0 && Owner.Calamity().AvaliableStarburst > 0) + if (ShotTimer <= 0 && Owner.Calamity().AvaliableStarburst > 1) { ShotTimer = 4; var spawnpos = Projectile.Center; @@ -97,8 +97,8 @@ namespace CalamityMod.Projectiles.Ranged for (var i = 0; i < 5; i++) GeneralParticleHandler.SpawnParticle(new GlowSparkParticle(spawnpos + dir * 36, (dir * Halley.shootSpeed).RotatedByRandom(0.75f) * Main.rand.NextFloat(0.5f, 1.5f), false, 7, 0.02f, drawColor, new Vector2(0.5f, 1f))); if (Projectile.owner == Main.myPlayer) - Projectile.NewProjectile(Owner.GetSource_ItemUse_WithPotentialAmmo(Halley, AmmoID.Gel), spawnpos + dir * 16,dir * Halley.shootSpeed * 0.75f, ModContent.ProjectileType(), (int)Owner.GetDamage(DamageClass.Ranged).ApplyTo(Halley.damage), Halley.knockBack, Projectile.owner, color); - Owner.Calamity().StratusStarburst--; + Projectile.NewProjectile(Owner.GetSource_ItemUse_WithPotentialAmmo(Halley, AmmoID.Gel), spawnpos + dir * 16,dir * Halley.shootSpeed * HalleysInferno.StarburstVelMult, ModContent.ProjectileType(), (int)(Owner.GetDamage(DamageClass.Ranged).ApplyTo(Halley.damage) * HalleysInferno.StarburstDmgMult), Halley.knockBack, Projectile.owner, color); + Owner.Calamity().StratusStarburst -= 2; SoundEngine.PlaySound(HalleysInferno.ShootSound); RecoilAmount = 4; } diff --git a/Projectiles/Ranged/HiveMissile.cs b/Projectiles/Ranged/HiveMissile.cs index a272cb7945..a95485dbed 100644 --- a/Projectiles/Ranged/HiveMissile.cs +++ b/Projectiles/Ranged/HiveMissile.cs @@ -155,8 +155,10 @@ namespace CalamityMod.Projectiles.Ranged dust2.noGravity = true; dust2.color = Main.rand.NextBool(3) ? EffectsColor : StaticEffectsColor; } - - for (int k = 0; k < (isClusterRocket ? 3f : 2f); k++) + var projAmount = isClusterRocket ? 3f : 2f; + if (Main.player[Projectile.owner].strongBees && Main.rand.NextBool()) + projAmount++; + for (int k = 0; k < projAmount; k++) { int BEES = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, new Vector2(4, 10).RotatedByRandom(4) * Main.rand.NextFloat(0.2f, 0.8f), ModContent.ProjectileType(), (int)(Projectile.damage * (isClusterRocket ? 0.2f : 0.3f)), 0f, Projectile.owner, 0f, 0f, isClusterRocket ? 2f : 1f); if (BEES.WithinBounds(Main.maxProjectiles)) diff --git a/Projectiles/Ranged/HiveNuke.cs b/Projectiles/Ranged/HiveNuke.cs index 4603c31b0b..42d6a91781 100644 --- a/Projectiles/Ranged/HiveNuke.cs +++ b/Projectiles/Ranged/HiveNuke.cs @@ -238,7 +238,11 @@ namespace CalamityMod.Projectiles.Ranged dust.alpha = Main.rand.Next(90, 220 + 1); } } - for (int k = 0; k < (int)((Main.zenithWorld ? 100 : 20) * (isClusterRocket ? 1.5f : 1)); k++) + + var projAmount = isClusterRocket ? 30f : 20f; + if (Main.player[Projectile.owner].strongBees) + projAmount *= 1.15f; + for (int k = 0; k < projAmount; k++) { int BEES = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, new Vector2(10, 10).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 0.8f), ModContent.ProjectileType(), (int)(Projectile.damage * (isClusterRocket ? 0.03f : 0.04f)), 0f, Projectile.owner, 0f, 0f, isClusterRocket ? 2f : 1f); if (BEES.WithinBounds(Main.maxProjectiles)) diff --git a/Projectiles/Ranged/M1GarandHoldout.cs b/Projectiles/Ranged/M1GarandHoldout.cs index e57d2c3d64..1b4089371d 100644 --- a/Projectiles/Ranged/M1GarandHoldout.cs +++ b/Projectiles/Ranged/M1GarandHoldout.cs @@ -315,7 +315,7 @@ namespace CalamityMod.Projectiles.Ranged { if (pingAnimationTimer <= PingAnimationDuration) { - Texture2D pingTexture = Main.zenithWorld ? ModContent.Request("CalamityMod/Particles/MammothParticle").Value : ModContent.Request("CalamityMod/Projectiles/Ranged/M1GarandPingText").Value; + Texture2D pingTexture = ModContent.Request("CalamityMod/Projectiles/Ranged/M1GarandPingText").Value; Vector2 origin = pingTexture.Size() * 0.5f; Vector2 pingDrawPosition; diff --git a/Projectiles/Ranged/NukeOfBliss.cs b/Projectiles/Ranged/NukeOfBliss.cs index 5543e63a47..c58d7eb599 100644 --- a/Projectiles/Ranged/NukeOfBliss.cs +++ b/Projectiles/Ranged/NukeOfBliss.cs @@ -139,8 +139,8 @@ namespace CalamityMod.Projectiles.Ranged public override void OnKill(int timeLeft) { - // Only do rocket effects for the owner client side - if (Projectile.owner != Main.myPlayer) + // Don't do rocket effects on the server + if (Main.dedServ) return; var info = new CalamityUtils.RocketBehaviorInfo((int)RocketID) diff --git a/Projectiles/Ranged/ScorchedEarthRocket.cs b/Projectiles/Ranged/ScorchedEarthRocket.cs index 4313ba0061..7fc2aff143 100644 --- a/Projectiles/Ranged/ScorchedEarthRocket.cs +++ b/Projectiles/Ranged/ScorchedEarthRocket.cs @@ -1,4 +1,5 @@ -using CalamityMod.Particles; +using System.IO; +using CalamityMod.Particles; using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -33,6 +34,14 @@ namespace CalamityMod.Projectiles.Ranged Projectile.timeLeft = 300; Projectile.DamageType = DamageClass.Ranged; } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(HasHit); + } + public override void ReceiveExtraAI(BinaryReader reader) + { + HasHit = reader.ReadBoolean(); + } public override void AI() { @@ -96,7 +105,6 @@ namespace CalamityMod.Projectiles.Ranged } if (RocketID == ItemID.RocketII || RocketID == ItemID.RocketIV || RocketID == ItemID.MiniNukeII) { - var info = new CalamityUtils.RocketBehaviorInfo((int)RocketID); int blastRadius = (int)(Projectile.RocketBehavior(info) * 3f); if (time % 5 == 0) @@ -150,13 +158,11 @@ namespace CalamityMod.Projectiles.Ranged HasHit = true; Projectile.netUpdate = true; } - public override void OnHitPlayer(Player target, Player.HurtInfo info) { HasHit = true; Projectile.netUpdate = true; } - public override bool OnTileCollide(Vector2 oldVelocity) { HasHit = true; @@ -166,39 +172,11 @@ namespace CalamityMod.Projectiles.Ranged public override void OnKill(int timeLeft) { - if (HasHit == true && !BonusEffectMode && Projectile.ai[2] == 0) + if (HasHit && !BonusEffectMode && Projectile.ai[2] == 0) { - if (Projectile.owner == Main.myPlayer) - { - bool isClusterRocket = (RocketID == ItemID.ClusterRocketI || RocketID == ItemID.ClusterRocketII); - //If using a rocket with extra effects, spawn an invisible copy that handes the tile breaking/liquid spawning logic - if (RocketID == ItemID.RocketII || RocketID == ItemID.RocketIV || RocketID == ItemID.MiniNukeII || RocketID == ItemID.DryRocket || RocketID == ItemID.WetRocket || RocketID == ItemID.LavaRocket || RocketID == ItemID.HoneyRocket) - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Projectile.owner, RocketID, 0f, 2f); - // Create Blast - float blastSize = 300; - float minMultiplier = 0.25f; - int hitsToMinMult = 4; - int debuff1 = BuffID.Daybreak; - int debuff2 = BuffID.Oiled; - int debuffTime = 360; - //The explosion has a different damage scaling depending on which rocket type you have. Left is Cluster Rocket, right is Non-Cluster. - Projectile blast = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * (isClusterRocket ? 0.75f : 1)), Projectile.knockBack, Projectile.owner, blastSize, minMultiplier, hitsToMinMult); - blast.localAI[0] = debuff1; - blast.localAI[2] = debuff2; - blast.localAI[1] = debuffTime; - blast.timeLeft = 15; - blast.DamageType = DamageClass.Ranged; - for (int j = 0; j < (isClusterRocket ? 9 : 5); j++) - { - Vector2 velocity = Main.rand.NextVector2Unit() * Main.rand.NextFloat(8f, 10f); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.25), Projectile.knockBack * 0.25f, Projectile.owner); - } - } - - // Handle FX for all clients + // Visual effects SoundEngine.PlaySound(SoundID.Item14, Projectile.Center); SoundEngine.PlaySound(RocketExplosion with { MaxInstances = 2 }, Projectile.Center); - for (int i = 0; i < 15; i++) { Vector2 randVel = new Vector2(12, 12).RotatedByRandom(100) * Main.rand.NextFloat(0.8f, 1.6f); @@ -220,6 +198,34 @@ namespace CalamityMod.Projectiles.Ranged Particle blastRing5 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.OrangeRed, "CalamityMod/Particles/FlameExplosion", Vector2.One, Main.rand.NextFloat(-10, 10), 0f, 0.13f, 20, true, 1f); GeneralParticleHandler.SpawnParticle(blastRing5); } + + // Below is projectile spawning logic, so it should only run on one instance + if (Main.myPlayer != Projectile.owner) + return; + + bool isClusterRocket = RocketID == ItemID.ClusterRocketI || RocketID == ItemID.ClusterRocketII; + // If using a rocket with extra effects, spawn an invisible copy that handes the tile breaking/liquid spawning logic + if (RocketID == ItemID.RocketII || RocketID == ItemID.RocketIV || RocketID == ItemID.MiniNukeII || RocketID == ItemID.DryRocket || RocketID == ItemID.WetRocket || RocketID == ItemID.LavaRocket || RocketID == ItemID.HoneyRocket) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Projectile.owner, RocketID, 0f, 2f); + // Create blast + float blastSize = 300; + float minMultiplier = 0.25f; + int hitsToMinMult = 4; + int debuff1 = BuffID.Daybreak; + int debuff2 = BuffID.Oiled; + int debuffTime = 360; + // The explosion has a different damage scaling depending on which rocket type you have. Left is Cluster Rocket, right is Non-Cluster. + Projectile blast = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * (isClusterRocket ? 0.75f : 1)), Projectile.knockBack, Projectile.owner, blastSize, minMultiplier, hitsToMinMult); + blast.localAI[0] = debuff1; + blast.localAI[2] = debuff2; + blast.localAI[1] = debuffTime; + blast.timeLeft = 15; + blast.DamageType = DamageClass.Ranged; + for (int j = 0; j < (isClusterRocket ? 9 : 5); j++) + { + Vector2 velocity = Main.rand.NextVector2Unit() * Main.rand.NextFloat(8f, 10f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.25), Projectile.knockBack * 0.25f, Projectile.owner); + } } } public override bool PreDraw(ref Color lightColor) diff --git a/Projectiles/Ranged/SepticSkewerBacteria.cs b/Projectiles/Ranged/SepticSkewerBacteria.cs index e5fd0f6d73..814e390323 100644 --- a/Projectiles/Ranged/SepticSkewerBacteria.cs +++ b/Projectiles/Ranged/SepticSkewerBacteria.cs @@ -4,6 +4,7 @@ using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; @@ -43,7 +44,7 @@ namespace CalamityMod.Projectiles.Ranged } if (time % 8 == 0 && time > 40) { - Particle spark = new CustomSpark(Projectile.Center - Projectile.velocity + Main.rand.NextVector2Circular(20, 20), -Projectile.velocity * Main.rand.NextFloat(0.1f, 0.4f), "CalamityMod/Projectiles/Boss/OldDukeGore", false, Main.rand.Next(9, 20 + 1), Main.rand.NextFloat(0.4f, 0.6f), Color.Lerp(Color.White, Color.Chartreuse, 0.5f) * Main.rand.NextFloat(0.55f, 0.7f) * Utils.GetLerpValue(255, 0, Projectile.alpha), new Vector2(1, 1), false, false, Main.rand.NextFloat(-1f, 1f)); + Particle spark = new CustomSpark(Projectile.Center - Projectile.velocity + Main.rand.NextVector2Circular(20, 20), -Projectile.velocity * Main.rand.NextFloat(0.1f, 0.4f), "CalamityMod/Projectiles/Boss/OldDukeGore", false, Main.rand.Next(9, 20 + 1), Main.rand.NextFloat(0.4f, 0.6f), (!ChildSafety.Disabled ? Color.LimeGreen : Color.Lerp(Color.White, Color.Chartreuse, 0.5f)) * Main.rand.NextFloat(0.55f, 0.7f) * Utils.GetLerpValue(255, 0, Projectile.alpha), new Vector2(1, 1), false, false, Main.rand.NextFloat(-1f, 1f)); GeneralParticleHandler.SpawnParticle(spark); } if (Main.rand.NextBool(15)) @@ -55,7 +56,7 @@ namespace CalamityMod.Projectiles.Ranged } if (Main.rand.NextBool(3)) { - Dust dust = Dust.NewDustPerfect(Projectile.Center - Projectile.velocity.SafeNormalize(Vector2.UnitX) * 3 + Main.rand.NextVector2Circular(6, 6), DustID.Blood, (-Projectile.velocity.SafeNormalize(Vector2.UnitX) * 4).RotatedByRandom(0.3f) * Main.rand.NextFloat(0.1f, 0.8f), 100, default, Main.rand.NextFloat(0.8f, 1.4f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center - Projectile.velocity.SafeNormalize(Vector2.UnitX) * 3 + Main.rand.NextVector2Circular(6, 6), !ChildSafety.Disabled ? (int)CalamityDusts.SulphurousSeaAcid : DustID.Blood, (-Projectile.velocity.SafeNormalize(Vector2.UnitX) * 4).RotatedByRandom(0.3f) * Main.rand.NextFloat(0.1f, 0.8f), 100, default, Main.rand.NextFloat(0.8f, 1.4f)); dust.noGravity = true; dust.alpha = (int)MathHelper.Clamp(Projectile.alpha, 0, 255); } diff --git a/Projectiles/Ranged/SepticSkewerHarpoon.cs b/Projectiles/Ranged/SepticSkewerHarpoon.cs index 313c2bdfee..42ca8e5637 100644 --- a/Projectiles/Ranged/SepticSkewerHarpoon.cs +++ b/Projectiles/Ranged/SepticSkewerHarpoon.cs @@ -4,12 +4,14 @@ using System.Linq; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.CalPlayer; using CalamityMod.DataStructures; +using CalamityMod.Dusts; using CalamityMod.NPCs; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; +using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; @@ -47,7 +49,7 @@ namespace CalamityMod.Projectiles.Ranged public bool strongEnemy = false; public bool normalHit = false; - public bool pullCheckValid => ((chosenTarget != null && chosenTarget.life < Projectile.damage * 20f && !calledToPull && chosenTarget.realLife == -1 && !normalHit && (CalamityPlayer.areThereAnyDamnBosses ? chosenTarget.life <= chosenTarget.lifeMax / 4 : true)) || Main.zenithWorld); + public bool pullCheckValid => chosenTarget != null && chosenTarget.life < Projectile.damage * 20f && !calledToPull && chosenTarget.realLife == -1 && !normalHit && (CalamityPlayer.areThereAnyDamnBosses ? chosenTarget.life <= chosenTarget.lifeMax / 4 : true); public override void SetStaticDefaults() { ProjectileID.Sets.DrawScreenCheckFluff[Type] = 10000; @@ -94,12 +96,6 @@ namespace CalamityMod.Projectiles.Ranged if (Projectile.velocity.Length() < 7) collideWithTiles = false; - if (Main.zenithWorld) - { - returnTime = 90; - Projectile.extraUpdates = 7; - } - if (time >= returnTime * (pullCheckValid ? strongEnemy ? 1.5f : 0.9f : stuckInTarget ? 5 : 1) || ripped) { stuckInTarget = false; @@ -164,16 +160,16 @@ namespace CalamityMod.Projectiles.Ranged Vector2 vel = ((Projectile.Center - Owner.Center).SafeNormalize(Vector2.UnitX) * -18).RotatedByRandom(0.2f * ripIntensity) * Main.rand.NextFloat(0.2f, 0.6f) * ripIntensity; if (i % 3 == 0) { - Particle spark = new AltLineParticle(Projectile.Center, vel, true, (int)(18 * ripIntensity), Main.rand.NextFloat(0.55f, 0.8f) * ripIntensity, Color.DarkRed * 0.8f); + Particle spark = new AltLineParticle(Projectile.Center, vel, true, (int)(18 * ripIntensity), Main.rand.NextFloat(0.55f, 0.8f) * ripIntensity, (!ChildSafety.Disabled ? Color.LimeGreen : Color.DarkRed) * 0.8f); GeneralParticleHandler.SpawnParticle(spark); } else { - Particle spark = new GlowOrbParticle(Projectile.Center, vel, true, (int)(18 * ripIntensity), Main.rand.NextFloat(0.55f, 0.8f) * ripIntensity, Color.DarkRed * 0.8f, false, false, false); + Particle spark = new GlowOrbParticle(Projectile.Center, vel, true, (int)(18 * ripIntensity), Main.rand.NextFloat(0.55f, 0.8f) * ripIntensity, (!ChildSafety.Disabled ? Color.LimeGreen : Color.DarkRed) * 0.8f, false, false, false); GeneralParticleHandler.SpawnParticle(spark); } - Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.Blood, vel * 3, 100, default, Main.rand.NextFloat(0.8f, 1.4f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center, !ChildSafety.Disabled ? (int)CalamityDusts.SulphurousSeaAcid : DustID.Blood, vel * 3, 100, default, Main.rand.NextFloat(0.8f, 1.4f)); dust.noGravity = true; } @@ -203,7 +199,7 @@ namespace CalamityMod.Projectiles.Ranged for (int i = 0; i < 3; i++) { - Particle orb7 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.Maroon, "CalamityMod/Particles/LargeBloom", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 0, (0.5f + i * 0.2f), 30, false); + Particle orb7 = new CustomPulse(Projectile.Center, Vector2.Zero, !ChildSafety.Disabled ? Color.LimeGreen : bColor, "CalamityMod/Particles/LargeBloom", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 0, (0.5f + i * 0.2f), 30, false); GeneralParticleHandler.SpawnParticle(orb7); } @@ -218,24 +214,24 @@ namespace CalamityMod.Projectiles.Ranged Vector2 vel = (Vector2.One * -28).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 0.9f) * intensity; if (i % 3 == 0) { - Particle spark = new AltLineParticle(Projectile.Center, vel, true, (int)(35), Main.rand.NextFloat(0.55f, 1.3f), Color.DarkRed * 0.8f); + Particle spark = new AltLineParticle(Projectile.Center, vel, true, (int)(35), Main.rand.NextFloat(0.55f, 1.3f), (!ChildSafety.Disabled ? Color.LimeGreen : Color.DarkRed) * 0.8f); GeneralParticleHandler.SpawnParticle(spark); } else { - Particle spark = new GlowOrbParticle(Projectile.Center, vel, true, (int)(35), Main.rand.NextFloat(0.55f, 1.3f), Color.DarkRed * 0.8f, false, false, false); + Particle spark = new GlowOrbParticle(Projectile.Center, vel, true, (int)(35), Main.rand.NextFloat(0.55f, 1.3f), (!ChildSafety.Disabled ? Color.LimeGreen : Color.DarkRed) * 0.8f, false, false, false); GeneralParticleHandler.SpawnParticle(spark); } for (int r = 0; r < 2; r++) { Vector2 vel2 = (Vector2.One * -28).RotatedByRandom(100) * Main.rand.NextFloat(0.1f, 0.8f) * intensity; - Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.Blood, vel2, 100, default, Main.rand.NextFloat(0.9f, 1.7f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center, !ChildSafety.Disabled ? (int)CalamityDusts.SulphurousSeaAcid : DustID.Blood, vel2, 100, default, Main.rand.NextFloat(0.9f, 1.7f)); dust.noGravity = false; } if (strongEnemy) { - Dust dust5 = Dust.NewDustPerfect(Projectile.Center, DustID.FireworksRGB, vel * 0.6f, 0, Color.Red, Main.rand.NextFloat(0.7f, 0.9f)); + Dust dust5 = Dust.NewDustPerfect(Projectile.Center, DustID.FireworksRGB, vel * 0.6f, 0, !ChildSafety.Disabled ? Color.LimeGreen : Color.DarkRed, Main.rand.NextFloat(0.7f, 0.9f)); dust5.noGravity = false; } } @@ -256,11 +252,6 @@ namespace CalamityMod.Projectiles.Ranged closestTarget = Main.npc[index]; } } - if (Main.zenithWorld && Main.npc[index] != null && index < 80 && Main.npc[index].realLife == -1 && Owner.ownedProjectileCounts[Type] < 80) - { - closestTarget = Main.npc[index]; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Owner.Center, ((closestTarget.Center - Owner.Center + closestTarget.velocity * 1.5f).SafeNormalize(Vector2.UnitX) * 18), Projectile.type, Projectile.damage, Projectile.knockBack, Projectile.owner, 0, Projectile.ai[1] + 1); - } } if (closestTarget != null) { @@ -302,7 +293,7 @@ namespace CalamityMod.Projectiles.Ranged Projectile.velocity *= 0.95f; } - if (collideWithTiles && Collision.SolidCollision(Projectile.Center + Projectile.velocity.SafeNormalize(Vector2.UnitX) * 30, 4, 4) && !Main.zenithWorld && Projectile.ai[1] < 1) + if (collideWithTiles && Collision.SolidCollision(Projectile.Center + Projectile.velocity.SafeNormalize(Vector2.UnitX) * 30, 4, 4) && Projectile.ai[1] < 1) { hasHitTile = true; Projectile.velocity *= -0.5f; @@ -311,7 +302,7 @@ namespace CalamityMod.Projectiles.Ranged { float sparkScale1 = Main.rand.NextFloat(0.3f, 0.8f); Vector2 sparkvelocity1 = sparkVelocity.RotatedByRandom(0.45f) * Main.rand.NextFloat(0.5f, 0.7f); - Particle spark1 = new LineParticle(Projectile.Center, sparkvelocity1, true, 40, sparkScale1, Main.rand.NextBool() ? bColor : Color.Green); + Particle spark1 = new LineParticle(Projectile.Center, sparkvelocity1, true, 40, sparkScale1, Main.rand.NextBool() ? (!ChildSafety.Disabled ? Color.LimeGreen : bColor) : Color.Green); GeneralParticleHandler.SpawnParticle(spark1); SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/CeramicImpact", 2) with { Pitch = 0.4f, Volume = 0.5f }, Projectile.Center); } @@ -351,15 +342,15 @@ namespace CalamityMod.Projectiles.Ranged float sparkScale1 = Main.rand.NextFloat(0.3f, 0.8f); Vector2 sparkvelocity1 = sparkVelocity.RotatedByRandom(0.45f) * Main.rand.NextFloat(0.5f, 0.7f); - Particle spark1 = new LineParticle(Projectile.Center, sparkvelocity1, false, 40, sparkScale1, Main.rand.NextBool() ? bColor : Color.Green); + Particle spark1 = new LineParticle(Projectile.Center, sparkvelocity1, false, 40, sparkScale1, Main.rand.NextBool() ? (!ChildSafety.Disabled ? Color.LimeGreen : bColor) : Color.Green); GeneralParticleHandler.SpawnParticle(spark1); float sparkScale2 = Main.rand.NextFloat(0.4f, 1f); Vector2 sparkvelocity2 = sparkVelocity.RotatedByRandom(0.2f) * Main.rand.NextFloat(0.9f, 1.6f); - Particle spark2 = new LineParticle(Projectile.Center, sparkvelocity2, false, 40, sparkScale2, Main.rand.NextBool() ? bColor : Color.Green); + Particle spark2 = new LineParticle(Projectile.Center, sparkvelocity2, false, 40, sparkScale2, Main.rand.NextBool() ? (!ChildSafety.Disabled ? Color.LimeGreen : bColor) : Color.Green); GeneralParticleHandler.SpawnParticle(spark2); - Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.Blood, sparkvelocity2, 100, default, Main.rand.NextFloat(0.8f, 1.4f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center, (!ChildSafety.Disabled ? (int)CalamityDusts.SulphurousSeaAcid : DustID.Blood), sparkvelocity2, 100, default, Main.rand.NextFloat(0.8f, 1.4f)); dust.noGravity = true; } diff --git a/Projectiles/Ranged/StarfleetHoldout.cs b/Projectiles/Ranged/StarfleetHoldout.cs index 7d354aefea..bc7eb9781c 100644 --- a/Projectiles/Ranged/StarfleetHoldout.cs +++ b/Projectiles/Ranged/StarfleetHoldout.cs @@ -28,7 +28,7 @@ namespace CalamityMod.Projectiles.Ranged public int time = 0; public int lastUseTime = 0; - public static int perfectLeniancy = 2; + public static int perfectLeniancy = 3; public static int goodLeniancy = perfectLeniancy + 6; public static int starburstPerfectTime = 23; public ref float shootingCooldown => ref Projectile.ai[0]; @@ -45,6 +45,7 @@ namespace CalamityMod.Projectiles.Ranged public Color c2 = new Color(222, 225, 146); public Color c3 = new Color(255, 233, 146); public Color shiftColor; + public Vector2 gunBackPosition; public ref float starburstCooldown => ref Projectile.ai[2]; public bool naildriver => ((starburstTimer <= starburstPerfectTime + perfectLeniancy) && (starburstTimer >= starburstPerfectTime - perfectLeniancy)); // if within perfect frame window public bool scattershot => !naildriver && ((starburstTimer <= starburstPerfectTime + goodLeniancy) && (starburstTimer >= starburstPerfectTime - goodLeniancy)); // If within early or late frame window @@ -170,6 +171,8 @@ namespace CalamityMod.Projectiles.Ranged SoundStyle shotgunFire = new("CalamityMod/Sounds/Item/StarfleetFire"); for (int i = 0; i < (naildriver ? 2 : 1); i++) SoundEngine.PlaySound(shotgunFire with { Volume = (naildriver && i == 0 ? 0.3f : 0.6f), Pitch = ((naildriver && i == 0) ? 0f : 0.2f), MaxInstances = 2 }, Projectile.Center); + if (naildriver) + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/HellkiteFullCharge") with { Volume = 0.7f, Pitch = 1.3f, MaxInstances = 2 }, Projectile.Center); // Perfects have longer cooldown int cooldown = (naildriver ? naildriverCooldown : lastUseTime); recoilTimerMax = cooldown; @@ -191,7 +194,30 @@ namespace CalamityMod.Projectiles.Ranged shotgun.extraUpdates = starExtraUpdates; } } - + + for (int b = 0; b < 24; b++) + { + int parts2 = 4; + for (int i = 0; i < parts2; i++) + { + float power = Main.rand.NextFloat(0.2f, 1f); + Vector2 vel = (MathHelper.TwoPi * i / parts2).ToRotationVector2().RotatedBy(Projectile.rotation) * 12f; + float size = (0.8f) * Main.rand.NextFloat(0.9f, 1.1f) * (1.1f - power); + int dustStyle = DustType(); + Dust dust = Dust.NewDustPerfect(gunBackPosition, dustStyle); + dust.scale = size; + dust.velocity = vel * power * (0.7f); + dust.noGravity = true; + dust.color = GetRandomColor(); + dust.fadeIn = naildriver ? -0.6f : 0f; + + if (b == 0) + { + Particle aura = new CustomSpark(gunBackPosition, Vector2.Zero, "CalamityMod/Particles/BloomCircle", false, naildriver ? 35 : 20, 0.5f, shiftColor, new Vector2(0.65f, 1f), glowCenter: true, glowOpacity: 0.8f, glowCenterScale: 0.85f, extraRotation: Projectile.rotation + (i % 2 == 0 ? MathHelper.PiOver2 : 0), shrinkSpeed: 0.1f); + GeneralParticleHandler.SpawnParticle(aura); + } + } + } for (int i = 0; i < 25; i++) { float variance = Main.rand.NextFloat(-0.7f, 0.7f); @@ -274,8 +300,11 @@ namespace CalamityMod.Projectiles.Ranged } public override bool PreDraw(ref Color lightColor) { + gunBackPosition = Projectile.Center - Projectile.velocity * 22f + Projectile.velocity.RotatedBy(MathHelper.PiOver2 * Projectile.direction) * -2; + if (time < 2) return false; + Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Type].Value; Texture2D glowTexture = Request("CalamityMod/Items/Weapons/Ranged/StarfleetGlow").Value; Texture2D orb = Request("CalamityMod/Particles/BloomCircle").Value; diff --git a/Projectiles/Ranged/StarmadaHoldout.cs b/Projectiles/Ranged/StarmadaHoldout.cs index 5a9631b513..719bdc33f9 100644 --- a/Projectiles/Ranged/StarmadaHoldout.cs +++ b/Projectiles/Ranged/StarmadaHoldout.cs @@ -29,7 +29,7 @@ namespace CalamityMod.Projectiles.Ranged public int time = 0; public int lastUseTime = 0; - public static int perfectLeniancy = 2; + public static int perfectLeniancy = 3; public static int goodLeniancy = perfectLeniancy + 6; public static int starburstPerfectTime = 23; public float frontRecoil = 0; @@ -226,7 +226,8 @@ namespace CalamityMod.Projectiles.Ranged SoundStyle shotgunFire = new("CalamityMod/Sounds/Item/StarmadaFire"); for (int i = 0; i < (naildriver ? 2 : 1); i++) SoundEngine.PlaySound(shotgunFire with { Volume = (naildriver && i == 0 ? 0.3f : 0.6f), Pitch = ((naildriver && i == 0) ? -0.2f : 0f), MaxInstances = 2 }, Projectile.Center); - + if (naildriver) + SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/HellkiteFullCharge") with { Volume = 0.7f, Pitch = 1.2f + 0.1f * gunPower, MaxInstances = 2 }, Projectile.Center); for (int b = 0; b < 24; b++) { int parts2 = 4; @@ -241,11 +242,11 @@ namespace CalamityMod.Projectiles.Ranged dust.velocity = vel * power * (0.7f + gunPower * 0.2f); dust.noGravity = true; dust.color = GetRandomColor(); - dust.fadeIn = 0f; + dust.fadeIn = naildriver ? -0.5f : 0f; if (b == 0) { - Particle aura = new CustomSpark(gunBackPosition, Vector2.Zero, "CalamityMod/Particles/BloomCircle", false, 20, size * 0.9f, shiftColor, new Vector2(0.65f, 1f), glowCenter: true, glowOpacity: 0.8f, glowCenterScale: 0.85f, extraRotation: Projectile.rotation + (i % 2 == 0 ? MathHelper.PiOver2 : 0), shrinkSpeed: 0.1f); + Particle aura = new CustomSpark(gunBackPosition, Vector2.Zero, "CalamityMod/Particles/BloomCircle", false, naildriver ? 35 : 20, (0.8f + 0.35f * gunPower) * 0.85f, shiftColor, new Vector2(0.65f, 1f), glowCenter: true, glowOpacity: 0.8f, glowCenterScale: 0.85f, extraRotation: Projectile.rotation + (i % 2 == 0 ? MathHelper.PiOver2 : 0), shrinkSpeed: 0.1f); GeneralParticleHandler.SpawnParticle(aura); } } diff --git a/Projectiles/Rogue/AntumbraShardProjectile.cs b/Projectiles/Rogue/AntumbraShardProjectile.cs index bd944e8832..d35823a7da 100644 --- a/Projectiles/Rogue/AntumbraShardProjectile.cs +++ b/Projectiles/Rogue/AntumbraShardProjectile.cs @@ -34,7 +34,7 @@ namespace CalamityMod.Projectiles.Rogue public bool jitter = false; public Vector2 portalSpot; public Vector2 shadowPlacement; - public int clones = 9; // This is just a counter for the clones, it will not change how many spawn + public int clones = 6; // This is the number of clones spawned by the stealth strike NPC closestTarget; public override void SetDefaults() { @@ -162,7 +162,7 @@ namespace CalamityMod.Projectiles.Rogue if (closestTarget == null) closestTarget = Projectile.Center.ClosestNPCAt(2000); - if (Projectile.Calamity().stealthStrike && time % 20 == 0) + if (Projectile.Calamity().stealthStrike && time % 20 == 0 && clones > 0) { Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center + Main.rand.NextVector2CircularEdge(450, 450) * Main.rand.NextFloat(0.7f, 1.3f), Vector2.Zero, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0, 1, 5); clones--; @@ -260,7 +260,7 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { if (Projectile.numHits > 0) - Projectile.damage = (int)(Projectile.damage * 0.83f); + Projectile.damage = (int)(Projectile.damage * 0.8f); if (Projectile.damage < 1) Projectile.damage = 1; diff --git a/Projectiles/Rogue/DestructionExplosion.cs b/Projectiles/Rogue/DestructionExplosion.cs index aeb01ad6f6..5a3653546f 100644 --- a/Projectiles/Rogue/DestructionExplosion.cs +++ b/Projectiles/Rogue/DestructionExplosion.cs @@ -27,12 +27,6 @@ namespace CalamityMod.Projectiles.Rogue } public override void AI() { - if (Main.zenithWorld) - { - Projectile.hostile = true; - Projectile.friendly = true; - } - if (Projectile.ai[0] == 1) { ExplosionRadius = 800; diff --git a/Projectiles/Rogue/DestructionStar.cs b/Projectiles/Rogue/DestructionStar.cs index 0d25bf3cf0..f8aff95cac 100644 --- a/Projectiles/Rogue/DestructionStar.cs +++ b/Projectiles/Rogue/DestructionStar.cs @@ -153,7 +153,7 @@ namespace CalamityMod.Projectiles.Rogue internal void Explode(bool big) { - float sizeBonus = big ? Main.zenithWorld ? 6 : 2 : 1; + float sizeBonus = big ? 2 : 1; float bigExplosionDamage = 3f; Player Owner = Main.player[Projectile.owner]; Particle orb = new CustomPulse(Projectile.Center, Vector2.Zero, Color.LightGreen with { A = 0 }, "CalamityMod/Particles/LargeBloom", new Vector2(1, 1), Main.rand.NextFloat(-10, 10), 0f, 0.82f * sizeBonus, 11); @@ -164,9 +164,9 @@ namespace CalamityMod.Projectiles.Rogue orb2.DrawLayer = GeneralDrawLayer.AfterEverything; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * (big ? Main.zenithWorld ? bigExplosionDamage * 4f : bigExplosionDamage : Projectile.Calamity().stealthStrike ? 0.25f : 1f)), Projectile.knockBack * 1.5f, Projectile.owner); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * (big ? bigExplosionDamage : Projectile.Calamity().stealthStrike ? 0.25f : 1f)), Projectile.knockBack * 1.5f, Projectile.owner); - if (!Main.zenithWorld || !big) + if (!big) { SoundStyle explo = new("CalamityMod/Sounds/Item/MeldExplosion"); SoundEngine.PlaySound(explo with { Volume = 0.9f }, Projectile.Center); @@ -179,15 +179,11 @@ namespace CalamityMod.Projectiles.Rogue if (big) { - if (!Main.zenithWorld) - { - SoundStyle explo2 = new("CalamityMod/Sounds/Item/EarthMeteor"); - SoundEngine.PlaySound(explo2 with { Volume = 0.9f, Pitch = -0.2f }, Projectile.Center); - - SoundStyle explo3 = new("CalamityMod/Sounds/Item/ExobladeDashImpact"); - SoundEngine.PlaySound(explo3 with { Volume = 0.9f, Pitch = -0.2f }, Projectile.Center); - } + SoundStyle explo2 = new("CalamityMod/Sounds/Item/EarthMeteor"); + SoundEngine.PlaySound(explo2 with { Volume = 0.9f, Pitch = -0.2f }, Projectile.Center); + SoundStyle explo3 = new("CalamityMod/Sounds/Item/ExobladeDashImpact"); + SoundEngine.PlaySound(explo3 with { Volume = 0.9f, Pitch = -0.2f }, Projectile.Center); } Particle bolt2 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.LightGreen, "CalamityMod/Particles/BloomRing", Vector2.One, Main.rand.NextFloat(-10f, 10f), 0f, 2.56f * 1.3f * sizeBonus, 18); diff --git a/Projectiles/Rogue/ExorcismProj.cs b/Projectiles/Rogue/ExorcismProj.cs index 80d124066f..6ea396fde9 100644 --- a/Projectiles/Rogue/ExorcismProj.cs +++ b/Projectiles/Rogue/ExorcismProj.cs @@ -168,12 +168,11 @@ namespace CalamityMod.Projectiles.Rogue if (Projectile.velocity.Length() < storedStealthVel.Length()) Projectile.velocity += Utils.DirectionTo(Projectile.Center, Owner.Center) * 0.1f; Projectile.velocity *= 0.99f; - // CIT 26JUN2025: Removing its ability to deal damage again because it's overpowered - /*if (time == 180) + if (time == 180) // Allow it to hit on the return trip { for (int i = 0; i < Main.maxNPCs; i++) Projectile.localNPCImmunity[i] = 0; - }*/ + } if (Projectile.timeLeft <= 240) { impaleDist = Vector2.One; // This is so the projectile stops dealing damage @@ -308,7 +307,7 @@ namespace CalamityMod.Projectiles.Rogue float minMult = 0.35f; int hitsToMinMult = 10; float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true); - modifiers.SourceDamage *= damageMult; + modifiers.SourceDamage *= damageMult / 2; } else if (!falling || Projectile.numHits != 0) modifiers.SourceDamage *= 0.1f; @@ -344,11 +343,17 @@ namespace CalamityMod.Projectiles.Rogue { if (Main.zenithWorld) { + // All is cleansed by The Lord for (int index = 0; index < Main.npc.Length; index++) - { - NPC searchedTarget = Main.npc[index]; - searchedTarget.active = false; - } + { NPC searchedTarget = Main.npc[index]; searchedTarget.active = false; } + for (int x = 0; x < Main.maxProjectiles; x++) + { Projectile projectile = Main.projectile[x]; if (projectile.active && projectile.type != ModContent.ProjectileType() && projectile.type != ModContent.ProjectileType()) { projectile.active = false; } } + for (int x = 0; x < Main.maxItems; x++) + { Item item = Main.item[x]; if (item.active) { item.active = false; } } + for (int x = 0; x < Main.maxDust; x++) + { Dust dust = Main.dust[x]; if (dust.active) { dust.active = false; } } + for (int x = 0; x < Main.maxGore; x++) + { Gore gore = Main.gore[x]; if (gore.active) { gore.active = false; } } SoundStyle gong = new("CalamityMod/Sounds/Custom/GFB/Jesus"); for (int i = 0; i < 2; i++) diff --git a/Projectiles/Rogue/LeviathanTooth.cs b/Projectiles/Rogue/LeviathanTooth.cs index 86a1595caf..4bea0fd77a 100644 --- a/Projectiles/Rogue/LeviathanTooth.cs +++ b/Projectiles/Rogue/LeviathanTooth.cs @@ -5,6 +5,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; +using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; @@ -54,7 +55,7 @@ namespace CalamityMod.Projectiles.Rogue public override void AI() { - Lighting.AddLight(Projectile.Center, Color.Lerp(Color.Red, Color.White, 0.85f).ToVector3() * 0.5f * Utils.GetLerpValue(255, 0, Projectile.alpha, true)); + Lighting.AddLight(Projectile.Center, (!ChildSafety.Disabled ? Color.CornflowerBlue : Color.Lerp(Color.Red, Color.White, 0.85f)).ToVector3() * 0.5f * Utils.GetLerpValue(255, 0, Projectile.alpha, true)); if (time == 0) { stuckTimer = Main.rand.Next(100, 120 + 1); @@ -68,10 +69,10 @@ namespace CalamityMod.Projectiles.Rogue Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; if ((time % 2 == 0 || !canStick) && time > 5) { - Dust dust = Dust.NewDustPerfect(Projectile.Center - Projectile.velocity.SafeNormalize(Vector2.UnitX) * 3 + Main.rand.NextVector2Circular(6, 6), DustID.Blood, (-Projectile.velocity.SafeNormalize(Vector2.UnitX) * 4).RotatedByRandom(0.3f) * Main.rand.NextFloat(0.1f, 0.8f), 100, default, Main.rand.NextFloat(0.8f, 1.4f) * (canStick ? 1 : 1.3f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center - Projectile.velocity.SafeNormalize(Vector2.UnitX) * 3 + Main.rand.NextVector2Circular(6, 6), !ChildSafety.Disabled ? DustID.Cloud : DustID.Blood, (-Projectile.velocity.SafeNormalize(Vector2.UnitX) * 4).RotatedByRandom(0.3f) * Main.rand.NextFloat(0.1f, 0.8f), 100, default, Main.rand.NextFloat(0.8f, 1.4f) * (canStick ? 1 : 1.3f)); dust.noGravity = true; Particle blood = new CustomSpark(Projectile.Center, -Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedByRandom(canStick ? 0.3f : 0.1f) * Main.rand.NextFloat(5f, 8f), "CalamityMod/Particles/LargeBloom", - false, 8, Main.rand.NextFloat(0.055f, 0.07f), Color.Lerp(Color.DarkRed, Color.Black, Main.rand.NextFloat(0, 0.5f)) * 0.7f, new Vector2(0.7f, 1f), false, shrinkSpeed: 0.8f); + false, 8, Main.rand.NextFloat(0.055f, 0.07f), (!ChildSafety.Disabled ? Color.CornflowerBlue : Color.Lerp(Color.DarkRed, Color.Black, Main.rand.NextFloat(0, 0.5f))) * 0.7f, new Vector2(0.7f, 1f), false, shrinkSpeed: 0.8f); GeneralParticleHandler.SpawnParticle(blood); } if (time > 90 && canStick) @@ -111,12 +112,12 @@ namespace CalamityMod.Projectiles.Rogue for (int i = 0; i <= 7; i++) { - Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.Blood, (storedVelocity * 2.5f).RotatedByRandom(0.7) * Main.rand.NextFloat(0.1f, 0.8f), 0, default, Main.rand.NextFloat(0.9f, 1.8f)); + Dust dust = Dust.NewDustPerfect(Projectile.Center, !ChildSafety.Disabled ? DustID.Cloud : DustID.Blood, (storedVelocity * 2.5f).RotatedByRandom(0.7) * Main.rand.NextFloat(0.1f, 0.8f), 0, default, Main.rand.NextFloat(0.9f, 1.8f)); dust.noGravity = false; } for (int i = 0; i <= 3; i++) { - Particle spark = new AltSparkParticle(Projectile.Center, (storedVelocity * 4.5f).RotatedByRandom(0.7) * Main.rand.NextFloat(0.1f, 0.8f) + new Vector2(0, -2), true, 20, 0.5f, Color.DarkRed * 0.7f); + Particle spark = new AltSparkParticle(Projectile.Center, (storedVelocity * 4.5f).RotatedByRandom(0.7) * Main.rand.NextFloat(0.1f, 0.8f) + new Vector2(0, -2), true, 20, 0.5f, (!ChildSafety.Disabled ? Color.CornflowerBlue : Color.DarkRed) * 0.7f); GeneralParticleHandler.SpawnParticle(spark); } SoundStyle sound = new("CalamityMod/Sounds/NPCHit/PerfSmallHit", 3); diff --git a/Projectiles/Rogue/LeviathanToothStealth.cs b/Projectiles/Rogue/LeviathanToothStealth.cs index 34163a3f15..24fdafda21 100644 --- a/Projectiles/Rogue/LeviathanToothStealth.cs +++ b/Projectiles/Rogue/LeviathanToothStealth.cs @@ -6,6 +6,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; +using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; using static Terraria.Player; @@ -166,14 +167,14 @@ namespace CalamityMod.Projectiles.Rogue if (!spawnedDust && toothNum > 1) { - Dust dust = Dust.NewDustPerfect(finalDrawPos, DustID.Blood, (rotation.ToRotationVector2().RotatedBy(MathHelper.PiOver2)).RotatedByRandom(0.5f).RotatedBy(1.2f * (isTopJaw ? -1 : 1)) * Main.rand.NextFloat(5f, 8f), 100, default, Main.rand.NextFloat(1.1f, 1.9f) * scale); + Dust dust = Dust.NewDustPerfect(finalDrawPos, !ChildSafety.Disabled ? DustID.Cloud : DustID.Blood, (rotation.ToRotationVector2().RotatedBy(MathHelper.PiOver2)).RotatedByRandom(0.5f).RotatedBy(1.2f * (isTopJaw ? -1 : 1)) * Main.rand.NextFloat(5f, 8f), 100, default, Main.rand.NextFloat(1.1f, 1.9f) * scale); dust.noGravity = true; dust.alpha = (int)(255 * (1 - toothOpacity)); Particle blood = new CustomSpark(finalDrawPos, (rotation.ToRotationVector2().RotatedBy(MathHelper.PiOver2)).RotatedByRandom(0.4f).RotatedBy(1.2f * (isTopJaw ? -1 : 1)) * Main.rand.NextFloat(5f, 8f), "CalamityMod/Particles/LargeBloom", - false, 8, Main.rand.NextFloat(0.065f, 0.08f) * scale, Color.Lerp(Color.DarkRed, Color.Black, Main.rand.NextFloat(0, 0.5f)) * 0.7f * toothOpacity, new Vector2(1f, 1f), false, shrinkSpeed: 0.9f); + false, 8, Main.rand.NextFloat(0.065f, 0.08f) * scale, (!ChildSafety.Disabled ? Color.CornflowerBlue : Color.Lerp(Color.DarkRed, Color.Black, Main.rand.NextFloat(0, 0.5f))) * 0.7f * toothOpacity, new Vector2(1f, 1f), false, shrinkSpeed: 0.9f); GeneralParticleHandler.SpawnParticle(blood); - Lighting.AddLight(finalDrawPos, Color.Lerp(Color.Red, Color.White, 0.85f).ToVector3() * 1.2f * toothOpacity); + Lighting.AddLight(finalDrawPos, (!ChildSafety.Disabled ? Color.CornflowerBlue : Color.Lerp(Color.Red, Color.White, 0.85f)).ToVector3() * 1.2f * toothOpacity); } } isTopJaw = (t == -1); diff --git a/Projectiles/Rogue/MoltenAmputatorProj.cs b/Projectiles/Rogue/MoltenAmputatorProj.cs index 85870c6c1c..8abe375b9c 100644 --- a/Projectiles/Rogue/MoltenAmputatorProj.cs +++ b/Projectiles/Rogue/MoltenAmputatorProj.cs @@ -258,7 +258,7 @@ namespace CalamityMod.Projectiles.Rogue } } } - if (pulled && (pulledTimer < 10 || Owner.Calamity().amputatorBuff > 0) && !AMPUTATE && !Projectile.Calamity().stealthStrike) + if (pulled && (pulledTimer < 10 || Owner.Calamity().focusFlurryAttackCount > 0) && !AMPUTATE && !Projectile.Calamity().stealthStrike) { // Amputate them Projectile strike = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), target.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage * 7, 0f, Owner.whoAmI, target.whoAmI, 1f); diff --git a/Projectiles/Rogue/NanoblackLightspeedCarve.cs b/Projectiles/Rogue/NanoblackLightspeedCarve.cs new file mode 100644 index 0000000000..0c6a4f2a7f --- /dev/null +++ b/Projectiles/Rogue/NanoblackLightspeedCarve.cs @@ -0,0 +1,65 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Rogue +{ + public class NanoblackLightspeedCarve : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Rogue"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public override LocalizedText DisplayName => this.GetLocalization(IsPerfect ? "Perfect" : "Standard"); + + internal const float TargetingRange = 600f; + internal const int MaxHits = 3; + + internal static float HitboxRadius = 60.0f; + internal static float PlacementRandomness = 12f; + + private static int Lifetime = 24; + private static int HitboxDuration = 9; // Hits on 0-4-8 + + internal bool IsPerfect => Projectile.ai[0] == 1f; + + public override void SetDefaults() + { + Projectile.width = Projectile.height = (int)(2f * HitboxRadius); + Projectile.friendly = true; + Projectile.DamageType = RogueDamageClass.Instance; + Projectile.penetrate = 1; // Actually three hits, but intentionally obfuscates and violates pierce resistance + Projectile.extraUpdates = 0; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + Projectile.alpha = 255; + Projectile.timeLeft = Lifetime; + + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 4; + } + + public override void AI() + { + if (Projectile.timeLeft == Lifetime) + FrameOneEffects(); + } + + private void FrameOneEffects() + { + if (Main.netMode != NetmodeID.Server) + { + int slashVisualID = ModContent.ProjectileType(); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, slashVisualID, 0, 0f, Projectile.owner, IsPerfect ? 1f : 0f); + } + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + if (Projectile.timeLeft > Lifetime - HitboxDuration && Projectile.numHits < MaxHits) + Projectile.penetrate++; + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, HitboxRadius, targetHitbox); + } +} diff --git a/Projectiles/Rogue/NanoblackLightspeedCarveSlashVisual.cs b/Projectiles/Rogue/NanoblackLightspeedCarveSlashVisual.cs new file mode 100644 index 0000000000..49d84325d8 --- /dev/null +++ b/Projectiles/Rogue/NanoblackLightspeedCarveSlashVisual.cs @@ -0,0 +1,556 @@ +using System; +using System.Collections.Generic; +using CalamityMod.Effects; +using CalamityMod.Graphics.Primitives; +using CalamityMod.Items.Weapons.Rogue; +using CalamityMod.Utilities.Daybreak; +using CalamityMod.Utilities.Daybreak.Buffers; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Rogue +{ + public class NanoblackLightspeedCarveSlashVisual : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Rogue"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + #region params + private const int VisualLifetime = 80; + private const int GrowTime = 3; + private const int FadeInTime = 1; + private const int FadeOutTime = 5; + private const int SlashDelay = 2; + private const int HoldTime = 5; + private const float FlashIntensity = 1.8f; + private const float FlashDuration = 0.15f; + private const float RangeMultiplier = 2.2f; + private const float MinWidthStandard = 14f; + private const float MaxWidthStandard = 46f; + private const float MinWidthPerfect = 28f; + private const float MaxWidthPerfect = 62f; + + private const float RevealSoftEdge = 0.25f; + private const float RevealOvershoot = 0.22f; + private const float RetreatSoftEdge = 0.18f; + private const float RetreatOvershoot = 0.18f; + private const int SlashResolution = 12; + private const float LightningAmplitude = 2.5f; + private const float LightningAmplitudePerfect = 3.5f; + private const int LightningSubdivisions = 3; + private const float LightningDecay = 0.45f; + private const float LightningDriftSpeed = 4f; + private const float MaxDepth = 40f; + private const float DepthWobbleAmount = 8f; + private const float DepthWobbleSpeed = 6f; + private const float BreathingAmount = 0.06f; + private const float BreathingSpeed = 9f; + private const float CurveStrength = 0.12f; + private const float CurveStrengthPerfect = 0.18f; + private const int EchoCount = 1; + private const float EchoOpacityFalloff = 0.4f; + private const float EchoWidthFalloff = 0.75f; + private const float EchoTimeLag = 4.5f; + private const float GiantSlashLengthMult = 3.4f; + private const float GiantSlashWidth = 120f; + private const int GiantSlashGrowTime = 3; + private const int GiantSlashHoldTime = 5; + private const int GiantSlashFadeTime = 12; + private const int GiantSlashDelay = 4; + private const int GiantSlashStagger = 4; + private const float GiantSlashScreenShake = 0f; + private const float GiantSlashImpactFlash = 2.2f; + private const float GiantSlashImpactFlashDuration = 3f; + #endregion + + private static readonly BlendState GiantSlashDarkenBlend = new BlendState + { + ColorSourceBlend = Blend.Zero, + ColorDestinationBlend = Blend.InverseSourceAlpha, + AlphaSourceBlend = Blend.Zero, + AlphaDestinationBlend = Blend.InverseSourceAlpha, + }; + + private int GiantSlashCount => 1; + // 13FEB2026: Ozzatron: previous hash function for allowing multiple visual giant slashes preserved + /* + { + get + { + float seed = Projectile.identity * 1.913f; + return Hash(seed * 3.91f) > 0.5f ? 2 : 1; + } + } + */ + + internal bool IsPerfect => Projectile.ai[0] == 1f; + + public override void SetDefaults() + { + Projectile.width = 2; + Projectile.height = 2; + Projectile.friendly = false; + Projectile.hostile = false; + Projectile.penetrate = -1; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + Projectile.alpha = 255; + Projectile.timeLeft = VisualLifetime; + } + + public override bool ShouldUpdatePosition() => false; + + public override void AI() + { + if (IsPerfect) + { + float age = VisualLifetime - Projectile.timeLeft; + int count = GiantSlashCount; + for (int g = 0; g < count; g++) + { + float giantAge = GetGiantAge(age, g); + if (giantAge >= 0f && giantAge < 1f) + { + Player owner = Main.player[Projectile.owner]; + owner.SetScreenshake(GiantSlashScreenShake); + } + } + } + } + private static float Hash(float x) + { + // ty shadertoy :p + float s = MathF.Sin(x * 127.1f) * 43758.5453f; + return s - MathF.Floor(s); + } + + private List BuildSlashPath( + Vector2 center, + Vector2 direction, + float halfLength, + float curveAmount, + float slashSeed, + float growProgress, + float time) + { + var path = new List(SlashResolution); + Vector2 perp = direction.RotatedBy(MathHelper.PiOver2); + bool valid = true; + + for (int p = 0; p < SlashResolution; p++) + { + float t = (float)p / (SlashResolution - 1); + float s = t * 2f - 1f; + Vector2 basePos = center + direction * s * halfLength; + + float curveBulge = (1f - s * s) * curveAmount * halfLength; + basePos += perp * curveBulge; + + float lightning = 0f; + float amplitude = IsPerfect ? LightningAmplitudePerfect : LightningAmplitude; + float freq = 1f; + for (int oct = 0; oct < LightningSubdivisions; oct++) + { + float noiseInput = slashSeed * 13.7f + s * freq * 1.8f + oct * 5.3f + time * LightningDriftSpeed * (1f + oct * 0.3f); + lightning += (Hash(noiseInput) * 2f - 1f) * amplitude; + amplitude *= LightningDecay; + freq *= 1.8f; + } + + float envelopeWindow = 1f - s * s; + lightning *= envelopeWindow * growProgress; + + basePos += perp * lightning; + + float depthWobble = MathF.Sin(time * DepthWobbleSpeed + slashSeed * 4.1f + s * 2f) * DepthWobbleAmount; + float z = (MathF.Sin(s * MathHelper.Pi + slashSeed * 2.9f) * MaxDepth + depthWobble) * (0.5f + 0.5f * growProgress); + + Vector2 screenPos = basePos - Main.screenPosition; + + if (float.IsNaN(screenPos.X) || float.IsNaN(screenPos.Y) || float.IsNaN(z) || + float.IsInfinity(screenPos.X) || float.IsInfinity(screenPos.Y) || float.IsInfinity(z)) + { + valid = false; + break; + } + + path.Add(new Vector3(screenPos, z)); + } + + if (!valid || path.Count < 2) + { + path.Clear(); + Vector2 start = center - direction * halfLength - Main.screenPosition; + Vector2 end = center + direction * halfLength - Main.screenPosition; + path.Add(new Vector3(start, 0f)); + path.Add(new Vector3(end, 0f)); + } + + return path; + } + + private static float SlashWidthFunc(float progress, float baseWidth, float cracklePhase, float revealProgress, float retreatProgress) + { + float taperInLinear = MathHelper.Clamp(progress / 0.08f, 0f, 1f); + float taperOutLinear = MathHelper.Clamp((1f - progress) / 0.08f, 0f, 1f); + float taperIn = 1f - MathF.Pow(1f - taperInLinear, 3f); + float taperOut = 1f - MathF.Pow(1f - taperOutLinear, 3f); + float taper = taperIn * taperOut; + + float revealLinear = MathHelper.Clamp((revealProgress - progress) / RevealSoftEdge, 0f, 1f); + float reveal = 1f - MathF.Pow(1f - revealLinear, 4f); + + float retreatRaw = MathHelper.Clamp((progress - retreatProgress + RetreatSoftEdge) / RetreatSoftEdge, 0f, 1f); + float retreat = 1f - MathF.Pow(1f - retreatRaw, 4f); + + float crackle = 1f + + 0.06f * MathF.Sin(progress * 13f + cracklePhase) + + 0.04f * MathF.Sin(progress * 29f - cracklePhase * 1.7f); + + return baseWidth * taper * crackle * reveal * retreat; + } + + private static float GiantSlashWidthFunc(float progress, float baseWidth, float revealProgress, float retreatProgress) + { + float taperIn = 1f - MathF.Pow(1f - MathHelper.Clamp(progress / 0.06f, 0f, 1f), 4f); + float taperOut = 1f - MathF.Pow(1f - MathHelper.Clamp((1f - progress) / 0.06f, 0f, 1f), 4f); + float taper = taperIn * taperOut; + + float centered = (progress - 0.5f) * 2f; + float starProfile = MathF.Pow(1f - centered * centered, 0.35f); + float starShape = MathHelper.Lerp(0.3f, 1f, starProfile); + + float revealLinear = MathHelper.Clamp((revealProgress - progress) / 0.2f, 0f, 1f); + float reveal = 1f - MathF.Pow(1f - revealLinear, 5f); + + float retreatRaw = MathHelper.Clamp((progress - retreatProgress + 0.2f) / 0.2f, 0f, 1f); + float retreat = 1f - MathF.Pow(1f - retreatRaw, 5f); + + return baseWidth * taper * starShape * reveal * retreat; + } + + public override bool PreDraw(ref Color lightColor) + { + int slashCount = IsPerfect ? 12 : 8; + + float age = VisualLifetime - Projectile.timeLeft; + + Effect shader = CalamityShaders.NanoblackSlashShader.Value; + float time = (float)Main.gameTimeCache.TotalGameTime.TotalSeconds; + shader.Parameters["uTime"]?.SetValue(time); + Color c = IsPerfect ? NanoblackReaper.LightspeedCarveColor1 : NanoblackReaper.NanoblackSlashColor2; + shader.Parameters["uColor"]?.SetValue(new Vector3(c.R / 255f, c.G / 255f, c.B / 255f)); + shader.Parameters["uBrightness"]?.SetValue(1f); + + Matrix view = Main.GameViewMatrix.ZoomMatrix; + Matrix projection = Matrix.CreateOrthographicOffCenter(0, Main.screenWidth, Main.screenHeight, 0, -200f, 200f); + + float baseLength = NanoblackLightspeedCarve.HitboxRadius * 0.9f * RangeMultiplier; + float seed = Projectile.identity * 1.913f; + float curveBase = IsPerfect ? CurveStrengthPerfect : CurveStrength; + + var device = Main.instance.GraphicsDevice; + + using var lease = RenderTargetPool.Shared.Rent( + device, + Main.screenWidth, + Main.screenHeight, + RenderTargetDescriptor.Default + ); + + Main.spriteBatch.End(out var ss); + + using (lease.Scope(clearColor: Color.Transparent)) + { + using var scope = SanePrimitiveRenderer.BeginShaderScope(shader, Matrix.Identity, view, projection, + depthState: DepthStencilState.None, blendState: BlendState.Additive); + + DrawAllSlashes(scope, slashCount, age, time, seed, baseLength, curveBase); + + if (IsPerfect) + { + int giantCount = GiantSlashCount; + for (int g = 0; g < giantCount; g++) + DrawGiantSlash(scope, age, time, seed, baseLength, g); + } + } + + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.LinearClamp, + DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Matrix.Identity); + Main.spriteBatch.Draw(lease.Target, Vector2.Zero, Color.White); + Main.spriteBatch.End(); + + Effect bloomShader = CalamityShaders.GaussianBloomShader.Value; + bloomShader.Parameters["uSource"]?.SetValue(new Vector4(Main.screenWidth, Main.screenHeight, 0f, 0f)); + + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, + DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Matrix.Identity); + bloomShader.CurrentTechnique.Passes["BloomShader"].Apply(); + Main.spriteBatch.Draw(lease.Target, Vector2.Zero, Color.White); + Main.spriteBatch.End(); + + if (IsPerfect) + { + int giantCount = GiantSlashCount; + for (int g = 0; g < giantCount; g++) + DrawGiantSlashBlackCore(age, time, seed, baseLength, g); + } + + Main.spriteBatch.Begin(ss); + + return false; + } + + private void DrawAllSlashes( + SanePrimitiveRenderer.ShaderScope scope, + int slashCount, float age, float time, + float seed, float baseLength, float curveBase) + { + for (int i = 0; i < slashCount; i++) + { + float startDelay = i * SlashDelay; + float growLinear = Utils.GetLerpValue(startDelay, startDelay + GrowTime, age, true); + if (growLinear <= 0f) + continue; + float growProgress = 1f - MathF.Pow(1f - growLinear, 2.5f); + float fadeIn = Utils.GetLerpValue(startDelay, startDelay + FadeInTime, age, true); + + float angle = MathHelper.TwoPi * i / slashCount + seed * 0.1f; + float lengthScale = 0.75f + 0.2f * MathF.Sin(seed + i * 1.7f); + float offsetScale = 0.25f * MathF.Cos(seed * 1.3f + i * 2.1f); + float widthInterpolant = 0.5f + 0.5f * MathF.Sin(seed * 0.7f + i * 2.3f); + float minWidth = IsPerfect ? MinWidthPerfect : MinWidthStandard; + float maxWidth = IsPerfect ? MaxWidthPerfect : MaxWidthStandard; + float slashWidth = MathHelper.Lerp(minWidth, maxWidth, widthInterpolant); + + Vector2 direction = angle.ToRotationVector2(); + Vector2 perpendicular = direction.RotatedBy(MathHelper.PiOver2); + Vector2 offset = perpendicular * baseLength * offsetScale; + Vector2 center = Projectile.Center + offset; + float halfLength = baseLength * lengthScale; + + float slashSeed = seed + i * 3.17f; + + float curveDirection = (i % 2 == 0) ? 1f : -1f; + float curveSigned = curveBase * curveDirection * (0.7f + 0.6f * Hash(slashSeed * 0.43f)); + + float retreatStartAge = startDelay + GrowTime + HoldTime; + float retreatAge = Utils.GetLerpValue(retreatStartAge, retreatStartAge + FadeOutTime, age, true); + float slashFadeOut = 1f - retreatAge; + if (slashFadeOut <= 0f) + continue; + + float smoothFadeOut = MathF.Pow(slashFadeOut, 0.5f); + + float flashProgress = 1f - slashFadeOut; + float flash = 1f; + if (flashProgress > 0f && flashProgress < FlashDuration) + { + float flashT = flashProgress / FlashDuration; + flash = 1f + (FlashIntensity - 1f) * (1f - MathF.Pow(1f - MathF.Sin(flashT * MathHelper.Pi), 2f)); + } + + float widthCollapse = 0.7f + 0.3f * MathF.Pow(smoothFadeOut, 3f); + + float retreatT = 1f - smoothFadeOut; + float retreatProgress = MathF.Pow(retreatT, 0.4f) * (1f + RetreatOvershoot); + + float colorShift = MathF.Pow(1f - smoothFadeOut, 2f); + Color aliveColor = NanoblackReaper.LightspeedCarveColor1; + Color dyingColor = NanoblackReaper.LightspeedCarveColor2; + Color baseColor = Color.Lerp(aliveColor, dyingColor, colorShift); + + float opacityFade = MathF.Pow(MathHelper.Clamp(smoothFadeOut / 0.2f, 0f, 1f), 0.3f); + float shimmer = 1f + 0.08f * MathF.Sin(time * 14f + slashSeed * 7.7f) + + 0.05f * MathF.Sin(time * 23f - slashSeed * 4.1f); + float opacity = opacityFade * fadeIn * flash * shimmer; + float cracklePhase = slashSeed * 11f + time * 12f; + + float breathing = 1f + BreathingAmount * MathF.Sin(time * BreathingSpeed + slashSeed * 3.3f); + float fadedWidth = slashWidth * widthCollapse * breathing; + + for (int echo = EchoCount; echo >= 0; echo--) + { + float echoAge = age - echo * EchoTimeLag; + float echoGrowLinear = Utils.GetLerpValue(startDelay, startDelay + GrowTime, echoAge, true); + if (echoGrowLinear <= 0f) + continue; + float echoGrow = 1f - MathF.Pow(1f - echoGrowLinear, 2.5f); + float echoFadeIn = Utils.GetLerpValue(startDelay, startDelay + FadeInTime, echoAge, true); + + float echoOpacity = opacity * echoFadeIn * MathF.Pow(EchoOpacityFalloff, echo); + float echoWidth = fadedWidth * MathF.Pow(EchoWidthFalloff, echo); + + float echoTime = time - echo * 0.06f; + + float echoLength = halfLength * (echo == 0 ? 1f : 0.97f - echo * 0.02f); + List path = BuildSlashPath( + center, direction, echoLength, + curveSigned, slashSeed, echoGrow, echoTime); + + Color echoTint = NanoblackReaper.NanoblackSlashColor2; + Color echoColor = echo == 0 + ? baseColor * echoOpacity + : Color.Lerp(echoTint, dyingColor, colorShift) * echoOpacity; + + float capturedEchoWidth = echoWidth; + float capturedCrackle = cracklePhase - echo * 5f; + + float capturedReveal = echoGrow * (1f + RevealOvershoot); + float capturedRetreat = retreatProgress; + + using var mesh = TriangleStripBuilder.BuildStripPooled( + path, + progress => SlashWidthFunc(progress, capturedEchoWidth, capturedCrackle, capturedReveal, capturedRetreat), + echoColor, + PrimitiveMeshCache.Shared, + textured: true, + smoothingSegments: 2); + + scope.Draw(mesh.View); + } + } + } + + private void DrawGiantSlash( + SanePrimitiveRenderer.ShaderScope scope, + float age, float time, float seed, float baseLength, int giantIndex) + { + float giantAge = GetGiantAge(age, giantIndex); + if (!TryGetGiantTimeline(giantAge, out float growProgress, out float fadeLinear, out float smoothFade)) + return; + + float impactFlash = CalculateImpactFlash(giantAge); + List path = BuildGiantSlashPath(time, seed, baseLength, giantIndex, growProgress); + + float widthCollapse = 0.6f + 0.4f * MathF.Pow(smoothFade, 3f); + float impactWidthBoost = 1f + 0.15f * MathF.Max(impactFlash - 1f, 0f); + float currentWidth = GiantSlashWidth * widthCollapse * impactWidthBoost; + + float opacity = MathF.Pow(MathHelper.Clamp(smoothFade / 0.15f, 0f, 1f), 0.3f) * MathF.Min(impactFlash, 2.5f); + Color edgeColor = NanoblackReaper.LightspeedCarveColor1 * opacity; + + float retreatProgress = CalculateGiantRetreatProgress(fadeLinear); + + float capturedWidth = currentWidth; + float capturedReveal = growProgress * 1.22f; + float capturedRetreat = retreatProgress; + + using var mesh = TriangleStripBuilder.BuildStripPooled( + path, + progress => GiantSlashWidthFunc(progress, capturedWidth, capturedReveal, capturedRetreat), + edgeColor, + PrimitiveMeshCache.Shared, + textured: true, + smoothingSegments: 2); + + scope.Draw(mesh.View); + } + + private void DrawGiantSlashBlackCore( + float age, float time, float seed, float baseLength, int giantIndex) + { + float giantAge = GetGiantAge(age, giantIndex); + if (!TryGetGiantTimeline(giantAge, out float growProgress, out float fadeLinear, out float smoothFade)) + return; + + List path = BuildGiantSlashPath(time, seed, baseLength, giantIndex, growProgress); + + float widthCollapse = 0.6f + 0.4f * MathF.Pow(smoothFade, 3f); + float coreWidth = GiantSlashWidth * 0.65f * widthCollapse; + + float opacity = MathF.Pow(MathHelper.Clamp(smoothFade / 0.15f, 0f, 1f), 0.3f); + + Color coreColor = Color.White * opacity; + + float retreatProgress = CalculateGiantRetreatProgress(fadeLinear); + + float capturedWidth = coreWidth; + float capturedReveal = growProgress * 1.22f; + float capturedRetreat = retreatProgress; + + Effect shader = CalamityShaders.NanoblackSlashShader.Value; + shader.Parameters["uColor"]?.SetValue(new Vector3(1f, 1f, 1f)); + shader.Parameters["uBrightness"]?.SetValue(1.5f); + + Matrix view = Main.GameViewMatrix.ZoomMatrix; + Matrix projection = Matrix.CreateOrthographicOffCenter(0, Main.screenWidth, Main.screenHeight, 0, -200f, 200f); + + using var scope = SanePrimitiveRenderer.BeginShaderScope(shader, Matrix.Identity, view, projection, + depthState: DepthStencilState.None, blendState: GiantSlashDarkenBlend); + + using var mesh = TriangleStripBuilder.BuildStripPooled( + path, + progress => GiantSlashWidthFunc(progress, capturedWidth, capturedReveal, capturedRetreat), + coreColor, + PrimitiveMeshCache.Shared, + textured: true, + smoothingSegments: 2); + + scope.Draw(mesh.View); + + Color c = NanoblackReaper.LightspeedCarveColor1; + shader.Parameters["uColor"]?.SetValue(new Vector3(c.R / 255f, c.G / 255f, c.B / 255f)); + shader.Parameters["uBrightness"]?.SetValue(1f); + } + + private static float CalculateGiantRetreatProgress(float fadeLinear) + => fadeLinear > 0f ? MathF.Pow(fadeLinear, 0.4f) * 1.2f : 0f; + + private float GetGiantAge(float age, int giantIndex) + => age - GiantSlashDelay - giantIndex * GiantSlashStagger; + + private static bool TryGetGiantTimeline(float giantAge, out float growProgress, out float fadeLinear, out float smoothFade) + { + growProgress = 0f; + fadeLinear = 0f; + smoothFade = 0f; + + if (giantAge < 0f) + return false; + + float growLinear = MathHelper.Clamp(giantAge / GiantSlashGrowTime, 0f, 1f); + growProgress = 1f - MathF.Pow(1f - growLinear, 4f); + + float fadeStartAge = GiantSlashGrowTime + GiantSlashHoldTime; + fadeLinear = MathHelper.Clamp((giantAge - fadeStartAge) / GiantSlashFadeTime, 0f, 1f); + + float fadeOut = 1f - fadeLinear; + if (fadeOut <= 0f) + return false; + + smoothFade = MathF.Pow(fadeOut, 0.5f); + return true; + } + + private static float CalculateImpactFlash(float giantAge) + { + if (giantAge >= GiantSlashImpactFlashDuration) + return 1f; + + float flashT = 1f - (giantAge / GiantSlashImpactFlashDuration); + return 1f + (GiantSlashImpactFlash - 1f) * flashT * flashT; + } + + private List BuildGiantSlashPath(float time, float seed, float baseLength, int giantIndex, float growProgress) + { + float angle = Hash(seed * 2.71f + giantIndex * 7.13f) * MathHelper.TwoPi; + Vector2 direction = angle.ToRotationVector2(); + + float halfLength = baseLength * GiantSlashLengthMult; + float slashSeed = seed * 5.13f + giantIndex * 11.7f; + + return BuildSlashPath( + Projectile.Center, + direction, + halfLength, + 0f, + slashSeed, + growProgress, + time); + } + } +} diff --git a/Projectiles/Rogue/NanoblackMain.cs b/Projectiles/Rogue/NanoblackMain.cs index cd18f9f0ff..09ee645e10 100644 --- a/Projectiles/Rogue/NanoblackMain.cs +++ b/Projectiles/Rogue/NanoblackMain.cs @@ -1,7 +1,10 @@ -using System; +using System.IO; +using CalamityMod.Dusts; using CalamityMod.Items.Weapons.Rogue; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; +using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; @@ -12,15 +15,82 @@ namespace CalamityMod.Projectiles.Rogue public new string LocalizationCategory => "Projectiles.Rogue"; public override string Texture => "CalamityMod/Items/Weapons/Rogue/NanoblackReaper"; - private const float RotationIncrement = 0.22f; + internal const int UpdatesPerFrame = 3; private const int Lifetime = 240; - private const float ReboundTime = 50f; - private const int MinBladeTimer = 13; - private const int MaxBladeTimer = 18; + private static int InternalLifetime => Lifetime * UpdatesPerFrame; + private const float BoomerangReturnTime = 16f; + private const int BaseTesselationDelay = 4; + private static int InternalTesselationDelay => BaseTesselationDelay * UpdatesPerFrame; + private const float TesselationSpawnSpeed = 24f; + + internal const float RotationIncrement = 0.22f; + + private static readonly SoundStyle LightspeedMissSound = new("CalamityMod/Sounds/Item/NanoblackReaper/NanoblackReaper_LightspeedMiss") + { + Volume = 0.8f, + PitchVariance = 0.1f, + MaxInstances = 8, + }; + + private static readonly SoundStyle LightspeedPerfectMissSound = new("CalamityMod/Sounds/Item/NanoblackReaper/NanoblackReaper_LightspeedMissPerfect") + { + Volume = 0.9f, + PitchVariance = 0.08f, + MaxInstances = 8, + }; + + private static readonly SoundStyle LightspeedSlashBaseSound = new("CalamityMod/Sounds/Item/NanoblackReaper/NanoblackReaper_LightspeedSlash") + { + Volume = 0.85f, + PitchVariance = 0.08f, + MaxInstances = 10, + }; + + private static readonly SoundStyle LightspeedSlashVariantSound = new("CalamityMod/Sounds/Item/NanoblackReaper/NanoblackReaper_LightspeedSlash", 3) + { + Volume = 0.65f, + PitchVariance = 0.12f, + MaxInstances = 10, + }; + + private static readonly SoundStyle LightspeedPerfectSlashSound = new("CalamityMod/Sounds/Item/NanoblackReaper/NanoblackReaper_PerfectLightspeedSlash") + { + Volume = 0.95f, + PitchVariance = 0.06f, + MaxInstances = 8, + }; + + private Player Owner => Main.player[Projectile.owner]; + internal ref float RealFrameCounter => ref Projectile.ai[0]; + internal ref float TesselationSpawnCooldown => ref Projectile.ai[1]; + + // 0f = Initial state + // 1f = Mouse button still held: Can be pulled back, but isn't in the perfect window + // 2f = Mouse button still held: Can be pulled back, will be perfect + // 3f = Mouse button no longer held + internal ref float LightspeedCarveState => ref Projectile.ai[2]; + internal const float LightspeedCarveState_Initial = 0f; + internal const float LightspeedCarveState_CanImperfect = 1f; + internal const float LightspeedCarveState_CanPerfect = 2f; + internal const float LightspeedCarveState_Performed = 3f; + + internal bool Returning + { + get => Projectile.localAI[0] != 0f; + set => Projectile.localAI[0] = (value ? 1f : 0f); + } + + // The frame at which the scythe started rebounding. This is used to time out the Perfect Lightspeed Carve window. + internal ref float ReboundStartFrame => ref Projectile.localAI[1]; public override void SetStaticDefaults() { + // Nanoblack Reaper does not spin exactly on the center of its sprite. + DrawOffsetX = -11; + DrawOriginOffsetY = -4; + DrawOriginOffsetX = 0; + ProjectileID.Sets.TrailCacheLength[Type] = 7; ProjectileID.Sets.TrailingMode[Type] = 2; } @@ -32,113 +102,281 @@ namespace CalamityMod.Projectiles.Rogue Projectile.friendly = true; Projectile.ignoreWater = true; Projectile.tileCollide = false; + Projectile.MaxUpdates = UpdatesPerFrame; + Projectile.timeLeft = InternalLifetime; + Projectile.penetrate = -1; - Projectile.extraUpdates = 2; - Projectile.timeLeft = Lifetime; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 8; + Projectile.localNPCHitCooldown = 6 * UpdatesPerFrame; + Projectile.DamageType = RogueDamageClass.Instance; } + public override void SendExtraAI(BinaryWriter writer) => writer.Write(Returning); + public override void ReceiveExtraAI(BinaryReader reader) => Returning = reader.ReadBoolean(); + + // Nanoblack Reaper's AI has been converted into a trenchcoat function due to the needed expansion of the sub-functions. public override void AI() { - DrawOffsetX = -11; - DrawOriginOffsetY = -4; - DrawOriginOffsetX = 0; + if (Projectile.timeLeft == InternalLifetime) + FrameOneEffects(); - // Initialize the frame counter and random blade delay on the very first frame. - if (Projectile.timeLeft == Lifetime) - Projectile.ai[1] = Projectile.Calamity().stealthStrike ? 4f : GetBladeDelay(); + // Nanoblack Reaper enables its owner's mouse listener so that the mouse state is synced. + // This is necessary for its targeting algorithm. + if (Owner.whoAmI == Main.myPlayer) + Owner.Calamity().mouseWorldListener = true; - // Produces electricity and green firework sparks constantly while in flight. - if (Main.rand.NextBool(3)) - { - int dustType = Main.rand.NextBool(5) ? 226 : 220; - float scale = 0.8f + Main.rand.NextFloat(0.3f); - float velocityMult = Main.rand.NextFloat(0.3f, 0.6f); - int idx = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType); - Main.dust[idx].noGravity = true; - Main.dust[idx].velocity = velocityMult * Projectile.velocity; - Main.dust[idx].scale = scale; - } - - // ai[0] is a frame counter. ai[1] is a countdown to spawning the next nanoblack energy blade. - Projectile.ai[0] += 1f; - Projectile.ai[1] -= 1f; + InFlightVisualEffects(); + UpdateAIVariables(); // On the frame the scythe begins returning, send a net update. - if (Projectile.ai[0] == ReboundTime) + if (RealFrameCounter >= BoomerangReturnTime && RealFrameCounter < BoomerangReturnTime + 1f) + { + Returning = true; + ReboundStartFrame = RealFrameCounter; + + // Also on this frame: The window for a Perfect Lightspeed Carve starts. + if (LightspeedCarveState == LightspeedCarveState_Initial) + LightspeedCarveState = LightspeedCarveState_CanPerfect; + Projectile.netUpdate = true; + } // The scythe runs its returning AI if the frame counter is greater than ReboundTime. - if (Projectile.ai[0] >= ReboundTime) + if (Returning) { - float returnSpeed = NanoblackReaper.Speed; - float acceleration = 2.4f; - Player owner = Main.player[Projectile.owner]; - - // Delete the scythe if it's excessively far away. - Vector2 playerCenter = owner.Center; - float xDist = playerCenter.X - Projectile.Center.X; - float yDist = playerCenter.Y - Projectile.Center.Y; - float dist = (float)Math.Sqrt(xDist * xDist + yDist * yDist); - if (dist > 3000f) - Projectile.Kill(); - - dist = returnSpeed / dist; - xDist *= dist; - yDist *= dist; - - // Home back in on the player. - if (Projectile.velocity.X < xDist) + // During this time, make sure the Perfect Lightspeed Carve window expires properly. + if (LightspeedCarveState == LightspeedCarveState_CanPerfect) { - Projectile.velocity.X = Projectile.velocity.X + acceleration; - if (Projectile.velocity.X < 0f && xDist > 0f) - Projectile.velocity.X += acceleration; - } - else if (Projectile.velocity.X > xDist) - { - Projectile.velocity.X = Projectile.velocity.X - acceleration; - if (Projectile.velocity.X > 0f && xDist < 0f) - Projectile.velocity.X -= acceleration; - } - if (Projectile.velocity.Y < yDist) - { - Projectile.velocity.Y = Projectile.velocity.Y + acceleration; - if (Projectile.velocity.Y < 0f && yDist > 0f) - Projectile.velocity.Y += acceleration; - } - else if (Projectile.velocity.Y > yDist) - { - Projectile.velocity.Y = Projectile.velocity.Y - acceleration; - if (Projectile.velocity.Y > 0f && yDist < 0f) - Projectile.velocity.Y -= acceleration; + bool perfectWindowPassed = RealFrameCounter > ReboundStartFrame + NanoblackReaper.PerfectLightspeedCarveFrames; + if (perfectWindowPassed) + LightspeedCarveState = LightspeedCarveState_CanImperfect; } - // Delete the projectile if it touches its owner. - if (Main.myPlayer == Projectile.owner) - if (Projectile.Hitbox.Intersects(owner.Hitbox)) - Projectile.Kill(); + // Also ensure that the Imperfect Lightspeed Carve window expires properly. + else if (LightspeedCarveState == LightspeedCarveState_CanImperfect) + { + bool imperfectWindowPassed = RealFrameCounter > ReboundStartFrame + NanoblackReaper.PerfectLightspeedCarveFrames + NanoblackReaper.ImperfectLightspeedCarveFrames; + if (imperfectWindowPassed) + LightspeedCarveState = LightspeedCarveState_Performed; + } + + BoomerangMovement(); } - // Create nanoblack energy blades at a somewhat-random rate while in flight. (or full-sized scythes afterimages if stealth strike) - if (Projectile.ai[1] <= 0f) + // Spawn Nanoblack Tesselations at a consistent and overwhelming rate while in flight. + // PENDING TESTING: Tesselations are not spawned if a scythe has been pulled for a Lightspeed Carve. + bool spawnTesselations = Projectile.Calamity().stealthStrike || /* LightspeedCarveState != LightspeedCarveState_Performed */ true; + if (spawnTesselations && TesselationSpawnCooldown <= 0f) { - if (Projectile.Calamity().stealthStrike) + SpawnTesselation(); + TesselationSpawnCooldown = InternalTesselationDelay; + } + + RotateScytheInFlight(); + } + + private void FrameOneEffects() + { + // If you set these values, you were a fool. Nanoblack Reaper does not care. + RealFrameCounter = 0f; + TesselationSpawnCooldown = InternalTesselationDelay; + + // Lightspeed Carves are not enabled on Focus Flurry attacks. + LightspeedCarveState = Projectile.Calamity().stealthStrike ? LightspeedCarveState_Performed : LightspeedCarveState_Initial; + } + + // Produces electricity and green firework sparks constantly while in flight. + private void InFlightVisualEffects() + { + if (!Main.rand.NextBool(UpdatesPerFrame)) + return; + + int dustType = Main.rand.NextBool(5) ? ModContent.DustType() : ModContent.DustType(); + + Vector2 position = Main.rand.NextVector2FromRectangle(Projectile.Hitbox); + float scale = Main.rand.NextFloat(0.8f, 1.1f); + float velocityMult = Main.rand.NextFloat(0.3f, 0.6f); + + Dust d = Dust.NewDustPerfect(position, dustType, Vector2.Zero, Scale: scale); + if (d is null || d.dustIndex == Main.maxDust) + return; + + d.color = NanoblackReaper.NanoblackDustColor1; + d.noGravity = true; + d.velocity = velocityMult * Projectile.velocity; + } + + private void UpdateAIVariables() + { + // Only increment the real frame counter once per frame, on the final extra update of that frame. + if (Projectile.FinalExtraUpdate()) + { + ++RealFrameCounter; + } + + // Tesselation spawn cooldown decrements every update so that it may be out of sync with gameplay frames if needed. + --TesselationSpawnCooldown; + } + + private void BoomerangMovement() + { + Player owner = Owner; + Vector2 toOwner = Projectile.SafeDirectionTo(owner.Center, -Vector2.UnitY); + float baseReturnSpeed = NanoblackReaper.Speed; + float currentReturnSpeed = baseReturnSpeed; + + // Nanoblack Reaper's return speed increases sharply if it remains in flight for too long. + float returnSpeedIncreaseTime = BoomerangReturnTime * 2f; + if (RealFrameCounter >= returnSpeedIncreaseTime) + currentReturnSpeed *= 1f + 0.05f * (RealFrameCounter - returnSpeedIncreaseTime); + + // Lerp into the desired velocity every update. + Vector2 desiredVelocity = currentReturnSpeed * toOwner; + float returnSharpness = 0.04f; + Projectile.velocity = Vector2.Lerp(Projectile.velocity, desiredVelocity, returnSharpness); + + // Delete the projectile if it touches its owner. + if (Main.myPlayer == Projectile.owner) + if (Projectile.Hitbox.Intersects(owner.Hitbox)) + Projectile.Kill(); + } + + // Spawns a triangular lattice of three Nanoblack Tesselations. All tesselations emit from the blade of the scythe. + private void SpawnTesselation() + { + int numTessSpawns = 3; + + // Each tesselation spawns with a random delay before it chooses to fire. + // For consistent RNG iteration, these RNG values are obtained even if they are not needed. + static float GetStrikeDelay() => Main.rand.NextFloat(NanoblackTesselation.MinDelay, NanoblackTesselation.MaxDelay); + float[] zeroPointStrikeDelays = new float[numTessSpawns]; + for (int i = 0; i < numTessSpawns; ++i) + zeroPointStrikeDelays[i] = GetStrikeDelay(); + + if (Main.myPlayer != Projectile.owner) + return; + + int tessID = ModContent.ProjectileType(); + int tessDamage = (int)(NanoblackReaper.TesselationDamageRatio * Projectile.damage); + float tessKB = NanoblackReaper.TesselationKnockback; + + // The blade of Nanoblack Reaper is close enough to straight-right +X that using the rotation directly is fine. + float scytheBladeRotation = Projectile.rotation * Projectile.spriteDirection; + Vector2 spawnOffsetDir = scytheBladeRotation.ToRotationVector2(); + Vector2 tessPos = Projectile.Center + spawnOffsetDir * 14f; + Vector2 tessVelDir = spawnOffsetDir.RotatedBy(-MathHelper.PiOver4); // close enough to a blade-egress vector + Vector2 tessBaseVel = tessVelDir * TesselationSpawnSpeed; + + var source = Projectile.GetSource_FromThis(); + + for (int i = 0; i < numTessSpawns; ++i) + { + Vector2 tessVel = tessBaseVel.RotatedBy(i * NanoblackReaper.TwoPiOver3); + float delay = zeroPointStrikeDelays[i]; + int tessIdx = Projectile.NewProjectile(source, tessPos, tessVel, tessID, tessDamage, tessKB, Projectile.owner, ai0: delay); + + // The spin direction and stealth strike status of the scythe transfers to the tesselations. + if (tessIdx.WithinBounds(Main.maxProjectiles)) { - SpawnScytheAfterimage(); - Projectile.ai[1] = 4f; + Projectile tess = Main.projectile[tessIdx]; + tess.direction = tess.spriteDirection = Projectile.spriteDirection; + tess.Calamity().stealthStrike = Projectile.Calamity().stealthStrike; } + } + } + + internal void AttemptLightspeedCarve() + { + var lcs = LightspeedCarveState; + if (lcs == LightspeedCarveState_Performed) + return; + + if (lcs != LightspeedCarveState_Initial && Projectile.owner == Main.myPlayer) + { + int projType = ModContent.ProjectileType(); + int damage = Projectile.damage * 6; + float kb = NanoblackReaper.LightspeedCarveKnockback; + var source = Projectile.GetSource_FromThis(); + + Vector2 pos = Projectile.Center; + + // As is Nanoblack tradition, Lightspeed Carves prefer to target bosses whenever possible. + NPC target = Owner.ClampedMouseWorld().ClosestNPCAt(NanoblackLightspeedCarve.TargetingRange, bossPriority: true); + + // If the first cursor-based targeting attempt fails, try again near the Tesselation itself. + if (target is null || !target.active) + target = Projectile.Center.ClosestNPCAt(NanoblackLightspeedCarve.TargetingRange, bossPriority: true); + + bool foundTarget = target is not null && target.active; + if (foundTarget) + pos = target.Center; else { - SpawnEnergyBlade(); - Projectile.ai[1] = GetBladeDelay(); + SoundStyle missSound = lcs == LightspeedCarveState_CanPerfect ? LightspeedPerfectMissSound : LightspeedMissSound; + SoundEngine.PlaySound(missSound, Projectile.Center); + } + + float fuzz = NanoblackLightspeedCarve.PlacementRandomness; + pos += Main.rand.NextVector2Circular(fuzz, fuzz); + + if (foundTarget) + PlayLightspeedCarveSounds(lcs == LightspeedCarveState_CanPerfect, pos); + + if (lcs == LightspeedCarveState_CanPerfect) + { + Projectile perf = Projectile.NewProjectileDirect(source, pos, Vector2.Zero, projType, damage, kb, Projectile.owner, ai0: 1f); + var cgp = perf.Calamity(); + cgp.supercritHits = -1; + cgp.bonusCritDamage += 1f; + } + else if (lcs == LightspeedCarveState_CanImperfect) + { + Projectile.NewProjectile(source, pos, Vector2.Zero, projType, damage, kb, Projectile.owner, ai0: 0f); } } - // Rotate the scythe as it flies. + // In all cases, all further attempts are blocked permanently. + LightspeedCarveState = LightspeedCarveState_Performed; + Projectile.netUpdate = true; + } + + private static void PlayLightspeedCarveSounds(bool perfect, Vector2 position) + { + if (perfect) + SoundEngine.PlaySound(LightspeedPerfectSlashSound, position); + else + { + SoundEngine.PlaySound(LightspeedSlashVariantSound, position); + } + } + + private void RotateScytheInFlight() + { float spin = Projectile.direction <= 0 ? -1f : 1f; Projectile.rotation += spin * RotationIncrement; + + // When thrown left, Nanoblack Reaper is still thrown scythe-head first. + Projectile.spriteDirection = Projectile.direction; + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + // No gameplay effects; just spawns slash impact particles at a slightly random angle. + Color color = NanoblackReaper.NanoblackSlashColor1; + float scale = 0.12f; + Vector2 slashDir = -Projectile.velocity.SafeNormalize(-Vector2.UnitY); + Vector2 vel = 0.01f * slashDir.RotatedByRandom(MathHelper.Pi / 8f); + + // scale of void sparks is arbitrarily multiplied by 0.357f. thanks! + float voidScale = scale / 0.357f; + Particle blackSpark = new VoidSparkParticle(Projectile.Center, vel, false, 12, voidScale, color, 1f); + GeneralParticleHandler.SpawnParticle(blackSpark); + + float glowScale = scale * 0.333f; + Vector2 squashStretch = new(1.3333f, 0.8f); + Particle innerSpark = new GlowSparkParticle(Projectile.Center, vel, false, 11, glowScale, color, squashStretch, true, true, 1f); + GeneralParticleHandler.SpawnParticle(innerSpark); } public override bool PreDraw(ref Color lightColor) @@ -146,35 +384,5 @@ namespace CalamityMod.Projectiles.Rogue CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); return false; } - - private int GetBladeDelay() - { - return Main.rand.Next(MinBladeTimer, MaxBladeTimer + 1); - } - - private void SpawnEnergyBlade() - { - int bladeID = ModContent.ProjectileType(); - int bladeDamage = Projectile.damage / 3; - float bladeKB = 3f; - float spin = Projectile.direction <= 0 ? -1f : 1f; - float d = 16f; - float velocityMult = 0.9f; - Vector2 directOffset = new Vector2(Main.rand.NextFloat(-d, d), Main.rand.NextFloat(-d, d)); - Vector2 velocityOffset = Main.rand.NextFloat(-velocityMult, velocityMult) * Projectile.velocity; - Vector2 pos = Projectile.Center + directOffset + velocityOffset; - if (Projectile.owner == Main.myPlayer) - Projectile.NewProjectile(Projectile.GetSource_FromThis(), pos, Vector2.Zero, bladeID, bladeDamage, bladeKB, Projectile.owner, 0f, spin); - } - - private void SpawnScytheAfterimage() - { - int bladeID = ModContent.ProjectileType(); - int bladeDamage = Projectile.damage / 2; - float bladeKB = 4f; - float spin = Projectile.direction <= 0 ? -1f : 1f; - if (Projectile.owner == Main.myPlayer) - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, bladeID, bladeDamage, bladeKB, Projectile.owner, 0f, spin); - } } } diff --git a/Projectiles/Rogue/NanoblackPiercingStrike.cs b/Projectiles/Rogue/NanoblackPiercingStrike.cs new file mode 100644 index 0000000000..067e9c9323 --- /dev/null +++ b/Projectiles/Rogue/NanoblackPiercingStrike.cs @@ -0,0 +1,163 @@ +using System; +using System.IO; +using CalamityMod.Items.Weapons.Rogue; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.GameContent.Shaders; +using Terraria.Graphics.Effects; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Rogue +{ + // Adopts a lot of code from Last Prism (aka Yharim's Crystal) for beam calculations, + // but delivers damage completely differently. + public class NanoblackPiercingStrike : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Rogue"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + internal const float MaxBeamLength = 1800f; + private const float BeamTileCollisionWidth = 1f; + private const float BeamHitboxCollisionWidth = 40; + // Sample points is much higher due to this beam only being cast once instead of every frame. + private const int NumSamplePoints = 9; + // no BeamLengthChangeFactor due to this beam never moving; it only gets cast once + + private const float BeamLightBrightness = 0.5f; + + internal Vector2 TargetPos => new(Projectile.ai[1], Projectile.ai[2]); + internal ref float VisibleBeamLength => ref Projectile.localAI[0]; + + // 0f = Beam not calculated yet + // 1f = Beam calculated but no damage has been done + // 2f = This projectile has had at least 1 frame of active hitbox and has hit N enemies, it no longer does damage + internal ref float ProgressiveState => ref Projectile.localAI[1]; + internal const float ProgressiveState_Initial = 0f; + internal const float ProgressiveState_BeamCalculated = 1f; + internal const float ProgressiveState_HasDealtDamage = 2f; + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 36; + Projectile.friendly = true; + Projectile.DamageType = RogueDamageClass.Instance; + Projectile.penetrate = 1; + Projectile.extraUpdates = 0; + // Completely ignores tiles and is not stopped by them, unlike Last Prism. + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + Projectile.alpha = 255; + Projectile.timeLeft = 6; + } + + public override void SendExtraAI(BinaryWriter writer) => writer.Write(VisibleBeamLength); + public override void ReceiveExtraAI(BinaryReader reader) => VisibleBeamLength = reader.ReadSingle(); + + public override void AI() + { + if (Projectile.numHits > 0) + ProgressiveState = ProgressiveState_HasDealtDamage; + + // This projectile does not move and its velocity is always zero. + // Destination X/Y is stored in AI variables and is computed into a faux velocity. + Vector2 fakeVel = (TargetPos - Projectile.Center).SafeNormalize(-Vector2.UnitY); + + // Supercharged Nanoblack Strikes ignore tiles but still perform a Last Prism laser scan to disturb water and cut tiles. + if (ProgressiveState == ProgressiveState_Initial) + { + Vector2 samplingPoint = Projectile.Center; + float[] laserScanResults = new float[NumSamplePoints]; + Collision.LaserScan(samplingPoint, fakeVel, BeamTileCollisionWidth, MaxBeamLength, laserScanResults); + + float averageSampledLength = 0f; + for (int i = 0; i < laserScanResults.Length; ++i) + averageSampledLength += laserScanResults[i]; + averageSampledLength /= NumSamplePoints; + // There is no lerping of visible beam length because the beam is only sampled once. + VisibleBeamLength = averageSampledLength; + + float distToTarget = Projectile.Center.Distance(TargetPos); + float minOvershoot = 224f; + float maxOvershoot = 320f; + + // If the beam is too short (it got stuck in a wall), force it to be an appropriate length. This item ignores walls. + // Similarly, if the beam is far too long, clip it down so it doesn't go ridiculously far past its target. + if (VisibleBeamLength < distToTarget || VisibleBeamLength > distToTarget + maxOvershoot) + { + float randomOvershoot = Main.rand.NextFloat(minOvershoot, maxOvershoot); + VisibleBeamLength = distToTarget + randomOvershoot; + } + + ProgressiveState = ProgressiveState_BeamCalculated; + } + + // X = beam length. Y = beam width. + Vector2 beamDims = new(VisibleBeamLength, Projectile.width * Projectile.scale); + + // Cause visual effects based on computed data + PiercingStrikeEffects(); + + // If the game is rendering (i.e. isn't a dedicated server), make the beam disturb water. + if (Main.netMode != NetmodeID.Server) + { + WaterShaderData wsd = (WaterShaderData)Filters.Scene["WaterDistortion"].GetShader(); + // A universal time-based sinusoid which updates extremely rapidly. GlobalTimeWrappedHourly is 0 to 3600, measured in seconds. + float waveSine = 0.1f * (float)Math.Sin(Main.GlobalTimeWrappedHourly * 20f); + Vector2 ripplePos = Projectile.position + new Vector2(beamDims.X * 0.5f, 0f).RotatedBy(Projectile.rotation); + // WaveData is encoded as a Color. Not sure why, considering Vector3 exists. + Color waveData = new Color(0.5f, 0.1f * Math.Sign(waveSine) + 0.5f, 0f, 1f) * Math.Abs(waveSine); + wsd.QueueRipple(ripplePos, waveData, beamDims, RippleShape.Square, Projectile.rotation); + } + + // Make the beam cast light along its length. + // v3_1 is an unnamed decompiled variable which is the color of the light cast by DelegateMethods.CastLight + Vector2 lightDest = Projectile.Center + fakeVel * VisibleBeamLength; + DelegateMethods.v3_1 = NanoblackReaper.PiercingStrikeColor.ToVector3() * BeamLightBrightness; + Utils.PlotTileLine(Projectile.Center, lightDest, beamDims.Y, DelegateMethods.CastLight); + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + // If the target is touching the beam's hitbox (which is a small rectangle vaguely overlapping the host crystal), that's good enough. + if (projHitbox.Intersects(targetHitbox)) + return true; + + // Otherwise, perform an AABB line collision check to check the whole beam. + float _ = float.NaN; + Vector2 fakeVel = (TargetPos - Projectile.Center).SafeNormalize(-Vector2.UnitY); + Vector2 endPoint = Projectile.Center + fakeVel * VisibleBeamLength; + return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), Projectile.Center, endPoint, BeamHitboxCollisionWidth * Projectile.scale, ref _); + } + + public override bool? CanHitNPC(NPC target) => ProgressiveState == ProgressiveState_HasDealtDamage ? false : null; + + // This projectile does not die upon landing a hit so that it may persist for visual reasons. + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => Projectile.penetrate++; + + private void PiercingStrikeEffects() + { + Vector2 fakeVel = (TargetPos - Projectile.Center).SafeNormalize(-Vector2.UnitY); + Vector2 endPoint = Projectile.Center + fakeVel * VisibleBeamLength; + + // 0 to 5 + int iter = 5 - Projectile.timeLeft; + + float startLerp = iter * 0.15f; + float endLerp = 0.6f + iter * 0.15f; + Vector2 segmentStart = Vector2.Lerp(Projectile.Center, endPoint, startLerp); + Vector2 segmentEnd = Vector2.Lerp(Projectile.Center, endPoint, endLerp); + float particleSpeed = Main.rand.NextFloat(34f, 40f); + Vector2 particleVel = fakeVel.RotatedByRandom(MathHelper.Pi / 30f) * particleSpeed; + + int lifetime = 5; + float xScale = 0.017f; + float xShrink = 0.66f; + + Particle carveParticle = new StaticGlowLine(segmentStart, segmentEnd, particleVel, lifetime, xScale, xShrink, NanoblackReaper.PiercingStrikeColor, true); + GeneralParticleHandler.SpawnParticle(carveParticle); + } + } +} diff --git a/Projectiles/Rogue/NanoblackSplit.cs b/Projectiles/Rogue/NanoblackSplit.cs deleted file mode 100644 index b311e37066..0000000000 --- a/Projectiles/Rogue/NanoblackSplit.cs +++ /dev/null @@ -1,213 +0,0 @@ -using System; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Rogue -{ - public class NanoblackSplit : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Rogue"; - private static int SpriteWidth = 52; - private static int Lifetime = 90; - private static float MaxRotationSpeed = 0.25f; - private static float MaxSpeed = 22f; - - private static float HomingStartRange = 600f; - private static float HomingBreakRange = 1000f; - private static float HomingBonusRangeCap = 200f; - private static float BaseHomingFactor = 1.6f; - private static float MaxHomingFactor = 6.6f; - - public override void SetStaticDefaults() - { - ProjectileID.Sets.CultistIsResistantTo[Type] = true; - ProjectileID.Sets.TrailCacheLength[Type] = 3; - ProjectileID.Sets.TrailingMode[Type] = 0; - } - - public override void SetDefaults() - { - Projectile.width = 32; - Projectile.height = 32; - Projectile.friendly = true; - Projectile.ignoreWater = true; - Projectile.tileCollide = false; - Projectile.penetrate = 4; - Projectile.extraUpdates = 1; - Projectile.timeLeft = Lifetime; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 8; - Projectile.DamageType = RogueDamageClass.Instance; - } - - // ai[0] = Index of current NPC target. If 0 or negative, the projectile has no target - // ai[1] = Current spin speed. Negative speeds are also allowed. - public override void AI() - { - DrawOffsetX = -10; - DrawOriginOffsetY = 0; - DrawOriginOffsetX = 0; - - // On the very first frame, clear any invalid starting target variable and create some dust. - // Also grab the damage type based on ai[0]. - if (Projectile.timeLeft == Lifetime) - SpawnDust(); - - // Spin in the specified starting direction and slow down spin over time - // Loses 1.66% of current speed every frame - // Also update current orientation to reflect current spin direction - float currentSpin = Projectile.ai[1]; - Projectile.direction = currentSpin <= 0f ? 1 : -1; - Projectile.spriteDirection = Projectile.direction; - Projectile.rotation += currentSpin * MaxRotationSpeed; - float spinReduction = 0.0166f * currentSpin; - Projectile.ai[1] -= spinReduction; - - // If about to disappear, shrink by 8% every frame - if (Projectile.timeLeft < 15) - Projectile.scale *= 0.92f; - - // Search for and home in on nearby targets - HomingAI(); - } - - private void HomingAI() - { - // If we don't currently have a target, go try and get one! - int targetID = (int)Projectile.ai[0] - 1; - if (targetID < 0) - targetID = AcquireTarget(); - - // Save the target, whether we have one or not. - Projectile.ai[0] = targetID + 1f; - - // If we don't have a target, then just slow down a bit. - if (targetID < 0) - { - Projectile.velocity *= 0.94f; - return; - } - - // Homing behavior depends on how far the blade is from its target. - NPC target = Main.npc[targetID]; - float xDist = Projectile.Center.X - target.Center.X; - float yDist = Projectile.Center.Y - target.Center.Y; - float dist = (float)Math.Sqrt(xDist * xDist + yDist * yDist); - - // If the target is too far away, stop homing in on it. - if (dist > HomingBreakRange) - { - Projectile.ai[0] = 0f; - return; - } - - // Adds a multiple of the towards-target vector to its velocity every frame. - float homingFactor = CalcHomingFactor(dist); - Vector2 posDiff = target.Center - Projectile.Center; - posDiff = posDiff.SafeNormalize(Vector2.Zero); - posDiff *= homingFactor; - Vector2 newVelocity = Projectile.velocity += posDiff; - - // Caps speed to make sure it doesn't go too fast. - if (newVelocity.Length() >= MaxSpeed) - { - newVelocity = newVelocity.SafeNormalize(Vector2.Zero); - newVelocity *= MaxSpeed; - } - - Projectile.velocity = newVelocity; - } - - // Returns the ID of the NPC to be targeted by this energy blade. - // It chooses the closest target which can be chased, ignoring invulnerable NPCs. - // Nanoblack Blades prefer to target bosses whenever possible. - private int AcquireTarget() - { - bool bossFound = false; - int target = -1; - float minDist = HomingStartRange; - foreach (NPC npc in Main.ActiveNPCs) - { - if (npc.type == NPCID.TargetDummy) - continue; - - // If we've found a valid boss target, ignore ALL targets which aren't bosses. - if (bossFound && !npc.boss) - continue; - - if (npc.CanBeChasedBy(Projectile, false)) - { - float xDist = Projectile.Center.X - npc.Center.X; - float yDist = Projectile.Center.Y - npc.Center.Y; - float distToNPC = (float)Math.Sqrt(xDist * xDist + yDist * yDist); - if (distToNPC < minDist) - { - // If this target within range is a boss, set the boss found flag. - if (npc.boss) - bossFound = true; - minDist = distToNPC; - target = npc.whoAmI; - } - } - } - return target; - } - - // Energy blades home even more aggressively if they are very close to their target. - private float CalcHomingFactor(float dist) - { - float baseFactor = BaseHomingFactor; - float bonus = (MaxHomingFactor - BaseHomingFactor) * (1f - dist / HomingBonusRangeCap); - if (bonus < 0f) - bonus = 0f; - return baseFactor + bonus; - } - - public override bool PreDraw(ref Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); - return false; - } - - // Draws the energy blade's glowmask. - public override void PostDraw(Color lightColor) - { - float fWidthOverTwo = SpriteWidth / 2f; - float fHeightOverTwo = Projectile.height / 2f; - - // Make sure the glowmask matches the blade's own orientation - SpriteEffects eff = SpriteEffects.None; - if (Projectile.spriteDirection == -1) - eff = SpriteEffects.FlipHorizontally; - Vector2 origin = new Vector2(fWidthOverTwo, fHeightOverTwo); - Main.EntitySpriteDraw(ModContent.Request("CalamityMod/Projectiles/Rogue/NanoblackSplitGlow").Value, - Projectile.Center - Main.screenPosition, null, Color.White, Projectile.rotation, - origin, Projectile.scale, eff, 0); - } - - // Spawns a tiny bit of dust when the energy blade vanishes. - public override void OnKill(int timeLeft) - { - SpawnDust(); - } - - // Spawns a small bit of Luminite themed dust. - private void SpawnDust() - { - int dustCount = Main.rand.Next(3, 6); - Vector2 corner = Projectile.position; - for (int i = 0; i < dustCount; ++i) - { - int dustType = 229; - float scale = 0.6f + Main.rand.NextFloat(0.4f); - int idx = Dust.NewDust(corner, Projectile.width, Projectile.height, dustType); - Main.dust[idx].noGravity = true; - Main.dust[idx].velocity *= 3f; - Main.dust[idx].scale = scale; - } - } - } -} diff --git a/Projectiles/Rogue/NanoblackStealthSplit.cs b/Projectiles/Rogue/NanoblackStealthSplit.cs deleted file mode 100644 index eaaef636bf..0000000000 --- a/Projectiles/Rogue/NanoblackStealthSplit.cs +++ /dev/null @@ -1,206 +0,0 @@ -using System; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Rogue -{ - public class NanoblackStealthSplit : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Rogue"; - public override string Texture => "CalamityMod/Items/Weapons/Rogue/NanoblackReaper"; - - private static int Lifetime = 300; - private static float MaxSpeed = 40f; - private static float MaxRotationSpeed = 0.25f; - - private static float HomingStartRange = 4000f; - private static float HomingBreakRange = 6000f; - private static float HomingBonusRangeCap = 2000f; - private static float BaseHomingFactor = 2.6f; - private static float MaxHomingFactor = 8.6f; - - public override void SetStaticDefaults() - { - ProjectileID.Sets.CultistIsResistantTo[Type] = true; - ProjectileID.Sets.TrailCacheLength[Type] = 7; - ProjectileID.Sets.TrailingMode[Type] = 2; - } - - public override void SetDefaults() - { - Projectile.width = 56; - Projectile.height = 56; - Projectile.friendly = true; - Projectile.ignoreWater = true; - Projectile.tileCollide = false; - Projectile.penetrate = 12; - Projectile.extraUpdates = 1; - Projectile.timeLeft = Lifetime; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 8; - Projectile.DamageType = RogueDamageClass.Instance; - } - - // ai[0] = Index of current NPC target. If 0 or negative, the projectile has no target - // ai[1] = Current spin speed. When it reaches 0, starts homing into enemies. Negative speeds are also allowed. - public override void AI() - { - - // Produces electricity and green firework sparks constantly while in flight. (Like the main projectile) - if (Main.rand.NextBool(3)) - { - int dustType = Main.rand.NextBool(5) ? 226 : 220; - float scale = 0.8f + Main.rand.NextFloat(0.3f); - float velocityMult = Main.rand.NextFloat(0.3f, 0.6f); - int idx = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, dustType); - Main.dust[idx].noGravity = true; - Main.dust[idx].velocity = velocityMult * Projectile.velocity; - Main.dust[idx].scale = scale; - } - - // Spin in the specified starting direction and slow down spin over time - // Loses 1.66% of current speed every frame - // Also update current orientation to reflect current spin direction - if (Projectile.timeLeft > 200) - { - float currentSpin = Projectile.ai[1]; - Projectile.direction = currentSpin <= 0f ? -1 : 1; - Projectile.spriteDirection = Projectile.direction; - Projectile.rotation += currentSpin * MaxRotationSpeed; - float spinReduction = 0.0166f * currentSpin; - Projectile.ai[1] -= spinReduction; - } - // Search for and home in on nearby targets after the given time, and stops spinning - else - { - Projectile.rotation = 0f; - HomingAI(); - } - } - - private void HomingAI() - { - // If we don't currently have a target, go try and get one! - int targetID = (int)Projectile.ai[0] - 1; - if (targetID < 0) - targetID = AcquireTarget(); - - // Save the target, whether we have one or not. - Projectile.ai[0] = targetID + 1f; - - // If we don't have a target, then just slow down a bit. - if (targetID < 0) - { - Projectile.velocity *= 0.94f; - return; - } - - // Homing behavior depends on how far the blade is from its target. - NPC target = Main.npc[targetID]; - float xDist = Projectile.Center.X - target.Center.X; - float yDist = Projectile.Center.Y - target.Center.Y; - float dist = (float)Math.Sqrt(xDist * xDist + yDist * yDist); - - // If the target is too far away, stop homing in on it. - if (dist > HomingBreakRange) - { - Projectile.ai[0] = 0f; - return; - } - - // Adds a multiple of the towards-target vector to its velocity every frame. - float homingFactor = CalcHomingFactor(dist); - Vector2 posDiff = target.Center - Projectile.Center; - posDiff = posDiff.SafeNormalize(Vector2.Zero); - posDiff *= homingFactor; - Vector2 newVelocity = Projectile.velocity += posDiff; - - // Caps speed to make sure it doesn't go too fast. - if (newVelocity.Length() >= MaxSpeed) - { - newVelocity = newVelocity.SafeNormalize(Vector2.Zero); - newVelocity *= MaxSpeed; - } - - Projectile.velocity = newVelocity; - - //The afterimage's blade always tries to face its target - Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.ToRadians(45f); - } - - // Returns the ID of the NPC to be targeted by this energy blade. - // It chooses the closest target which can be chased, ignoring invulnerable NPCs. - // Nanoblack Afterimages prefer to target bosses whenever possible. - private int AcquireTarget() - { - bool bossFound = false; - int target = -1; - float minDist = HomingStartRange; - foreach (NPC npc in Main.ActiveNPCs) - { - if (npc.type == NPCID.TargetDummy) - continue; - - // If we've found a valid boss target, ignore ALL targets which aren't bosses. - if (bossFound && !npc.boss) - continue; - - if (npc.CanBeChasedBy(Projectile, false)) - { - float xDist = Projectile.Center.X - npc.Center.X; - float yDist = Projectile.Center.Y - npc.Center.Y; - float distToNPC = (float)Math.Sqrt(xDist * xDist + yDist * yDist); - if (distToNPC < minDist) - { - // If this target within range is a boss, set the boss found flag. - if (npc.boss) - bossFound = true; - minDist = distToNPC; - target = npc.whoAmI; - } - } - } - return target; - } - - // Afterimages home even more aggressively if they are very close to their target. - private float CalcHomingFactor(float dist) - { - float baseFactor = BaseHomingFactor; - float bonus = (MaxHomingFactor - BaseHomingFactor) * (1f - dist / HomingBonusRangeCap); - if (bonus < 0f) - bonus = 0f; - return baseFactor + bonus; - } - - public override bool PreDraw(ref Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); - return false; - } - - // Spawns a tiny bit of dust when the afterimage vanishes. - public override void OnKill(int timeLeft) - { - SpawnDust(); - } - - // Spawns a small bit of Luminite themed dust. - private void SpawnDust() - { - int dustCount = Main.rand.Next(3, 6); - Vector2 corner = Projectile.position; - for (int i = 0; i < dustCount; ++i) - { - int dustType = 229; - float scale = 0.6f + Main.rand.NextFloat(0.4f); - int idx = Dust.NewDust(corner, Projectile.width, Projectile.height, dustType); - Main.dust[idx].noGravity = true; - Main.dust[idx].velocity *= 3f; - Main.dust[idx].scale = scale; - } - } - } -} diff --git a/Projectiles/Rogue/NanoblackStrike.cs b/Projectiles/Rogue/NanoblackStrike.cs new file mode 100644 index 0000000000..5cf266a84e --- /dev/null +++ b/Projectiles/Rogue/NanoblackStrike.cs @@ -0,0 +1,65 @@ +using CalamityMod.Items.Weapons.Rogue; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Rogue +{ + // 18NOV2024: Ozzatron: Nanoblack zero-point energy strikes are very similar to Direct Strikes, but aren't a subclass. + // This is because they maintain a consistent offset and have visuals instead of having customized knockback. + public class NanoblackStrike : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Rogue"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + internal bool InvalidTarget => !((int)Projectile.ai[0]).WithinBounds(Main.maxNPCs); + internal ref float visualXOffset => ref Projectile.ai[1]; + internal ref float visualYOffset => ref Projectile.ai[2]; + + public override void SetDefaults() + { + Projectile.width = 2; + Projectile.height = 2; + Projectile.friendly = true; + Projectile.DamageType = RogueDamageClass.Instance; + Projectile.penetrate = 1; + Projectile.extraUpdates = 0; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + Projectile.alpha = 255; + Projectile.timeLeft = 2; + } + + // On-spawn, the strikes are Rogue class for damage inheritance reasons. + // Once they exist, they immediately swap to classless, as they are intentionally similar to Direct Strikes and shouldn't proc effects. + public override bool PreAI() + { + Projectile.DamageType = DamageClass.Generic; + return true; + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => ProduceImpactParticles(target); + public override void OnHitPlayer(Player target, Player.HurtInfo info) => ProduceImpactParticles(target); + + private void ProduceImpactParticles(Entity target) + { + Vector2 visualsPos = Projectile.Center + new Vector2(Projectile.ai[1], Projectile.ai[2]); + float sparkSpeed = 2f; + // Spark particles invert depending on the scythe's flight direction at the moment their parent tesselations were created. + float baseRot = Projectile.spriteDirection * MathHelper.PiOver2; + float scale = 0.014f; + Color color = NanoblackReaper.ZeroPointImpactColor; + + // Spawn a triangle of three sparks. + for (int i = 0; i < 3; ++i) + { + float rot = baseRot + i * NanoblackReaper.TwoPiOver3; + Vector2 sparkVel = sparkSpeed * rot.ToRotationVector2(); + Vector2 squashStretch = new(1f, 0.3f); + Particle spark = new GlowSparkParticle(visualsPos, sparkVel, false, 11, scale, color, squashStretch, true, false, 1.25f); + GeneralParticleHandler.SpawnParticle(spark); + } + } + } +} diff --git a/Projectiles/Rogue/NanoblackTesselation.cs b/Projectiles/Rogue/NanoblackTesselation.cs new file mode 100644 index 0000000000..5b406141aa --- /dev/null +++ b/Projectiles/Rogue/NanoblackTesselation.cs @@ -0,0 +1,267 @@ +using CalamityMod.Items.Weapons.Rogue; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Rogue +{ + public class NanoblackTesselation : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Rogue"; + internal static Asset Glow; + + // As Nanoblack Tesselations are not square, this is required for the glowmask to be rendered properly. + private const int SpriteWidth = 52; + + private const int Lifetime = 60; + private const int VanishTime = 12; + internal const int MinDelay = 15; + internal const int MaxDelay = 45; + + private const float TargetingRange = 600f; + private const float FiringRange = 2000f; + + // Rotation speed is inherited directly from the scythe. + private const float StartingRotationIncrement = NanoblackMain.RotationIncrement * NanoblackMain.UpdatesPerFrame; + private const float DriftSpeed = 0.8f; + + private Player Owner => Main.player[Projectile.owner]; + internal ref float AttackDelay => ref Projectile.ai[0]; + internal ref float CurrentSpin => ref Projectile.ai[1]; + private bool IsVanishing => Projectile.timeLeft < VanishTime; + + public override void Load() => Glow = ModContent.Request(Texture + "Glow"); + + public override void SetStaticDefaults() + { + // Nanoblack Tesselations are not perfectly square and need assistance to spin properly. + DrawOffsetX = -10; + DrawOriginOffsetY = 0; + DrawOriginOffsetX = 0; + } + + public override void SetDefaults() + { + Projectile.width = 32; + Projectile.height = 32; + Projectile.scale = 0.5f; + Projectile.friendly = true; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + Projectile.penetrate = -1; + Projectile.timeLeft = Lifetime; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 8; + Projectile.DamageType = RogueDamageClass.Instance; + } + + public override void AI() + { + if (Projectile.timeLeft == Lifetime) + FrameOneEffects(); + + // Tesselations enable their owner's mouse listener so that the mouse state is synced. + // This is necessary for their targeting algorithm. + if (Owner.whoAmI == Main.myPlayer) + Owner.Calamity().mouseWorldListener = true; + + // If the Tesselation cannot attack, then it immediately transitions to vanishing. + bool shouldShutdown = false; + if (!IsVanishing) + shouldShutdown = AttemptAttackThisFrame(); + + if (shouldShutdown) + { + Projectile.timeLeft = VanishTime - 1; + + // Spawn a particle when the Tesselation begins vanishing to make it look like it blinks out of existence. + float orbScale = 1.5f; + Color orbColor = NanoblackReaper.TesselationParticleColor; + Particle vanishOrb = new GlowOrbParticle(Projectile.Center, Projectile.velocity, false, 15, orbScale, orbColor); + GeneralParticleHandler.SpawnParticle(vanishOrb); + } + + ProcessSpin(); + + // Tesselations always screech to a near-halt during spindown, but drift gently afterwards to form a mesmerizing pattern. + if (!IsVanishing && Projectile.velocity.LengthSquared() > DriftSpeed * DriftSpeed) + Projectile.velocity *= 0.75f; + + // If the tesselation is vanishing, shrink by 12% every frame + if (IsVanishing) + Projectile.scale *= 0.88f; + } + + private void FrameOneEffects() + { + // Sanity check the firing delay. + if (AttackDelay < MinDelay) + AttackDelay = MinDelay; + else if (AttackDelay > MaxDelay) + AttackDelay = MaxDelay; + + CurrentSpin = StartingRotationIncrement; + + // Create particles to visually flavor the spawning of the projectile. + { + float sparkSpeed = 2f; + float baseRot = MathHelper.PiOver2; + float scale = 0.018f; + int lifetime = 15; + Color color = NanoblackReaper.TesselationParticleColor; + Vector2 squashStretch = new(1f, 0.3f); + + for (int i = 0; i < 6; ++i) + { + float rot = baseRot + i * NanoblackReaper.PiOver3; + Vector2 sparkVel = sparkSpeed * rot.ToRotationVector2(); + Particle spark = new GlowSparkParticle(Projectile.Center, sparkVel, false, lifetime, scale, color, squashStretch, true, true, 1f); + GeneralParticleHandler.SpawnParticle(spark); + } + } + } + + private void ProcessSpin() + { + // Visually spins the tesselation. + float rotationIncrement = CurrentSpin * Projectile.spriteDirection; + Projectile.rotation += rotationIncrement; + + // Spin slows down exponentially over time. + CurrentSpin *= 0.93f; + } + + // Returns whether or not the Tesselation should shut down. + private bool AttemptAttackThisFrame() + { + // If the attack isn't ready yet, don't perform it. + if (AttackDelay > 0f) + { + --AttackDelay; + return false; + } + + // As is Nanoblack tradition, Tesselations prefer to target bosses whenever possible. + bool inFiringRange = false; + NPC target = Owner.ClampedMouseWorld().ClosestNPCAt(TargetingRange, bossPriority: true); + + // If the first cursor-based targeting attempt fails, try again near the Tesselation itself. + if (target is null || !target.active) + target = Projectile.Center.ClosestNPCAt(TargetingRange, bossPriority: true); + + // Check firing range. Tesselations can fire across a whole 1080p screen, but it's not infinite distance. + if (target is not null && target.active) + inFiringRange = target.DistanceSQ(Projectile.Center) < FiringRange * FiringRange; + if (!inFiringRange) + return true; + + // At this point, the targeting is confirmed. Attack. + PerformAttack(target); + return true; + } + + private void PerformAttack(NPC target) + { + // Exact visual offset of the zero-point energy strike is randomly chosen. + // For consistent RNG across clients, this randomness is executed even if the result is not used. + float xInterp = Main.rand.NextFloat(); + float yInterp = Main.rand.NextFloat(); + + if (Main.myPlayer != Projectile.owner) + return; + + // The "dartboard" is the majority, but not all, of the NPC's hitbox. + Vector2 c = target.Center; + float dartboardScale = 0.4f; // 0.5f would be the entire hitbox of the NPC + Vector2 topLeft = c - dartboardScale * target.Size; + Vector2 bottomRight = c + dartboardScale * target.Size; + float dartboardX = MathHelper.Lerp(topLeft.X, bottomRight.X, xInterp); + float dartboardY = MathHelper.Lerp(topLeft.Y, bottomRight.Y, yInterp); + Vector2 strikeDest = new(dartboardX, dartboardY); + Vector2 offset = strikeDest - c; + + bool stealthStrikeAttack = Projectile.Calamity().stealthStrike; + + // Stealth strike attack: Lightspeed carve + if (stealthStrikeAttack) + { + int carveID = ModContent.ProjectileType(); + int carveDamage = Projectile.damage; // same damage ratio as the tesselation itself + float carveKB = 0f; + + // Carves are spawned with a target X/Y coordinate stored in ai[1] and ai[2]. + // They can and will strike anything on the line indiscriminately. + var source = Projectile.GetSource_FromThis(); + int carveIdx = Projectile.NewProjectile(source, Projectile.Center, Vector2.Zero, carveID, carveDamage, carveKB, Projectile.owner, ai1: dartboardX, ai2: dartboardY); + if (carveIdx.WithinBounds(Main.maxProjectiles)) + { + Projectile carve = Main.projectile[carveIdx]; + carve.ArmorPenetration += NanoblackReaper.LightspeedCarveArmorPenetration; // Add excessive armor penetration. + } + + // There is no need to add visuals to the stealth strike. The carves are flashy enough. + } + + // Standard attack: Hitscan zero-point energy strike + else + { + int zpeID = ModContent.ProjectileType(); + int zpeDamage = Projectile.damage; // same damage ratio as the tesselation itself + float zpeKB = 0f; + + var source = Projectile.GetSource_FromThis(); + int zpeIdx = Projectile.NewProjectile(source, strikeDest, Vector2.Zero, zpeID, zpeDamage, zpeKB, Projectile.owner, ai0: target.whoAmI, ai1: offset.X, ai2: offset.Y); + if (zpeIdx.WithinBounds(Main.maxProjectiles)) + { + Projectile zpe = Main.projectile[zpeIdx]; + zpe.ArmorPenetration += NanoblackReaper.ZeroPointArmorPenetration; // Add excessive armor penetration. + + // This consistently orients the visuals of the hitscan attack for flair. + zpe.direction = zpe.spriteDirection = Projectile.spriteDirection; + } + + // Draw a bright line of energy between the Tesselation and the spawned strike. + Vector2 lineVel = 3f * Projectile.velocity; + float xScale = 0.009f; + float xShrink = 0.88f; + Color lineColor = NanoblackReaper.ZeroPointLineColor; + Particle energyLine = new StaticGlowLine(Projectile.Center, strikeDest, lineVel, 7, xScale, xShrink, lineColor, true); + GeneralParticleHandler.SpawnParticle(energyLine); + + // Draw a stack of three glow orbs right at the start of the line. One glow orb was not glowy enough. + int numOrbs = 3; + float orbScale = 1.5f; + Vector2 orbVel = lineVel; + for (int i = 0; i < numOrbs; ++i) + { + Particle energyOrb = new GlowOrbParticle(Projectile.Center, orbVel, false, 15, orbScale, lineColor); + GeneralParticleHandler.SpawnParticle(energyOrb); + } + } + } + + public override bool PreDraw(ref Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); + return false; + } + + // Draws the tesselation's glowmask. + public override void PostDraw(Color lightColor) + { + float fWidthOverTwo = SpriteWidth / 2f; + float fHeightOverTwo = Projectile.height / 2f; + + // Make sure the glowmask matches the tesselation's own orientation + SpriteEffects eff = SpriteEffects.None; + if (Projectile.spriteDirection == -1) + eff = SpriteEffects.FlipHorizontally; + Vector2 origin = new Vector2(fWidthOverTwo, fHeightOverTwo); + Main.EntitySpriteDraw(Glow.Value, Projectile.Center - Main.screenPosition, null, Color.White, Projectile.rotation, origin, Projectile.scale, eff, 0); + } + } +} diff --git a/Projectiles/Rogue/NanoblackSplit.png b/Projectiles/Rogue/NanoblackTesselation.png similarity index 100% rename from Projectiles/Rogue/NanoblackSplit.png rename to Projectiles/Rogue/NanoblackTesselation.png diff --git a/Projectiles/Rogue/NanoblackSplitGlow.png b/Projectiles/Rogue/NanoblackTesselationGlow.png similarity index 100% rename from Projectiles/Rogue/NanoblackSplitGlow.png rename to Projectiles/Rogue/NanoblackTesselationGlow.png diff --git a/Projectiles/Rogue/PlaguenadeProj.cs b/Projectiles/Rogue/PlaguenadeProj.cs index 7e1a120629..8dd4b9c786 100644 --- a/Projectiles/Rogue/PlaguenadeProj.cs +++ b/Projectiles/Rogue/PlaguenadeProj.cs @@ -73,6 +73,8 @@ namespace CalamityMod.Projectiles.Rogue { Player player = Main.player[Projectile.owner]; int projAmt = Projectile.Calamity().stealthStrike ? 28 : 20; + if (player.strongBees) + projAmt += Projectile.Calamity().stealthStrike ? 7 : 5; for (int projIndex = 0; projIndex < projAmt; projIndex++) { float speedX = (float)Main.rand.Next(-35, 36) * 0.02f; diff --git a/Projectiles/Rogue/PumpkaboomBig.cs b/Projectiles/Rogue/PumpkaboomBig.cs index 2bfe1f2e96..7439fa10fd 100644 --- a/Projectiles/Rogue/PumpkaboomBig.cs +++ b/Projectiles/Rogue/PumpkaboomBig.cs @@ -155,7 +155,7 @@ namespace CalamityMod.Projectiles.Rogue if (Main.myPlayer == Projectile.owner) { - if (completion >= 1 || hasReachedFullCharge) + if (completion >= 1) { time = -1; Projectile.Center = Owner.Center; @@ -165,48 +165,20 @@ namespace CalamityMod.Projectiles.Rogue flungState = 1f; Projectile.netUpdate = true; } - else - { - if (Main.mouseLeft && !hasStoppedHolding) - { - if (completion >= 0.7f && completion <= 0.8f) - { - time--; - if (charge < 1) - charge += 0.5f; - - if (charge >= 1 && !hasReachedFullCharge) - { - SoundEngine.PlaySound(SoundID.Item1, Projectile.Center); - hasReachedFullCharge = true; - } - } - } - else - { - if (!hasReachedFullCharge) - { - Projectile.localAI[1] = 5; - flungState = -1f; - Projectile.Kill(); - } - hasStoppedHolding = true; - } - } Owner.direction = Math.Sign(Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld).X); } float grenadeRot = 0; - if (completion >= 0.7f) + if (completion <= 0.75f) { - float completionLerp = (float)Math.Pow(Utils.GetLerpValue(0.7f, 1f, completion, true), 7); - grenadeRot = MathHelper.ToRadians(MathHelper.Lerp(-75, 130f, completionLerp) * Owner.direction); + float completionLerp = (float)Math.Pow(Utils.GetLerpValue(0f, 0.75f, completion, true), 2); + grenadeRot = MathHelper.ToRadians(MathHelper.Lerp(120, -75f, completionLerp) * Owner.direction); } else { - float completionLerp = (float)Math.Pow(Utils.GetLerpValue(0f, 0.7f, completion, true), 2); - grenadeRot = MathHelper.ToRadians(MathHelper.Lerp(120, -75f, completionLerp) * Owner.direction); + float releaseLerp = (float)Math.Pow(Utils.GetLerpValue(0.75f, 1f, completion, true), 3); + grenadeRot = MathHelper.ToRadians(MathHelper.Lerp(-75f, 30f, releaseLerp) * Owner.direction); } Vector2 mouseDir = (Main.myPlayer == Projectile.owner) ? Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld) : Projectile.velocity.SafeNormalize(Vector2.UnitX); @@ -394,14 +366,28 @@ namespace CalamityMod.Projectiles.Rogue int useAnim = Owner.HeldItem.useAnimation > 0 ? Owner.HeldItem.useAnimation : 30; float completion = time / (useAnim * 0.7f); - float completionLerp2 = (float)Math.Pow(Utils.GetLerpValue(0f, 0.7f, completion, true), 2); - float grenadeRot = MathHelper.ToRadians(MathHelper.Lerp(120, -75f, completionLerp2) * Owner.direction); + float grenadeRot; + + if (completion <= 0.75f) + { + float completionLerp = (float)Math.Pow(Utils.GetLerpValue(0f, 0.75f, completion, true), 2); + grenadeRot = MathHelper.ToRadians(MathHelper.Lerp(120, -75f, completionLerp) * Owner.direction); + } + else + { + float releaseLerp = (float)Math.Pow(Utils.GetLerpValue(0.75f, 1f, completion, true), 3); + grenadeRot = MathHelper.ToRadians(MathHelper.Lerp(-75f, 30f, releaseLerp) * Owner.direction); + } + Vector2 mouseDir = (Main.myPlayer == Projectile.owner) ? Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld) : Projectile.velocity.SafeNormalize(Vector2.UnitX); grenadeRot += mouseDir.ToRotation(); + Vector2 grenadePos = Owner.GetFrontHandPosition(Player.CompositeArmStretchAmount.Full, grenadeRot) + new Vector2(Owner.direction == 1 ? 5 : 5, Owner.direction == 1 ? -38 : 22).RotatedBy(grenadeRot); + drawPosition = grenadePos - Main.screenPosition; - drawRotation = grenadeRot - MathHelper.ToRadians(25 * completionLerp2) + (Owner.direction == 1 ? MathHelper.ToRadians(180) : 0); + drawRotation = grenadeRot + (Owner.direction == 1 ? MathHelper.ToRadians(180) : 0); } + else { if (stuckState == 1f) diff --git a/Projectiles/Rogue/PumpkaboomSmall.cs b/Projectiles/Rogue/PumpkaboomSmall.cs index 19708ea60b..759714363a 100644 --- a/Projectiles/Rogue/PumpkaboomSmall.cs +++ b/Projectiles/Rogue/PumpkaboomSmall.cs @@ -122,7 +122,7 @@ namespace CalamityMod.Projectiles.Rogue if (Main.myPlayer == Projectile.owner) { - if (completion >= 1 || hasReachedFullCharge) + if (completion >= 1) { time = -1; Projectile.Center = Owner.Center; @@ -132,52 +132,27 @@ namespace CalamityMod.Projectiles.Rogue flungState = 1f; Projectile.netUpdate = true; } - else - { - if (Main.mouseLeft && !hasStoppedHolding) - { - if (completion >= 0.7f && completion <= 0.8f) - { - time--; - if (charge < 1) - charge += 0.5f; - if (charge >= 1 && !hasReachedFullCharge) - { - SoundEngine.PlaySound(SoundID.Item1, Projectile.Center); - hasReachedFullCharge = true; - } - } - } - else - { - if (!hasReachedFullCharge) - { - Projectile.localAI[1] = 5; - flungState = -1f; - Projectile.Kill(); - } - hasStoppedHolding = true; - } - } Owner.direction = Math.Sign(Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld).X); } float grenadeRot = 0; - if (completion >= 0.7f) + if (completion <= 0.75f) { - float completionLerp = (float)Math.Pow(Utils.GetLerpValue(0.7f, 1f, completion, true), 7); - grenadeRot = MathHelper.ToRadians(MathHelper.Lerp(-75, 130f, completionLerp) * Owner.direction); + float completionLerp = (float)Math.Pow(Utils.GetLerpValue(0f, 0.75f, completion, true), 2); + grenadeRot = MathHelper.ToRadians(MathHelper.Lerp(120, -75f, completionLerp) * Owner.direction); } else { - float completionLerp = (float)Math.Pow(Utils.GetLerpValue(0f, 0.7f, completion, true), 2); - grenadeRot = MathHelper.ToRadians(MathHelper.Lerp(120, -75f, completionLerp) * Owner.direction); + float releaseLerp = (float)Math.Pow(Utils.GetLerpValue(0.75f, 1f, completion, true), 3); + grenadeRot = MathHelper.ToRadians(MathHelper.Lerp(-75f, 30f, releaseLerp) * Owner.direction); } Vector2 mouseDir = (Main.myPlayer == Projectile.owner) ? Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld) : Projectile.velocity.SafeNormalize(Vector2.UnitX); grenadeRot += mouseDir.ToRotation(); + Vector2 grenadePos = Owner.GetFrontHandPosition(Player.CompositeArmStretchAmount.Full, grenadeRot) + new Vector2(Owner.direction == 1 ? 5 : -3, Owner.direction == 1 ? -24 : -4).RotatedBy(grenadeRot); + float completionLerp2 = (float)Math.Pow(Utils.GetLerpValue(0f, 0.7f, completion, true), 2); float grenadeHalfRot = MathHelper.ToRadians(MathHelper.Lerp(120, -75f, completionLerp2) * Owner.direction); @@ -359,14 +334,28 @@ namespace CalamityMod.Projectiles.Rogue int useAnim = Owner.HeldItem.useAnimation > 0 ? Owner.HeldItem.useAnimation : 30; float completion = time / (useAnim * 0.7f); - float completionLerp2 = (float)Math.Pow(Utils.GetLerpValue(0f, 0.7f, completion, true), 2); - float grenadeRot = MathHelper.ToRadians(MathHelper.Lerp(120, -75f, completionLerp2) * Owner.direction); + float grenadeRot; + + if (completion <= 0.75f) + { + float completionLerp = (float)Math.Pow(Utils.GetLerpValue(0f, 0.75f, completion, true), 2); + grenadeRot = MathHelper.ToRadians(MathHelper.Lerp(120, -75f, completionLerp) * Owner.direction); + } + else + { + float releaseLerp = (float)Math.Pow(Utils.GetLerpValue(0.75f, 1f, completion, true), 3); + grenadeRot = MathHelper.ToRadians(MathHelper.Lerp(-75f, 30f, releaseLerp) * Owner.direction); + } + Vector2 mouseDir = (Main.myPlayer == Projectile.owner) ? Utils.DirectionTo(Owner.Center, Owner.Calamity().mouseWorld) : Projectile.velocity.SafeNormalize(Vector2.UnitX); grenadeRot += mouseDir.ToRotation(); + Vector2 grenadePos = Owner.GetFrontHandPosition(Player.CompositeArmStretchAmount.Full, grenadeRot) + new Vector2(Owner.direction == 1 ? 5 : 5, Owner.direction == 1 ? -38 : 22).RotatedBy(grenadeRot); + drawPosition = grenadePos - Main.screenPosition; - drawRotation = grenadeRot - MathHelper.ToRadians(25 * completionLerp2) + (Owner.direction == 1 ? MathHelper.ToRadians(180) : 0); + drawRotation = grenadeRot + (Owner.direction == 1 ? MathHelper.ToRadians(180) : 0); } + else { if (stuckState == 1f) diff --git a/Projectiles/Rogue/SlickCaneProjectile.cs b/Projectiles/Rogue/SlickCaneProjectile.cs index 061241ef8a..54599b649a 100644 --- a/Projectiles/Rogue/SlickCaneProjectile.cs +++ b/Projectiles/Rogue/SlickCaneProjectile.cs @@ -67,9 +67,9 @@ namespace CalamityMod.Projectiles.Rogue float f2 = Projectile.rotation - MathHelper.PiOver4 * Math.Sign(Projectile.velocity.X) + (Projectile.spriteDirection == -1).ToInt() * MathHelper.Pi; float velocityMagnitude = 0f; - float scaleFactor = 35f; + float scaleFactor = 18f; if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), - Projectile.Center, Projectile.Center + f2.ToRotationVector2() * scaleFactor, + Main.player[Projectile.owner].Center, Projectile.Center + f2.ToRotationVector2() * scaleFactor, (TravelSpeed + 1f) * Projectile.scale, ref velocityMagnitude)) { return true; @@ -142,12 +142,12 @@ namespace CalamityMod.Projectiles.Rogue } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { - // Boost dmg in proportion to money, caps at 1 plat. Much higher cap in GFB cuz it would be funny + // Boost dmg in proportion to money, caps at 1 plat. if (Projectile.Calamity().stealthStrike) { Player player = Main.player[Projectile.owner]; double money = Utils.CoinsCount(out bool overflow, player.inventory); - double cap = Main.zenithWorld ? 100000000 : 1000000; + double cap = 1000000; if (money >= cap) money = cap; if (money != 0) diff --git a/Projectiles/Rogue/SupernovaBoom.cs b/Projectiles/Rogue/SupernovaBoom.cs index 7a48ea630d..9d920c69f4 100644 --- a/Projectiles/Rogue/SupernovaBoom.cs +++ b/Projectiles/Rogue/SupernovaBoom.cs @@ -116,15 +116,6 @@ namespace CalamityMod.Projectiles.Rogue } if (currentFrame == 13) { - if (Main.zenithWorld) - { - if (Vector2.Distance(Owner.Center, Projectile.Center) < radius) - { - Vector2 velToApply = Owner.Center.DirectionFrom(Projectile.Center).SafeNormalize(Vector2.UnitX) * 30; - Owner.velocity = velToApply + (velToApply.Y <= 0 ? new Vector2(0, -15) : Vector2.Zero); - } - } - Projectile.velocity = Vector2.Zero; Owner.SetScreenshake(5f); @@ -166,13 +157,8 @@ namespace CalamityMod.Projectiles.Rogue } } - if (currentFrame < 13) // suck in enemies, or you if it's GFB + if (currentFrame < 13) // suck in enemies { - if (Main.zenithWorld) - { - if (Vector2.Distance(Owner.Center, Projectile.Center) > 40 && Vector2.Distance(Owner.Center, Projectile.Center) < 600) - Owner.Center += Owner.Center.DirectionTo(Projectile.Center).SafeNormalize(Vector2.UnitX) * 22; - } for (int i = 0; i < Main.maxNPCs; i++) { NPC target = Main.npc[i]; diff --git a/Projectiles/Rogue/SupernovaStealthBoom.cs b/Projectiles/Rogue/SupernovaStealthBoom.cs index b78d856f42..21f394d99a 100644 --- a/Projectiles/Rogue/SupernovaStealthBoom.cs +++ b/Projectiles/Rogue/SupernovaStealthBoom.cs @@ -134,12 +134,6 @@ namespace CalamityMod.Projectiles.Rogue if (time == 80) { radius = 2500; - if (Main.zenithWorld) - { - Projectile.hostile = true; - Projectile.friendly = true; - Projectile.damage *= 100; - } SoundEngine.PlaySound(Supernova.StealthExplosionSound with { Pitch = Projectile.ai[2] }, Projectile.Center); Projectile.numHits = 0; diff --git a/Projectiles/Rogue/ToothBallProjectile.cs b/Projectiles/Rogue/ToothBallProjectile.cs index 8592253161..59634c5d7c 100644 --- a/Projectiles/Rogue/ToothBallProjectile.cs +++ b/Projectiles/Rogue/ToothBallProjectile.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Projectiles.Rogue public override void SetDefaults() { - Projectile.width = 12; - Projectile.height = 12; + Projectile.width = 30; + Projectile.height = 30; Projectile.friendly = true; Projectile.penetrate = 3; Projectile.aiStyle = ProjAIStyleID.ThrownProjectile; diff --git a/Projectiles/Summon/AtlasMunitionsLaserOverdrive.cs b/Projectiles/Summon/AtlasMunitionsLaserOverdrive.cs index 687d7d13ed..8c1d426513 100644 --- a/Projectiles/Summon/AtlasMunitionsLaserOverdrive.cs +++ b/Projectiles/Summon/AtlasMunitionsLaserOverdrive.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Projectiles.Summon public override void SetStaticDefaults() { Main.projFrames[Type] = 4; - ProjectileID.Sets.MinionShot[Type] = true; + ProjectileID.Sets.SentryShot[Type] = true; } public override void SetDefaults() diff --git a/Projectiles/Summon/BloodBreath.cs b/Projectiles/Summon/BloodBreath.cs index b486c23676..59e83f51c6 100644 --- a/Projectiles/Summon/BloodBreath.cs +++ b/Projectiles/Summon/BloodBreath.cs @@ -1,5 +1,6 @@ using CalamityMod.Buffs.DamageOverTime; using Terraria; +using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon @@ -57,7 +58,7 @@ namespace CalamityMod.Projectiles.Summon Time++; if (Main.rand.NextBool()) { - Dust dust = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, DustID.Blood, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100); + Dust dust = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, !ChildSafety.Disabled ? DustID.Cloud : DustID.Blood, Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f, 100); if (Main.rand.NextBool(3)) { dust.noGravity = true; diff --git a/Projectiles/Summon/BloodSpit.cs b/Projectiles/Summon/BloodSpit.cs index 62dd5683bd..50c362b699 100644 --- a/Projectiles/Summon/BloodSpit.cs +++ b/Projectiles/Summon/BloodSpit.cs @@ -1,5 +1,7 @@ using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; @@ -44,10 +46,29 @@ namespace CalamityMod.Projectiles.Summon { for (int i = 0; i < 15; i++) { - Dust blood = Dust.NewDustDirect(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.Blood, Projectile.velocity.X * 0.1f, Projectile.velocity.Y * 0.1f); + Dust blood = Dust.NewDustDirect(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, !ChildSafety.Disabled ? DustID.Cloud : DustID.Blood, Projectile.velocity.X * 0.1f, Projectile.velocity.Y * 0.1f); blood.velocity = Main.rand.NextVector2Circular(1f, 2f); blood.noGravity = true; } } + + public override bool PreDraw(ref Color lightColor) + { + if (ChildSafety.Disabled) + { + return base.PreDraw(ref lightColor); + } + + Texture2D texture = TextureAssets.Projectile[Projectile.type].Value; + int frameHeight = texture.Height / Main.projFrames[Projectile.type]; + int startY = frameHeight * Projectile.frame; + Rectangle sourceRectangle = new Rectangle(0, startY, texture.Width, frameHeight); + Vector2 origin = sourceRectangle.Size() / 2f; + Color drawColor = Color.CornflowerBlue; + drawColor *= Projectile.Opacity; + + Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), sourceRectangle, drawColor, Projectile.rotation, origin, Projectile.scale, SpriteEffects.None, 0); + return false; + } } } diff --git a/Projectiles/Summon/DazzlingStabber.cs b/Projectiles/Summon/DazzlingStabber.cs index 4322dbb52a..ac5051de40 100644 --- a/Projectiles/Summon/DazzlingStabber.cs +++ b/Projectiles/Summon/DazzlingStabber.cs @@ -1,4 +1,5 @@ using System; +using System.IO; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.Summon; using CalamityMod.Dusts; @@ -19,9 +20,10 @@ namespace CalamityMod.Projectiles.Summon public ref float AttackDelay => ref Projectile.ai[0]; public ref float RestOffsetAngle => ref Projectile.ai[1]; public ref float KnifeType => ref Projectile.ai[2]; // 1 - Crystal, 2 - Stone, 3 - Fire - public Color color1 = Color.White; + public Color bladeColor = Color.White; public int attackCooldown = 0; public int attacksDone = 0; + private bool justHit = false; public NPC potentialTarget; public float moveSmoothing = 50; public float damageMult = 1; @@ -49,23 +51,36 @@ namespace CalamityMod.Projectiles.Summon Projectile.DamageType = DamageClass.Summon; } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(attackCooldown); + writer.Write(attacksDone); + writer.Write(justHit); + } + public override void ReceiveExtraAI(BinaryReader reader) + { + attackCooldown = reader.ReadInt32(); + attacksDone = reader.ReadInt32(); + justHit = reader.ReadBoolean(); + } + public override void AI() { switch (KnifeType) { case 1: // Crystal - color1 = Color.Orchid; + bladeColor = Color.Orchid; Projectile.extraUpdates = 1; damageMult = 0.5f; Projectile.ArmorPenetration = 40; break; case 2: // Rock - color1 = Color.OrangeRed; + bladeColor = Color.OrangeRed; Projectile.extraUpdates = 2; damageMult = 3; break; default: // Flame - color1 = Color.Orange; + bladeColor = Color.Orange; damageMult = 1; Projectile.ArmorPenetration = 20; break; @@ -82,11 +97,46 @@ namespace CalamityMod.Projectiles.Summon storedPos = potentialTarget.Center; } + // On-hit visuals + if (justHit) + { + if (KnifeType == 1) + { + SoundEngine.PlaySound(SoundID.DD2_WitherBeastCrystalImpact with { Volume = 0.7f, Pitch = attacksDone * 0.05f }, Projectile.Center); + if (attacksDone >= 6) + { + for (int i = 0; i < 9; i++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType(), Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedByRandom(0.5f) * Main.rand.NextFloat(10f, 20f)); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(1.25f, 1.75f); + dust.color = Color.Orchid; + dust.noLightEmittence = true; + } + for (int i = 0; i < 4; i++) + { + Particle spark = new CustomSpark(Projectile.Center, (Projectile.velocity.SafeNormalize(Vector2.UnitX)).RotatedByRandom(0.6f) * Main.rand.NextFloat(15f, 20f), "CalamityMod/Particles/ProvidenceMarkParticle", false, 25, Main.rand.NextFloat(1.35f, 1.6f), Color.Orchid, new Vector2(1.3f, 0.5f), true, false, 0, false, false, Main.rand.NextFloat(0.25f, 0.35f)); + GeneralParticleHandler.SpawnParticle(spark); + } + } + } + if (KnifeType == 2) + { + SoundStyle slam = new("CalamityMod/Sounds/NPCHit/RavagerRockPillarHit", 2); + SoundEngine.PlaySound(slam with { Volume = 0.4f, Pitch = Main.rand.NextFloat(-0.25f, -0.15f), MaxInstances = -1 }, Projectile.Center); + for (int i = 0; i < 7; i++) + { + Particle spark = new CustomSpark(Projectile.Center, Vector2.One.RotatedByRandom(100) * Main.rand.NextFloat(1f, 5f), "CalamityMod/Projectiles/Typeless/ArtifactOfResilienceShard6", false, Main.rand.Next(15, 25 + 1), Main.rand.NextFloat(0.75f, 1.2f), Color.White, new Vector2(1.3f, 0.5f), false, false, Main.rand.NextFloat(-5, 5), false, false); + GeneralParticleHandler.SpawnParticle(spark); + } + } + } + if (potentialTarget != null) { if (KnifeType == 1 && attacksDone > 0 && Utils.Distance(Projectile.Center, storedPos) < 150 && attackCooldown == 0) { - Particle spark = new GlowSparkParticle(Projectile.Center, -Projectile.velocity * 0.1f, false, 20, 0.03f, color1 * 0.55f, new Vector2(0.8f, 2.3f), true, false, 0.45f); + Particle spark = new GlowSparkParticle(Projectile.Center, -Projectile.velocity * 0.1f, false, 20, 0.03f, bladeColor * 0.55f, new Vector2(0.8f, 2.3f), true, false, 0.45f); GeneralParticleHandler.SpawnParticle(spark); } if (KnifeType == 2 && attackCooldown == 0) @@ -102,7 +152,7 @@ namespace CalamityMod.Projectiles.Summon Dust dust = Dust.NewDustPerfect(Projectile.Center, memesHatesLists ? 278 : ModContent.DustType(), -Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedByRandom(0.4f) * Main.rand.NextFloat(1f, 4f)); dust.noGravity = !memesHatesLists; dust.scale = Main.rand.NextFloat(0.55f, 1.1f); - dust.color = color1; + dust.color = bladeColor; } } if (KnifeType == 3) @@ -255,38 +305,16 @@ namespace CalamityMod.Projectiles.Summon } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { + justHit = true; if (KnifeType == 1) { AttackDelay = 15; attacksDone++; - SoundEngine.PlaySound(SoundID.DD2_WitherBeastCrystalImpact with { Volume = 0.7f, Pitch = attacksDone * 0.05f }, Projectile.Center); if (attacksDone >= 6) - { - for (int i = 0; i < 9; i++) - { - Dust dust = Dust.NewDustPerfect(Projectile.Center, ModContent.DustType(), Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedByRandom(0.5f) * Main.rand.NextFloat(10f, 20f)); - dust.noGravity = true; - dust.scale = Main.rand.NextFloat(1.25f, 1.75f); - dust.color = Color.Orchid; - dust.noLightEmittence = true; - } - for (int i = 0; i < 4; i++) - { - Particle spark = new CustomSpark(Projectile.Center, (Projectile.velocity.SafeNormalize(Vector2.UnitX)).RotatedByRandom(0.6f) * Main.rand.NextFloat(15f, 20f), "CalamityMod/Particles/ProvidenceMarkParticle", false, 25, Main.rand.NextFloat(1.35f, 1.6f), Color.Orchid, new Vector2(1.3f, 0.5f), true, false, 0, false, false, Main.rand.NextFloat(0.25f, 0.35f)); - GeneralParticleHandler.SpawnParticle(spark); - } attackCooldown = Main.rand.Next(80, 95 + 1); - } } if (KnifeType == 2) { - SoundStyle slam = new("CalamityMod/Sounds/NPCHit/RavagerRockPillarHit", 2); - SoundEngine.PlaySound(slam with { Volume = 0.4f, Pitch = Main.rand.NextFloat(-0.25f, -0.15f), MaxInstances = -1 }, Projectile.Center); - for (int i = 0; i < 7; i++) - { - Particle spark = new CustomSpark(Projectile.Center, Vector2.One.RotatedByRandom(100) * Main.rand.NextFloat(1f, 5f), "CalamityMod/Projectiles/Typeless/ArtifactOfResilienceShard6", false, Main.rand.Next(15, 25 + 1), Main.rand.NextFloat(0.75f, 1.2f), Color.White, new Vector2(1.3f, 0.5f), false, false, Main.rand.NextFloat(-5, 5), false, false); - GeneralParticleHandler.SpawnParticle(spark); - } Projectile.velocity = (-Projectile.velocity.SafeNormalize(Vector2.UnitX) * 15).RotatedByRandom(0.7f); attackCooldown = Main.rand.Next(45, 60 + 1); } @@ -296,11 +324,9 @@ namespace CalamityMod.Projectiles.Summon attackCooldown = 5; target.AddBuff(ModContent.BuffType(), 180); } + Projectile.netUpdate = true; } - public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) - { - modifiers.SourceDamage *= damageMult; - } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) => modifiers.SourceDamage *= damageMult; public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), 180); @@ -316,7 +342,7 @@ namespace CalamityMod.Projectiles.Summon if (KnifeType == 3) tex = ModContent.Request("CalamityMod/Projectiles/Summon/DazzlingStabber3").Value; - Projectile.DrawProjectileWithBackglow(color1 with { A = 0 }, lightColor, 3.5f, tex); + Projectile.DrawProjectileWithBackglow(bladeColor with { A = 0 }, lightColor, 3.5f, tex); return false; } diff --git a/Projectiles/Summon/DreadmineTurret.cs b/Projectiles/Summon/DreadmineTurret.cs index 1a1cc0a54e..235947ba98 100644 --- a/Projectiles/Summon/DreadmineTurret.cs +++ b/Projectiles/Summon/DreadmineTurret.cs @@ -67,8 +67,9 @@ namespace CalamityMod.Projectiles.Summon { Projectile.NewProjectile(Projectile.GetSource_FromThis(), center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner,Projectile.whoAmI); mineAmt++; - i -= 0.75f; // This will cause it to run more loops when mines fail, but still eventually get up to the cap of 5 mines per activation even if no spots to spawn can be found. } + else + i -= 0.75f; // This will cause it to run more loops when mines fail, but still eventually get up to the cap of 5 mines per activation even if no spots to spawn can be found. } else { diff --git a/Projectiles/Summon/FlyingOrthoceraStream.cs b/Projectiles/Summon/FlyingOrthoceraStream.cs index b7a9f750ac..4b4a7db582 100644 --- a/Projectiles/Summon/FlyingOrthoceraStream.cs +++ b/Projectiles/Summon/FlyingOrthoceraStream.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Projectiles.Summon public override void SetStaticDefaults() { - ProjectileID.Sets.MinionShot[Type] = true; + ProjectileID.Sets.SentryShot[Type] = true; } public override void SetDefaults() diff --git a/Projectiles/Summon/HarvestStaffMinion.cs b/Projectiles/Summon/HarvestStaffMinion.cs index 67d97ddc25..10915893e7 100644 --- a/Projectiles/Summon/HarvestStaffMinion.cs +++ b/Projectiles/Summon/HarvestStaffMinion.cs @@ -528,7 +528,7 @@ namespace CalamityMod.Projectiles.Summon public override void SetStaticDefaults() { Main.projFrames[Type] = 68; - ProjectileID.Sets.MinionShot[Type] = true; + ProjectileID.Sets.SentryShot[Type] = true; } public override void SetDefaults() diff --git a/Projectiles/Summon/IgneousBlade.cs b/Projectiles/Summon/IgneousBlade.cs index 7fca4f2e51..4a0edee62a 100644 --- a/Projectiles/Summon/IgneousBlade.cs +++ b/Projectiles/Summon/IgneousBlade.cs @@ -118,11 +118,12 @@ namespace CalamityMod.Projectiles.Summon CircleOwner(); break; case AIState.TransitionToLaunch: - ChargeTargetPos = Owner.Calamity().mouseWorld; + Owner.Calamity().mouseWorldListener = true; + ChargeTargetPos = Owner.Calamity().mouseWorldDeltaFromPlayer; ChargeStartPos = Owner.Center; CurrentState = AIState.LaunchAtPos; AITimer = 0; - Projectile.penetrate = 50; + Projectile.penetrate = 15; LaunchAtTargetPos(); break; case AIState.LaunchAtPos: @@ -161,13 +162,11 @@ namespace CalamityMod.Projectiles.Summon public void LaunchAtTargetPos() { - Projectile.damage = Projectile.originalDamage; - if (Projectile.penetrate > 40) //First 10 hits do 2x damage - Projectile.damage *= 2; int chargeTime = IgneousExaltation.ChargeDuration * 2; int chargeLength = 2000; float circleWidth = Math.Min(75, Owner.ownedProjectileCounts[Type] * 4); - var CurrentPlace = Vector2.Lerp(ChargeStartPos, ChargeStartPos + ChargeStartPos.DirectionTo(ChargeTargetPos) * chargeLength, MathF.Pow(AITimer / chargeTime, 3)); + var CurrentPlace = Vector2.Lerp(ChargeStartPos, ChargeStartPos + ChargeTargetPos.SafeNormalize(Vector2.UnitX) * chargeLength, MathF.Pow(AITimer / chargeTime, 3)); + Projectile.Center = CurrentPlace + BladeHoverOffsetAngle.ToRotationVector2() * Math.Max(MathHelper.Lerp(100f, 25f, AITimer / 10f), circleWidth); Projectile.rotation = Projectile.AngleFrom(CurrentPlace) + MathHelper.PiOver2; if (AITimer >= chargeTime) @@ -193,9 +192,14 @@ namespace CalamityMod.Projectiles.Summon } } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + if (Projectile.penetrate >= 10) // First 5 hits deal 2x dmg + modifiers.SourceDamage *= 2; + } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - if (Projectile.penetrate >= 40 && CurrentState != AIState.CircleOwner) //The first 10 hits per launch can spawn blades + if (Projectile.penetrate >= 10 && CurrentState != AIState.CircleOwner) //The first 5 hits per launch can spawn blades if (Main.myPlayer == Projectile.owner) { for (int i = 0; i < 1; i++) diff --git a/Projectiles/Summon/OldDukeSharkVomit.cs b/Projectiles/Summon/OldDukeSharkVomit.cs index ebf8e9c181..2f5e8c671e 100644 --- a/Projectiles/Summon/OldDukeSharkVomit.cs +++ b/Projectiles/Summon/OldDukeSharkVomit.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Projectiles.Summon public new string LocalizationCategory => "Projectiles.Summon"; public override void SetStaticDefaults() { - ProjectileID.Sets.MinionShot[Type] = true; + ProjectileID.Sets.SentryShot[Type] = true; ProjectileID.Sets.CultistIsResistantTo[Type] = true; } diff --git a/Projectiles/Summon/PlaguePrincess.cs b/Projectiles/Summon/PlaguePrincess.cs index 675df857c8..ad3f25f855 100644 --- a/Projectiles/Summon/PlaguePrincess.cs +++ b/Projectiles/Summon/PlaguePrincess.cs @@ -73,6 +73,9 @@ namespace CalamityMod.Projectiles.Summon // Decide frames. DecideFrames(); + if (Owner.strongBees) + Projectile.damage = (int)(Projectile.damage * 1.167f); //Minions recalculate every frame so this won't scale infinitely. + // Reset afterimages, extra updates, and i-frames. UseAfterimages = false; Projectile.MaxUpdates = 1; diff --git a/Projectiles/Summon/PlaguebringerMK2.cs b/Projectiles/Summon/PlaguebringerMK2.cs index 01e795d795..e1a38ea092 100644 --- a/Projectiles/Summon/PlaguebringerMK2.cs +++ b/Projectiles/Summon/PlaguebringerMK2.cs @@ -67,7 +67,7 @@ namespace CalamityMod.Projectiles.Summon else Projectile.velocity = Projectile.SafeDirectionTo(destination) * Projectile.Distance(destination) / 36f; - int timeNeeded = (int)MathHelper.Lerp(60f, 18f, MathHelper.Clamp(Projectile.localAI[1] / 320f, 0f, 1f)); + int timeNeeded = (int)(MathHelper.Lerp(60f, 18f, MathHelper.Clamp(Projectile.localAI[1] / 320f, 0f, 1f)) * (player.strongBees ? 0.85f : 1f)); if (Projectile.ai[0] >= timeNeeded && Main.myPlayer == Projectile.owner) { Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, diff --git a/Projectiles/Summon/ProfanedEnergy.cs b/Projectiles/Summon/ProfanedEnergy.cs index fadd5344d5..19db3f0522 100644 --- a/Projectiles/Summon/ProfanedEnergy.cs +++ b/Projectiles/Summon/ProfanedEnergy.cs @@ -186,7 +186,7 @@ namespace CalamityMod.Projectiles.Summon if (healShots != 0 && attackCooldown != maxRechargeTime && (attackCooldown % (maxRechargeTime / (healShots + 1)) == 0)) { Vector2 vel = ((Projectile.Center - player.Center) - player.velocity * 10).SafeNormalize(Vector2.UnitX) * -10; - Projectile healStar = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, vel, ModContent.ProjectileType(), 0, Projectile.knockBack, Projectile.owner, 0, 10, 5); + Projectile healStar = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, vel, ModContent.ProjectileType(), 0, Projectile.knockBack, Projectile.owner, 0, 5, 5); healStar.extraUpdates = 2; SoundStyle fireHeal = new("CalamityMod/Sounds/Custom/ProfanedGuardians/GuardianDash"); SoundEngine.PlaySound(fireHeal with { Volume = 0.7f, Pitch = 0.3f }, Projectile.Center); diff --git a/Projectiles/Summon/SiriusMinion.cs b/Projectiles/Summon/SiriusMinion.cs index e41364e24c..f85c8e11d3 100644 --- a/Projectiles/Summon/SiriusMinion.cs +++ b/Projectiles/Summon/SiriusMinion.cs @@ -89,11 +89,16 @@ namespace CalamityMod.Projectiles.Summon SpawnEffect(); // Does a dust spawn effect. ShootTarget(target); // If there's a target, shoot at the target. - if (target is not null && Owner.miscCounter % 30 == 0) { - - if (moddedOwner.StratusStarburst <= CalamityPlayer.MaxStratusStarburst) + if (target is not null) + { + moddedOwner.StarburstSpawnFrameCounter += Projectile.minionSlots / (float)CalamityUtils.SecondsToFrames(3f); //0.33 starbursts per seconds per minion slot + while (moddedOwner.StarburstSpawnFrameCounter >= 1 && moddedOwner.StratusStarburst <= CalamityPlayer.MaxStratusStarburst) + { + moddedOwner.StratusStarburst++; moddedOwner.StarburstEntities.Add(new StarburstEntity(Projectile.Center)); - moddedOwner.StratusStarburst++; + moddedOwner.StarburstSpawnFrameCounter--; + } + } Lighting.AddLight(Projectile.Center, 0.5f, 0.5f, 1f); // Passively makes blue light. diff --git a/Projectiles/Summon/SiriusQuasar.cs b/Projectiles/Summon/SiriusQuasar.cs index 568d8abe34..8caa8b3348 100644 --- a/Projectiles/Summon/SiriusQuasar.cs +++ b/Projectiles/Summon/SiriusQuasar.cs @@ -14,6 +14,7 @@ namespace CalamityMod.Projectiles.Summon public new string LocalizationCategory => "Projectiles.Summon"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + bool hasExploded = false; public override void SetStaticDefaults() { ProjectileID.Sets.MinionShot[Type] = true; @@ -75,8 +76,9 @@ namespace CalamityMod.Projectiles.Summon //Due to Sirius's high Starburst consumption, it inflicts long amounts of Voidfrost on hit target.AddBuff(ModContent.BuffType(), 600); float x4 = Main.rgbToHsl(new Color(103, 203, Main.DiscoB)).X; - if (Projectile.numHits == 0) + if (!hasExploded && !target.Calamity().IsArmored()) { + hasExploded = true; SoundStyle fire = new("CalamityMod/Sounds/Item/ScorpioNukeHit"); SoundEngine.PlaySound(fire with { Volume = 0.75f, Pitch = 0.6f, PitchVariance = 0.2f }, Projectile.Center); float numberOfDusts = 156f; diff --git a/Projectiles/Summon/VengefulSunSpiritMinion.cs b/Projectiles/Summon/VengefulSunSpiritMinion.cs index 531def854b..f298bbd61d 100644 --- a/Projectiles/Summon/VengefulSunSpiritMinion.cs +++ b/Projectiles/Summon/VengefulSunSpiritMinion.cs @@ -108,7 +108,7 @@ namespace CalamityMod.Projectiles.Summon float shootSpeed = 15f; Vector2 source = Projectile.Center; var velocity = CalamityUtils.CalculatePredictiveAimToTargetMaxUpdates(Projectile.Center, target, shootSpeed, 2); - Projectile beam = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center - velocity, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * (0.75f + Projectile.minionSlots * 0.25f)), Projectile.knockBack, Projectile.owner, ai1: (Projectile.minionSlots - 1) / 9f); + Projectile beam = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center - velocity, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * (0.75f + Projectile.minionSlots * 0.25f)), Projectile.knockBack, Projectile.owner, ai1: (Projectile.minionSlots - 1) / 6f); beam.DamageType = DamageClass.Summon; Projectile.ai[1] += 60f / (0.75f + Projectile.minionSlots * 0.25f); } @@ -147,7 +147,6 @@ namespace CalamityMod.Projectiles.Summon public static Asset circle; public override bool PreDraw(ref Color lightColor) { - AllWhiteVersion = null; var spTex = TextureAssets.Projectile[Type].Value; var whiteTex = GetWhiteTex(); var ciTex = CalamityUtils.GetTextureEfficient(ref circle, "CalamityMod/ExtraTextures/GreyscaleOpenCircleButBigger").Value; diff --git a/Projectiles/Typeless/AmuletEnergy.cs b/Projectiles/Typeless/AmuletEnergy.cs index e0e37cc736..278b83fa31 100644 --- a/Projectiles/Typeless/AmuletEnergy.cs +++ b/Projectiles/Typeless/AmuletEnergy.cs @@ -28,8 +28,6 @@ namespace CalamityMod.Projectiles.Typeless public ref float energyNumber => ref Projectile.ai[1]; // The number assigned to this energy, ranging from 1 to the max number of energies public bool idle => Projectile.ai[2] == 0; // Floating around the player public bool healing = false; // If the energies should heal the player. If false they will attack - public int soundCooldown = 0; // A cooldown after making a sound. Also used for some of the visuals when a sound is made - public SlotId soundSlot; public NPC targeted; public override void SetStaticDefaults() { @@ -51,12 +49,11 @@ namespace CalamityMod.Projectiles.Typeless public override void AI() { - bool spoke = (soundCooldown >= 250 * Projectile.MaxUpdates); int startTime = 100; // Time after launch when it will begin attacking/healing int endTime = 300; // Time after launch when it's movement code reaches it's cap on strength - // Color is in blues if idle or healing, but becomes orange breifley if they speak or constantly if they are attacking - float colorShift = spoke ? Utils.GetLerpValue(250 * Projectile.MaxUpdates, 300 * Projectile.MaxUpdates, soundCooldown) : (idle || healing ? 0 : Utils.GetLerpValue(0, startTime, time)); + // Color is in blues if idle or healing, but becomes orange if they are attacking + float colorShift = (idle || healing ? 0 : Utils.GetLerpValue(0, startTime, time)); float rate = Main.GlobalTimeWrappedHourly * 5; List eColors = new List() { @@ -86,9 +83,6 @@ namespace CalamityMod.Projectiles.Typeless // Emit some light Lighting.AddLight(Projectile.Center, bColor.ToVector3() * 0.65f); - if (SoundEngine.TryGetActiveSound(soundSlot, out var sound) && sound.IsPlaying) - sound.Position = Projectile.Center; - if (idle) // Following Ai { if (time == 0 && visuals) // On spawn fx @@ -124,22 +118,12 @@ namespace CalamityMod.Projectiles.Typeless Projectile.velocity *= 0.985f; if (!outOfRange) Projectile.velocity = Projectile.velocity.RotatedBy(0.0065f * (energyNumber % 2 == 0 ? -1 : 1)) * 1.004f; - - if (soundCooldown == 0 && Main.rand.NextBool(4500 * Projectile.MaxUpdates) && visuals && time > 18000 * Projectile.MaxUpdates && !Main.dedServ) // Sounds are an easter egg that only plays if they've been alive for over 5 minutes - { - SoundStyle certainlyNotADeadChild = new("CalamityMod/Sounds/Item/AmuletVox", 6); - soundSlot = SoundEngine.PlaySound(certainlyNotADeadChild with { Volume = 0.3f, Pitch = Main.rand.NextFloat(-0.1f, 0.1f), MaxInstances = -1 }, Projectile.Center); - soundCooldown = 800 * Projectile.MaxUpdates; - } - if (soundCooldown > 0) - soundCooldown--; } else Projectile.velocity *= 0.99f; } else // Attack/Healing Ai { - soundCooldown = 0; if (Projectile.ai[2] == 5) // Effects for the moment they stop being idle { Projectile.netUpdate = true; @@ -209,13 +193,13 @@ namespace CalamityMod.Projectiles.Typeless GeneralParticleHandler.SpawnParticle(fadeInfx); } - Projectile.scale = MathHelper.Lerp(Projectile.scale, spoke ? 0.9f : 0.5f, 0.1f); + Projectile.scale = MathHelper.Lerp(Projectile.scale, 0.5f, 0.1f); Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; time++; } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { - target.AddBuff(ModContent.BuffType(), 420); + target.AddBuff(ModContent.BuffType(), 180); Projectile.netUpdate = true; } public override void OnKill(int timeLeft) diff --git a/Projectiles/Typeless/BabyCannonballProjectile.cs b/Projectiles/Typeless/BabyCannonballProjectile.cs index 2dcca5f59d..81dd4c3a93 100644 --- a/Projectiles/Typeless/BabyCannonballProjectile.cs +++ b/Projectiles/Typeless/BabyCannonballProjectile.cs @@ -92,7 +92,7 @@ namespace CalamityMod.Projectiles.Ranged SoundEngine.PlaySound(SoundID.Item88, Projectile.Center); if (Projectile.owner == Main.myPlayer) { - int p = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); + int p = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage / 2, Projectile.knockBack, Projectile.owner); Main.projectile[p].DamageType = DamageClass.Default; } // Circular spread of clouds and bubbles for impact diff --git a/Projectiles/Typeless/BossRushTier1Animation.png b/Projectiles/Typeless/BossRushTier1Animation.png new file mode 100644 index 0000000000..6077956ffa Binary files /dev/null and b/Projectiles/Typeless/BossRushTier1Animation.png differ diff --git a/Projectiles/Typeless/BossRushTier2Animation.png b/Projectiles/Typeless/BossRushTier2Animation.png index 93fb86bb54..3e347e15e4 100644 Binary files a/Projectiles/Typeless/BossRushTier2Animation.png and b/Projectiles/Typeless/BossRushTier2Animation.png differ diff --git a/Projectiles/Typeless/BossRushTier3Animation.png b/Projectiles/Typeless/BossRushTier3Animation.png index 5a3205be0f..81d46b2f13 100644 Binary files a/Projectiles/Typeless/BossRushTier3Animation.png and b/Projectiles/Typeless/BossRushTier3Animation.png differ diff --git a/Projectiles/Typeless/BossRushTier4Animation.png b/Projectiles/Typeless/BossRushTier4Animation.png index fc2e379198..e618c7f68e 100644 Binary files a/Projectiles/Typeless/BossRushTier4Animation.png and b/Projectiles/Typeless/BossRushTier4Animation.png differ diff --git a/Projectiles/Typeless/BossRushTier5Animation.png b/Projectiles/Typeless/BossRushTier5Animation.png index 60fb8d4ba2..126b93d1db 100644 Binary files a/Projectiles/Typeless/BossRushTier5Animation.png and b/Projectiles/Typeless/BossRushTier5Animation.png differ diff --git a/Projectiles/Typeless/BossRushTierAnimation.cs b/Projectiles/Typeless/BossRushTierAnimation.cs index 6ff92afbb9..12ae28607c 100644 --- a/Projectiles/Typeless/BossRushTierAnimation.cs +++ b/Projectiles/Typeless/BossRushTierAnimation.cs @@ -16,14 +16,14 @@ namespace CalamityMod.Projectiles.Typeless public const int FrameChangeRate = 4; - public const int TotalFrames = 56; + public const int TotalFrames = 41; - public override string Texture => "CalamityMod/Projectiles/Typeless/BossRushTier2Animation"; + public override string Texture => "CalamityMod/Projectiles/Typeless/BossRushTier1Animation"; public override void SetDefaults() { - Projectile.width = 76; - Projectile.height = 180; + Projectile.width = 62; + Projectile.height = 64; Projectile.aiStyle = -1; Projectile.ignoreWater = true; Projectile.tileCollide = false; @@ -45,6 +45,10 @@ namespace CalamityMod.Projectiles.Typeless float volume = 2.8f; switch (Tier) { + // Tier 1 doesn't have its own sound yet. + case 1: + SoundEngine.PlaySound(Tier2TransitionSound with { Volume = volume }, Main.LocalPlayer.Center); + break; case 2: SoundEngine.PlaySound(Tier2TransitionSound with { Volume = volume }, Main.LocalPlayer.Center); break; @@ -67,7 +71,7 @@ namespace CalamityMod.Projectiles.Typeless public override bool PreDraw(ref Color lightColor) { Texture2D texture = ModContent.Request($"CalamityMod/Projectiles/Typeless/BossRushTier{Tier}Animation").Value; - Rectangle frame = texture.Frame(14, 4, Projectile.frame % 14, Projectile.frame / 14); + Rectangle frame = texture.Frame(TotalFrames, 1, Projectile.frame % TotalFrames, Projectile.frame / TotalFrames); Vector2 origin = frame.Size() * 0.5f; Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition, frame, Projectile.GetAlpha(lightColor), 0f, origin, Projectile.scale, 0, 0f); return false; diff --git a/Projectiles/Typeless/ClaretCannonProj.cs b/Projectiles/Typeless/ClaretCannonProj.cs index 0a67da9052..07f5e54899 100644 --- a/Projectiles/Typeless/ClaretCannonProj.cs +++ b/Projectiles/Typeless/ClaretCannonProj.cs @@ -1,12 +1,14 @@ using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Items.Weapons.Typeless; +using CalamityMod.Particles; +using CalamityMod.Projectiles.Healing; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; +using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; -using CalamityMod.Items.Weapons.Typeless; -using CalamityMod.Projectiles.Healing; -using CalamityMod.Particles; namespace CalamityMod.Projectiles.Typeless { @@ -37,6 +39,7 @@ namespace CalamityMod.Projectiles.Typeless { Collision.HitTiles(Projectile.position, Projectile.velocity, Projectile.width, Projectile.height); SoundEngine.PlaySound(SoundID.Dig, Projectile.position); + Projectile.netUpdate = true; return true; } @@ -46,33 +49,61 @@ namespace CalamityMod.Projectiles.Typeless return; SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/NPCKilled/PerfLargeDeath") { Volume = 0.5f }, Projectile.Center); SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/BloodPactCrit") { Volume = 0.5f }, Projectile.Center); + float particleScale = 8f; + Particle bloodsplosion = new CustomPulse(Projectile.Center, Vector2.Zero, (!ChildSafety.Disabled ? Color.CornflowerBlue : Color.DarkRed), "CalamityMod/Particles/DetailedExplosion", Vector2.One, Main.rand.NextFloat(-15f, 15f), 0.16f * particleScale / 5f, 0.87f * particleScale / 5f, (int)(40 * 0.38f), false); + GeneralParticleHandler.SpawnParticle(bloodsplosion); + Particle bloodsplosion2 = new CustomPulse(Projectile.Center, Vector2.Zero, (!ChildSafety.Disabled ? Color.CornflowerBlue : new Color(255, 32, 32)), "CalamityMod/Particles/DustyCircleHardEdge", Vector2.One, Main.rand.NextFloat(-15f, 15f), 0.03f * particleScale / 5f, 0.155f * particleScale / 5f, 40); + GeneralParticleHandler.SpawnParticle(bloodsplosion2); + Projectile.netUpdate = true; } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - target.AddBuff(ModContent.BuffType(), ClaretCannon.ClaretCooldownMax / 2); - target.AddBuff(BuffID.BetsysCurse, ClaretCannon.ClaretCooldownMax); + var player = Main.player[Projectile.owner]; + + int cooldown = 600; + if (player.HeldItem.ModItem is IClaretCannonInstance cooldownWeapon) + cooldown = cooldownWeapon.CooldownMax; + + target.AddBuff(ModContent.BuffType(), cooldown / 2); + target.AddBuff(BuffID.BetsysCurse, cooldown); + if (Projectile.penetrate == -1) return; - var player = Main.player[Projectile.owner]; - float orbCount = 20; - for (var i = 0; i < orbCount; i++) + + for (var i = 0; i < 20; i++) { Projectile.NewProjectile(Projectile.GetSource_OnHit(target), Projectile.Center, -Projectile.velocity.SafeNormalize(Vector2.Zero).RotatedByRandom(1) * Main.rand.NextFloat(2.75f, 5.25f), ModContent.ProjectileType(), 20, 0f, player.whoAmI); } - Projectile.position = Projectile.Center; - Projectile.Size = new Vector2(352); - Projectile.Center = Projectile.position; - Projectile.penetrate = -1; - Projectile.extraUpdates = 0; - Projectile.timeLeft = 2; - Projectile.velocity *= 0; - Projectile.damage /= 2; - float particleScale = 8f; - Particle bloodsplosion = new CustomPulse(Projectile.Center, Vector2.Zero, Color.DarkRed, "CalamityMod/Particles/DetailedExplosion", Vector2.One, Main.rand.NextFloat(-15f, 15f), 0.16f*particleScale/5f, 0.87f * particleScale / 5f, (int)(40 * 0.38f), false); - GeneralParticleHandler.SpawnParticle(bloodsplosion); - Particle bloodsplosion2 = new CustomPulse(Projectile.Center, Vector2.Zero, new Color(255, 32, 32), "CalamityMod/Particles/DustyCircleHardEdge", Vector2.One, Main.rand.NextFloat(-15f, 15f), 0.03f * particleScale / 5f, 0.155f * particleScale / 5f, 40); - GeneralParticleHandler.SpawnParticle(bloodsplosion2); + + Projectile.position = Projectile.Center; + Projectile.Size = new Vector2(352); + Projectile.Center = Projectile.position; + Projectile.penetrate = -1; + Projectile.extraUpdates = 0; + Projectile.timeLeft = 2; + Projectile.velocity *= 0; + Projectile.damage /= 2; + Projectile.netUpdate = true; + } + + public override bool PreDraw(ref Color lightColor) + { + if (ChildSafety.Disabled) + { + return base.PreDraw(ref lightColor); + } + + Texture2D texture = TextureAssets.Projectile[Projectile.type].Value; + int frameHeight = texture.Height / Main.projFrames[Projectile.type]; + int startY = frameHeight * Projectile.frame; + Rectangle sourceRectangle = new Rectangle(0, startY, texture.Width, frameHeight); + Vector2 origin = sourceRectangle.Size() / 2f; + Color drawColor = Color.CornflowerBlue; + drawColor *= Projectile.Opacity; + + Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), sourceRectangle, drawColor, Projectile.rotation, origin, Projectile.scale, SpriteEffects.None, 0); + return false; } } -} \ No newline at end of file +} diff --git a/Projectiles/Typeless/DirectStrike.cs b/Projectiles/Typeless/DirectStrike.cs index e56d3cd89a..b29d83d206 100644 --- a/Projectiles/Typeless/DirectStrike.cs +++ b/Projectiles/Typeless/DirectStrike.cs @@ -9,10 +9,14 @@ namespace CalamityMod.Projectiles.Typeless public new string LocalizationCategory => "Projectiles.Typeless"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; public bool invalidTarget => (Projectile.ai[0] < 0f || Projectile.ai[0] > 199f); - public Vector2 pushVelocity => new Vector2(Projectile.ai[1], Projectile.ai[2]); - // You can set projectile.ai 1 & 2 to the x and y velocity that you would like to launch the target, even if the direct strike deals no damage - public bool hasStongDisplacement = false; // If you set Knockback to anything below zero, the custom knockback will be able to effect enemies that normally ignore knockback + // You can set Projectile AI 1 & 2 to the X/Y velocity that you would like to launch the target, even if the direct strike deals no damage. + // This lets Direct Strikes be used as "Direct Nudges" which deal no damage but push something around. + public Vector2 pushVelocity => new(Projectile.ai[1], Projectile.ai[2]); + + // If you set Knockback to anything below zero, the custom knockback will be able to effect enemies that normally ignore knockback + public bool hasStongDisplacement = false; + public override void SetDefaults() { Projectile.width = 2; @@ -25,6 +29,7 @@ namespace CalamityMod.Projectiles.Typeless Projectile.alpha = 255; Projectile.timeLeft = 2; } + public override void AI() { if (Projectile.knockBack < 0) @@ -34,6 +39,7 @@ namespace CalamityMod.Projectiles.Typeless } // If the target is moving VERY fast, direct strikes spawned on top of them can actually miss + // Setting a target will guarantee hits on said target by teleporting the projectile onto their center every frame // Setting a target will guarantee hits on said target by teleporting the projectile onto them every frame if (!invalidTarget) Projectile.Center = Main.npc[(int)Projectile.ai[0]].Center; diff --git a/Projectiles/Typeless/Luxor.cs b/Projectiles/Typeless/Luxor.cs index ddafd4ff7b..024fc70532 100644 --- a/Projectiles/Typeless/Luxor.cs +++ b/Projectiles/Typeless/Luxor.cs @@ -135,11 +135,6 @@ namespace CalamityMod.Projectiles.Typeless case 5: attackSpeed = LuxorsGift.rogueAttackSpeed; attackDamage = LuxorsGift.rogueDamage; projType = ModContent.ProjectileType(); break; } float powerMult = Utils.GetLerpValue(-120, 140, attackSpeed, true); // An intensity multiplier based on the fire rate of the mode - if (Main.zenithWorld) // Just like old times - { - attackSpeed = 0; - attackDamage = Math.Max(1, (int)(Owner.HeldItem.damage * Utils.Remap(Owner.HeldItem.useAnimation, 3, 120, 0.025f, 1f, false))); - } for (int i = 0; i < (int)(20 * powerMult); i++) // Firing dust { diff --git a/Projectiles/Typeless/PlaguePulse.cs b/Projectiles/Typeless/PlaguePulse.cs index fb430aa6e8..61c02f920e 100644 --- a/Projectiles/Typeless/PlaguePulse.cs +++ b/Projectiles/Typeless/PlaguePulse.cs @@ -64,6 +64,11 @@ namespace CalamityMod.Projectiles.Typeless } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { + Player Owner = Main.player[Projectile.owner]; + bool crit = Main.rand.Next(0, 100 + 1) < Owner.GetTotalCritChance(Owner.GetBestClass()); + if (crit) + modifiers.SetCrit(); + float minMult = 0.4f; int hitsToMinMult = 6; float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true); diff --git a/Projectiles/Typeless/StratusBlackHole.cs b/Projectiles/Typeless/StratusBlackHole.cs index 032903d270..b803f42dfa 100644 --- a/Projectiles/Typeless/StratusBlackHole.cs +++ b/Projectiles/Typeless/StratusBlackHole.cs @@ -59,7 +59,7 @@ namespace CalamityMod.Projectiles.Typeless } foreach (var player in Main.ActivePlayers) { - if (player.Distance(Projectile.Center) <= 600) + if (player.Distance(Projectile.Center) <= 600 && !player.dead) { if (player.miscCounter % 30 == 15) { @@ -68,7 +68,7 @@ namespace CalamityMod.Projectiles.Typeless player.Calamity().StarburstEntities.Add(new StarburstEntity(Projectile.Center)); player.Calamity().StratusStarburstResetTimer = (int)MathHelper.Max(player.Calamity().StratusStarburstResetTimer, 180); } - if (player.wingsLogic > 0) + if (player.wingsLogic > 0 && player.wingTimeMax > 0) { if (player.wingTime <= 0 && player.Calamity().AvaliableStarburst > 0) { diff --git a/Projectiles/Typeless/TerminusHoldout.cs b/Projectiles/Typeless/TerminusHoldout.cs index c444e4d74e..52a48fc9ba 100644 --- a/Projectiles/Typeless/TerminusHoldout.cs +++ b/Projectiles/Typeless/TerminusHoldout.cs @@ -28,8 +28,8 @@ namespace CalamityMod.Projectiles.Typeless public override void SetDefaults() { - Projectile.width = 50; - Projectile.height = 50; + Projectile.width = 70; + Projectile.height = 80; Projectile.aiStyle = -1; Projectile.ignoreWater = true; Projectile.tileCollide = false; @@ -130,6 +130,8 @@ namespace CalamityMod.Projectiles.Typeless int dustCount = (int)Math.Round(MathHelper.SmoothStep(1f, 5f, Time / Lifetime)); float outwardness = MathHelper.SmoothStep(40f, 150f, Time / Lifetime); float dustScale = MathHelper.Lerp(1.15f, 1.725f, Time / Lifetime); + float colorTime = Time / Lifetime * Main.rand.NextFloat(0.65f, 1f); + for (int i = 0; i < dustCount; i++) { Vector2 spawnPosition = Projectile.Center + Main.rand.NextVector2Unit() * outwardness * Main.rand.NextFloat(0.75f, 1.1f); @@ -138,7 +140,7 @@ namespace CalamityMod.Projectiles.Typeless Dust paleMagic = Dust.NewDustPerfect(spawnPosition, DustID.PortalBoltTrail); paleMagic.velocity = dustVelocity; paleMagic.scale = dustScale * Main.rand.NextFloat(0.75f, 1.15f); - paleMagic.color = Color.Lerp(Color.LightCoral, Color.White, Time / Lifetime * Main.rand.NextFloat(0.65f, 1f)); + paleMagic.color = Main.zenithWorld ? Color.Lerp(Color.LightCoral, Color.White, colorTime) : Color.Lerp(Color.Violet, Color.Goldenrod, colorTime); paleMagic.noGravity = true; paleMagic.noLight = true; } @@ -169,8 +171,8 @@ namespace CalamityMod.Projectiles.Typeless SpriteEffects direction = Projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; if (Time >= 150f) { - float outwardness = MathHelper.SmoothStep(1f, 15f, Utils.GetLerpValue(150f, Lifetime - 30f, Time, true)); - Color afterimageColor = Color.Lerp(baseColor, Color.LightCoral, Utils.GetLerpValue(150f, 195f, Time, true)) * 0.225f; + float outwardness = MathHelper.SmoothStep(0f, 12f, Utils.GetLerpValue(150f, Lifetime - 30f, Time, true)); + Color afterimageColor = Color.Lerp(baseColor, Color.PaleGoldenrod, Utils.GetLerpValue(150f, 195f, Time, true)) * 0.225f; afterimageColor.A = 0; for (int i = 0; i < 10; i++) @@ -179,9 +181,34 @@ namespace CalamityMod.Projectiles.Typeless Main.EntitySpriteDraw(texture, baseDrawPosition + drawOffset, null, afterimageColor, 0f, origin, Projectile.scale, direction, 0); } } - Main.EntitySpriteDraw(texture, baseDrawPosition, null, baseColor, 0f, origin, Projectile.scale, direction, 0); + Main.EntitySpriteDraw(texture, baseDrawPosition, null, baseColor, 0f, origin, Projectile.scale, direction, 0); return false; } + + public override void PostDraw(Color lightColor) + { + if (Main.zenithWorld) + return; + + Texture2D texture = ModContent.Request("CalamityMod/Items/SummonItems/TerminusGlow").Value; + Vector2 baseDrawPosition = Projectile.Center - Main.screenPosition; + Vector2 origin = texture.Size() * 0.5f; + SpriteEffects direction = Projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; + + if (Time >= 75f) + { + float outwardness = MathHelper.SmoothStep(0f, 4f, Utils.GetLerpValue(75f, Lifetime - 30f, Time, true)); + + for (int i = 0; i < 3; i++) + { + Vector2 drawOffset = (MathHelper.TwoPi * i / 4f + Main.GlobalTimeWrappedHourly * 4.4f).ToRotationVector2() * outwardness; + + Main.EntitySpriteDraw(texture, baseDrawPosition + drawOffset, null, new Color(56, 12, 115, 0), 0f, origin, Projectile.scale, direction, 0); + } + } + + Main.EntitySpriteDraw(texture, baseDrawPosition, null, Color.White, 0f, origin, Projectile.scale, direction, 0); + } } } diff --git a/Projectiles/Typeless/UrsaSlash.cs b/Projectiles/Typeless/UrsaSlash.cs index 0407ca2cce..d4cc885cea 100644 --- a/Projectiles/Typeless/UrsaSlash.cs +++ b/Projectiles/Typeless/UrsaSlash.cs @@ -1,4 +1,5 @@ -using CalamityMod.Particles; +using CalamityMod.Dusts; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -11,7 +12,7 @@ namespace CalamityMod.Projectiles.Typeless public new string LocalizationCategory => "Projectiles.Typeless"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; public Player Owner => Main.player[Projectile.owner]; - private static float radius = 65f; + private static float radius = 85f; public bool visuals = true; public override void SetDefaults() @@ -32,46 +33,50 @@ namespace CalamityMod.Projectiles.Typeless { bool visible = Owner.Calamity().ursaSergeantVisual; Vector2 slashDir = new Vector2(13, 13).RotatedByRandom(100); - Vector2 slashPos1 = Projectile.Center + slashDir.RotatedBy(MathHelper.ToRadians(90f)); - Vector2 slashPos2 = Projectile.Center + slashDir.RotatedBy(MathHelper.ToRadians(-90f)); + Vector2 slashPos1 = Projectile.Center + slashDir.RotatedBy(MathHelper.ToRadians(90f) * 1.25f); + Vector2 slashPos2 = Projectile.Center + slashDir.RotatedBy(MathHelper.ToRadians(-90f) * 1.25f); + Owner.SetScreenshake(4f); for (int i = 0; i < 3; i++) { - Particle bigSpark = new GlowSparkParticle(Projectile.Center - slashDir * 6, slashDir * 0.65f, false, 19, 0.07f * (1 - i * 0.25f), Color.Coral * (visible ? 1 : 0.3f), new Vector2(1.9f, 1), true, false, 0.7f); + Particle bigSpark = new GlowSparkParticle(Projectile.Center - slashDir * 6, slashDir * 0.65f, false, 19, 0.085f * (1 - i * 0.25f), Color.Coral * (visible ? 1 : 0.3f), new Vector2(1.9f, 1), true, false, 0.7f); GeneralParticleHandler.SpawnParticle(bigSpark); - Particle spark1 = new GlowSparkParticle(slashPos1 - slashDir * 6, slashDir * 0.65f, false, 19, 0.052f * (1 - i * 0.25f), Color.DarkTurquoise * (visible ? 1 : 0.3f), new Vector2(1.9f, 1), true, false, 0.7f); + Particle spark1 = new GlowSparkParticle(slashPos1 - slashDir * 6, slashDir.RotatedBy(0.06f) * 0.65f, false, 19, 0.067f * (1 - i * 0.25f), Color.DarkTurquoise * (visible ? 1 : 0.3f), new Vector2(1.9f, 1), true, false, 0.7f); GeneralParticleHandler.SpawnParticle(spark1); - Particle spark2 = new GlowSparkParticle(slashPos2 - slashDir * 6, slashDir * 0.65f, false, 19, 0.052f * (1 - i * 0.25f), Color.DarkTurquoise * (visible ? 1 : 0.3f), new Vector2(1.9f, 1), true, false, 0.7f); + Particle spark2 = new GlowSparkParticle(slashPos2 - slashDir * 6, slashDir.RotatedBy(-0.06f) * 0.65f, false, 19, 0.067f * (1 - i * 0.25f), Color.DarkTurquoise * (visible ? 1 : 0.3f), new Vector2(1.9f, 1), true, false, 0.7f); GeneralParticleHandler.SpawnParticle(spark2); } for (int i = 0; i <= 9; i++) { - int dustStyle = Main.rand.NextBool() ? 66 : 263; + int dustStyle = ModContent.DustType(); Dust dust = Dust.NewDustPerfect(Projectile.Center - slashDir * 6, dustStyle); - dust.scale = Main.rand.NextFloat(0.6f, 1.2f) * (visible ? 1 : 0.3f); + dust.scale = Main.rand.NextFloat(0.8f, 1.7f) * (visible ? 1 : 0.3f) * (Main.rand.NextBool(5) ? 1.5f : 1); dust.velocity = slashDir.RotatedByRandom(0.05f) * Main.rand.NextFloat(0.3f, 2); dust.noGravity = true; dust.color = Color.Coral; + dust.fadeIn = 0.5f; if (!visible) { dust.noLight = true; dust.noLightEmittence = true; } Dust dust2 = Dust.NewDustPerfect(slashPos1 - slashDir * 6, dustStyle); - dust2.scale = Main.rand.NextFloat(0.6f, 1.2f) * (visible ? 1 : 0.3f); + dust2.scale = Main.rand.NextFloat(0.8f, 1.7f) * (visible ? 1 : 0.3f) * (Main.rand.NextBool(5) ? 1.5f : 1); dust2.velocity = slashDir.RotatedByRandom(0.05f) * Main.rand.NextFloat(0.3f, 2); dust2.noGravity = true; dust2.color = Color.DarkTurquoise; + dust2.fadeIn = 0.5f; if (!visible) { dust2.noLight = true; dust2.noLightEmittence = true; } Dust dust3 = Dust.NewDustPerfect(slashPos2 - slashDir * 6, dustStyle); - dust3.scale = Main.rand.NextFloat(0.6f, 1.2f) * (visible ? 1 : 0.3f); + dust3.scale = Main.rand.NextFloat(0.8f, 1.7f) * (visible ? 1 : 0.3f) * (Main.rand.NextBool(5) ? 1.5f : 1); dust3.velocity = slashDir.RotatedByRandom(0.05f) * Main.rand.NextFloat(0.3f, 2); dust3.noGravity = true; dust3.color = Color.DarkTurquoise; + dust3.fadeIn = 0.5f; if (!visible) { dust3.noLight = true; @@ -82,7 +87,7 @@ namespace CalamityMod.Projectiles.Typeless if (visible) { SoundStyle sound = new("CalamityMod/Sounds/Item/AstralSlash", 3); - SoundEngine.PlaySound(sound with { Volume = 0.45f }, Projectile.Center); + SoundEngine.PlaySound(sound with { Volume = 0.65f }, Projectile.Center); SoundStyle sound2 = new("CalamityMod/Sounds/NPCHit/PerfLargeHit", 3); SoundEngine.PlaySound(sound2 with { Volume = 0.85f, Pitch = Main.rand.NextFloat(0.4f, 0.5f) }, Projectile.Center); } diff --git a/Projectiles/Typeless/XykWings.cs b/Projectiles/Typeless/XykWings.cs index bdf7d597cd..2cf9792eb1 100644 --- a/Projectiles/Typeless/XykWings.cs +++ b/Projectiles/Typeless/XykWings.cs @@ -275,17 +275,17 @@ namespace CalamityMod.Projectiles.Typeless float height = 1; Texture2D tex; if (wingNum == 0) - tex = ModContent.Request("CalamityMod/Particles/XykWing2").Value; + tex = moddedOwner.XykVisualsOrange ? ModContent.Request("CalamityMod/Particles/XykWingOrange2").Value : ModContent.Request("CalamityMod/Particles/XykWingBlue2").Value; else if (wingNum == topWingNum || iAmTopWing) { height = 1.5f; - tex = ModContent.Request("CalamityMod/Particles/XykWing1").Value; + tex = moddedOwner.XykVisualsOrange ? ModContent.Request("CalamityMod/Particles/XykWingOrange1").Value : ModContent.Request("CalamityMod/Particles/XykWingBlue1").Value; } else { width = 2; height = 1f + 0.1f * wingNum; - tex = ModContent.Request("CalamityMod/Particles/XykWing3").Value; + tex = moddedOwner.XykVisualsOrange ? ModContent.Request("CalamityMod/Particles/XykWingOrange3").Value : ModContent.Request("CalamityMod/Particles/XykWingBlue3").Value; } Texture2D glow = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; diff --git a/README.md b/README.md index fe22891c7f..694b01251b 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Calamity Mod [![Discord](https://img.shields.io/discord/225030931008847874)](https://discord.gg/calamity) - [Official site](https://calamitymod.com/) -- [Steam Workshop](https://calamitymod.com/download/) +- [Steam Workshop](https://steamcommunity.com/sharedfiles/filedetails/?id=2824688072) - [Discord](https://discord.gg/calamity) - [Official Wiki](https://calamitymod.wiki.gg/) - [Patreon](https://patreon.com/CalamityMod) @@ -12,6 +12,8 @@ The Calamity Mod is a vast content mod for Terraria which adds dozens of bosses Active development by Calamity developers occurs on a separate, private repository. Contributions made here will be cherry picked into that repository. When an update is released to the Steam Workshop, the `1.4.4-release` branch is replaced with the matching branch from the private repository. +Issues are disabled on this repository. To report a bug, please join the [Calamity Discord](https://discord.gg/calamity) and use the `#bug-reports-read-pins` forum therein. + Please do not submit resprites via pull requests. Instead, go to the [Calamity Art Discord](https://discord.gg/CKByxd5) and use the Asset Submission system if you want to propose a resprite for Calamity. **Do not redistribute the Calamity Mod.** Creating your own builds of the mod from an in-development sourcetree will cause confusion in the community and will make players' mods fail to sync in multiplayer. We will take down any copies of the Calamity Mod published to Steam Workshop or rehosted elsewhere, and reserve the right to take legal action as we see fit. \ No newline at end of file diff --git a/Sounds/Custom/BrainOfCthulhu/BoC_Rev_BloodBomb.ogg b/Sounds/Custom/BrainOfCthulhu/BoC_Rev_BloodBomb.ogg new file mode 100644 index 0000000000..27b0983094 Binary files /dev/null and b/Sounds/Custom/BrainOfCthulhu/BoC_Rev_BloodBomb.ogg differ diff --git a/Sounds/Item/AmuletVox1.ogg b/Sounds/Item/AmuletVox1.ogg deleted file mode 100644 index af09bedf93..0000000000 Binary files a/Sounds/Item/AmuletVox1.ogg and /dev/null differ diff --git a/Sounds/Item/AmuletVox2.ogg b/Sounds/Item/AmuletVox2.ogg deleted file mode 100644 index 631d38c19c..0000000000 Binary files a/Sounds/Item/AmuletVox2.ogg and /dev/null differ diff --git a/Sounds/Item/AmuletVox3.ogg b/Sounds/Item/AmuletVox3.ogg deleted file mode 100644 index 933fea04ad..0000000000 Binary files a/Sounds/Item/AmuletVox3.ogg and /dev/null differ diff --git a/Sounds/Item/AmuletVox4.ogg b/Sounds/Item/AmuletVox4.ogg deleted file mode 100644 index 6d3ec52bcb..0000000000 Binary files a/Sounds/Item/AmuletVox4.ogg and /dev/null differ diff --git a/Sounds/Item/AmuletVox5.ogg b/Sounds/Item/AmuletVox5.ogg deleted file mode 100644 index 77888a2106..0000000000 Binary files a/Sounds/Item/AmuletVox5.ogg and /dev/null differ diff --git a/Sounds/Item/AmuletVox6.ogg b/Sounds/Item/AmuletVox6.ogg deleted file mode 100644 index 7f7ae9060d..0000000000 Binary files a/Sounds/Item/AmuletVox6.ogg and /dev/null differ diff --git a/Sounds/Item/NanoblackReaper/NanoblackReaper_LightspeedMiss.ogg b/Sounds/Item/NanoblackReaper/NanoblackReaper_LightspeedMiss.ogg new file mode 100644 index 0000000000..a89ba6b8f9 Binary files /dev/null and b/Sounds/Item/NanoblackReaper/NanoblackReaper_LightspeedMiss.ogg differ diff --git a/Sounds/Item/NanoblackReaper/NanoblackReaper_LightspeedMissPerfect.ogg b/Sounds/Item/NanoblackReaper/NanoblackReaper_LightspeedMissPerfect.ogg new file mode 100644 index 0000000000..8405606f08 Binary files /dev/null and b/Sounds/Item/NanoblackReaper/NanoblackReaper_LightspeedMissPerfect.ogg differ diff --git a/Sounds/Item/NanoblackReaper/NanoblackReaper_LightspeedSlash.ogg b/Sounds/Item/NanoblackReaper/NanoblackReaper_LightspeedSlash.ogg new file mode 100644 index 0000000000..2bdc2ef4a5 Binary files /dev/null and b/Sounds/Item/NanoblackReaper/NanoblackReaper_LightspeedSlash.ogg differ diff --git a/Sounds/Item/NanoblackReaper/NanoblackReaper_LightspeedSlash1.ogg b/Sounds/Item/NanoblackReaper/NanoblackReaper_LightspeedSlash1.ogg new file mode 100644 index 0000000000..9c17995bb9 Binary files /dev/null and b/Sounds/Item/NanoblackReaper/NanoblackReaper_LightspeedSlash1.ogg differ diff --git a/Sounds/Item/NanoblackReaper/NanoblackReaper_LightspeedSlash2.ogg b/Sounds/Item/NanoblackReaper/NanoblackReaper_LightspeedSlash2.ogg new file mode 100644 index 0000000000..e1d047b075 Binary files /dev/null and b/Sounds/Item/NanoblackReaper/NanoblackReaper_LightspeedSlash2.ogg differ diff --git a/Sounds/Item/NanoblackReaper/NanoblackReaper_LightspeedSlash3.ogg b/Sounds/Item/NanoblackReaper/NanoblackReaper_LightspeedSlash3.ogg new file mode 100644 index 0000000000..586ddc1952 Binary files /dev/null and b/Sounds/Item/NanoblackReaper/NanoblackReaper_LightspeedSlash3.ogg differ diff --git a/Sounds/Item/NanoblackReaper/NanoblackReaper_PerfectLightspeedSlash.ogg b/Sounds/Item/NanoblackReaper/NanoblackReaper_PerfectLightspeedSlash.ogg new file mode 100644 index 0000000000..562c3a70ef Binary files /dev/null and b/Sounds/Item/NanoblackReaper/NanoblackReaper_PerfectLightspeedSlash.ogg differ diff --git a/Systems/Collections/CalamityProjectileSets.cs b/Systems/Collections/CalamityProjectileSets.cs index 740bf59a91..8d0d52a1c7 100644 --- a/Systems/Collections/CalamityProjectileSets.cs +++ b/Systems/Collections/CalamityProjectileSets.cs @@ -47,8 +47,8 @@ namespace CalamityMod.Systems.Collections /// Used to allow the projectile to inflict Plague while wearing the Plaguebringer armor.
/// Defaults to . ///
- public static bool[] IsFriendlyBeeProjectile = Factory.CreateBoolSet(ProjectileID.GiantBee, ProjectileID.Bee, ProjectileID.Wasp, ProjectileType(), - ProjectileType(), ProjectileType(), ProjectileType()); + public static bool[] IsFriendlyBeeProjectile = Factory.CreateBoolSet(ProjectileID.GiantBee, ProjectileID.Bee, ProjectileID.Wasp, ProjectileID.Hornet,ProjectileID.HornetStinger, ProjectileType(), + ProjectileType(), ProjectileType(), ProjectileType(), ProjectileType(), ProjectileType()); /// /// If for a projectile type, then that projectile is a bomb or other explosive which is not a weapon.
diff --git a/Systems/Mechanic/RecipeSystem.cs b/Systems/Mechanic/RecipeSystem.cs index 71e7665c26..aa54ab889f 100644 --- a/Systems/Mechanic/RecipeSystem.cs +++ b/Systems/Mechanic/RecipeSystem.cs @@ -1347,7 +1347,7 @@ namespace CalamityMod.Systems r = Recipe.Create(ItemID.Bacon); r.AddIngredient(); - r.AddTile(TileID.Hellforge); + r.AddTile(TileID.CookingPots); r.Register(); r.DisableDecraft(); } @@ -1512,7 +1512,7 @@ namespace CalamityMod.Systems r = Recipe.Create(ItemID.WaterWalkingBoots); r.AddIngredient(ItemID.Leather, 5); r.AddIngredient(ItemID.WaterWalkingPotion, 5); - r.AddTile(TileID.Anvils); + r.AddTile(TileID.Loom); r.Register(); // Lava Charm diff --git a/Systems/UIManagementSystem.cs b/Systems/UIManagementSystem.cs index 6b32e4a2f1..337623ac94 100644 --- a/Systems/UIManagementSystem.cs +++ b/Systems/UIManagementSystem.cs @@ -174,7 +174,7 @@ namespace CalamityMod.Systems { InvasionProgressUIManager.UpdateAndDraw(Main.spriteBatch); return true; - }, InterfaceScaleType.None)); + }, InterfaceScaleType.UI)); } } } diff --git a/Tiles/Abyss/AcidWoodTreeSapling.cs b/Tiles/Abyss/AcidWoodTreeSapling.cs index ecc1de60bf..2ebd617ecf 100644 --- a/Tiles/Abyss/AcidWoodTreeSapling.cs +++ b/Tiles/Abyss/AcidWoodTreeSapling.cs @@ -71,7 +71,7 @@ namespace CalamityMod.Tiles.Abyss { return; } - if (!WorldGen.EmptyTileCheck(i - 1, i + 1, trueStartingPositionY - 20, trueStartingPositionY, Type)) + if (!WorldGen.EmptyTileCheck(i - 1, i + 1, trueStartingPositionY - 20, trueStartingPositionY-1, Type)) { return; } diff --git a/Tiles/FurnitureExo/ExoWorkBenchTile.cs b/Tiles/FurnitureExo/ExoWorkBenchTile.cs index d77a9b53bb..fdd26e7386 100644 --- a/Tiles/FurnitureExo/ExoWorkBenchTile.cs +++ b/Tiles/FurnitureExo/ExoWorkBenchTile.cs @@ -29,11 +29,6 @@ namespace CalamityMod.Tiles.FurnitureExo num = fail ? 1 : 3; } - public override void KillMultiTile(int i, int j, int frameX, int frameY) - { - Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, 32, 16, ModContent.ItemType()); - } - public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { if (Main.tile[i, j].IsTileActuallyInvisible()) diff --git a/UI/CalamitasEnchantments/CalamitasEnchantUI.cs b/UI/CalamitasEnchantments/CalamitasEnchantUI.cs index aaf38e9686..297c26c2bd 100644 --- a/UI/CalamitasEnchantments/CalamitasEnchantUI.cs +++ b/UI/CalamitasEnchantments/CalamitasEnchantUI.cs @@ -24,7 +24,7 @@ namespace CalamityMod.UI.CalamitasEnchants public static bool CurrentlyViewing = false; - public static readonly Vector2 ReforgeUITopLeft = new Vector2(68f, 320f); + public static Vector2 ReforgeUITopLeft => new Vector2(68f, 320f) * Main.UIScale; public static readonly float ResolutionRatio = Main.screenHeight / 1440f; public static readonly SoundStyle EnchSound = new("CalamityMod/Sounds/Custom/WeaponEnchant"); diff --git a/UI/DraedonSummoning/CodebreakerUI.Communication.cs b/UI/DraedonSummoning/CodebreakerUI.Communication.cs index 223f642127..e4b9f39545 100644 --- a/UI/DraedonSummoning/CodebreakerUI.Communication.cs +++ b/UI/DraedonSummoning/CodebreakerUI.Communication.cs @@ -358,7 +358,8 @@ namespace CalamityMod.UI.DraedonSummoning // Draw and update the text scroller if there is some cut off text. Vector2 textTopLeft = selectionArea.TopLeft() + new Vector2(20f, 12f) * panelScale + Vector2.UnitY * OptionsTextVerticalOffset; - float cutoffDistance = OptionsTextHeight / GeneralScale - selectionOutline.Height; + float bottomPadding = panelScale.Y * 24f; + float cutoffDistance = OptionsTextHeight - selectionOutline.Height * panelScale.Y + bottomPadding; if (cutoffDistance > 0f && OptionsTextOpacity > 0f) { if (MouseScreenArea.Intersects(selectionArea)) @@ -476,7 +477,9 @@ namespace CalamityMod.UI.DraedonSummoning // Ensure that the player starts at the bottom of the scoller, now that new text is generating there. Texture2D dialogOutline = ModContent.Request("CalamityMod/UI/DraedonSummoning/DraedonDialogOutline").Value; Rectangle dialogArea = Utils.CenteredRectangle(selectionCenter, dialogOutline.Size() * panelScale); - DialogVerticalOffset = -DialogHeight * GeneralScale; + float scaledLineSpacing = FontAssetSystem.CodebreakerDialog.Value.LineSpacing * panelScale.Y; + bottomPadding = scaledLineSpacing * 3f; + DialogVerticalOffset = -(DialogHeight - dialogOutline.Height * panelScale.Y + bottomPadding); DialogScroller.PositionYInterpolant = 1f; if (DialogVerticalOffset > 0f) DialogVerticalOffset = 0f; @@ -579,7 +582,9 @@ namespace CalamityMod.UI.DraedonSummoning // Draw and update the text scroller if there is some cut off text. Vector2 textTopLeft = dialogArea.TopLeft() + new Vector2(20f, 14f) * panelScale; - float cutoffDistance = DialogHeight - dialogOutline.Height; + float scaledLineSpacing = FontAssetSystem.CodebreakerDialog.Value.LineSpacing * panelScale.Y; + float bottomPadding = scaledLineSpacing * 3f; + float cutoffDistance = DialogHeight - (dialogOutline.Height * panelScale.Y - bottomPadding); if (cutoffDistance > 0f && OptionsTextOpacity > 0f) { if (MouseScreenArea.Intersects(dialogArea)) diff --git a/Waters/CragsLava.cs b/Waters/CragsLava.cs index 4c9340658c..778df3f4dd 100644 --- a/Waters/CragsLava.cs +++ b/Waters/CragsLava.cs @@ -26,9 +26,6 @@ namespace CalamityMod.Waters public override void InflictDebuff(Player player, int onfireDuration) { - // Extra DoT in the lava of the crags. Negated by Flame-licked Shell. - if (!player.Calamity().flameLickedShell) - player.AddBuff(ModContent.BuffType(), 2, false); } } } diff --git a/World/Abyss.cs b/World/Abyss.cs index e36254d037..ca8dca54fe 100644 --- a/World/Abyss.cs +++ b/World/Abyss.cs @@ -245,7 +245,7 @@ namespace CalamityMod.World else { tile.TileType = (ushort)ModContent.TileType(); - tile.WallType = (ushort)ModContent.WallType(); + tile.WallType = (ushort)ModContent.WallType(); } } //basically places smaller clusters everywhere else? @@ -301,7 +301,7 @@ namespace CalamityMod.World else { tile.TileType = (ushort)ModContent.TileType(); - tile.WallType = (ushort)ModContent.WallType(); + tile.WallType = (ushort)ModContent.WallType(); } } } diff --git a/World/Planets/GrassPlanet.cs b/World/Planets/GrassPlanet.cs index c92173df46..b539c8ed55 100644 --- a/World/Planets/GrassPlanet.cs +++ b/World/Planets/GrassPlanet.cs @@ -18,8 +18,8 @@ namespace CalamityMod.World.Planets { private ushort[] oreTypes = new ushort[] { - GenVars.copper == TileID.Copper ? (Main.getGoodWorld ? TileID.Palladium : TileID.Tin) : (Main.getGoodWorld ? TileID.Cobalt : TileID.Copper), - GenVars.iron == TileID.Iron ? (Main.getGoodWorld ? TileID.Palladium : TileID.Lead) : (Main.getGoodWorld ? TileID.Cobalt : TileID.Iron) + GenVars.copper == TileID.Copper ? (Main.zenithWorld ? TileID.Palladium : TileID.Tin) : (Main.zenithWorld ? TileID.Cobalt : TileID.Copper), + GenVars.iron == TileID.Iron ? (Main.zenithWorld ? TileID.Palladium : TileID.Lead) : (Main.zenithWorld ? TileID.Cobalt : TileID.Iron) }; public override bool Place(Point origin, StructureMap structures)