diff --git a/Balancing/BalancingChangesManager.cs b/Balancing/BalancingChangesManager.cs index 3daca26a39..c36cc58ade 100644 --- a/Balancing/BalancingChangesManager.cs +++ b/Balancing/BalancingChangesManager.cs @@ -264,6 +264,9 @@ namespace CalamityMod.Balancing // 50% resist to true melee. NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.AstrumDeusIDs, Do(ResistTrueMelee(0.5f)))); + // 35% resist to Ballistic Poison Bomb's clouds. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.AstrumDeusIDs, Do(new ProjectileResistBalancingRule(0.65f, ProjectileType())))); + // 35% resist to Icicle Arrows. NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.AstrumDeusIDs, Do(new ProjectileResistBalancingRule(0.65f, ProjectileType())))); diff --git a/Balancing/BalancingConstants.cs b/Balancing/BalancingConstants.cs index dc64bb8899..4b931a4b1f 100644 --- a/Balancing/BalancingConstants.cs +++ b/Balancing/BalancingConstants.cs @@ -16,6 +16,23 @@ // Altered jump speed boost provided by Shiny Red Balloon via IL edit // This is a const because it replaces a hardcoded value in vanilla internal const float BalloonJumpSpeedBoost = 0.75f; + + // Default jump speed boost provided by Frog Leg and tinker combinations in vanilla + internal const float VanillaFrogLegJumpSpeedBoost = 1.6f; + + // Altered jump speed boost provided by Amphibian Boots via global item UpdateAccessory + internal static readonly float AmphibianBootsJumpSpeedBoost = 1f; + + // Altered movement stats provided by Shadow Armor via IL edit + // This item is modified to not stack with Magiluminescence if on the ground. If in the air, it still functions. + internal static readonly float ShadowArmorRunAccelerationMultiplier = 1.25f; // Vanilla and Magi = 1.75f + internal static readonly float ShadowArmorMaxRunSpeedMultiplier = 1.05f; // Vanilla and Magi = 1.15f + internal static readonly float ShadowArmorAccRunSpeedMultiplier = 1.05f; // Vanilla and Magi = 1.15f + internal static readonly float ShadowArmorRunSlowdownMultiplier = 1.5f; // Vanilla and Magi = 1.75f + + // Altered run acceleration multiplier provided by Soaring Insignia via IL edit + // This is a const because it replaces a hardcoded value in vanilla + internal const float SoaringInsigniaRunAccelerationMultiplier = 1.1f; // Vanilla = 1.75f #endregion #region Immunity Frames diff --git a/Buffs/DamageOverTime/Plague.cs b/Buffs/DamageOverTime/Plague.cs index defe20c5b8..f776337e36 100644 --- a/Buffs/DamageOverTime/Plague.cs +++ b/Buffs/DamageOverTime/Plague.cs @@ -36,15 +36,18 @@ namespace CalamityMod.Buffs.DamageOverTime float numberOfDusts = 2f; float rotFactor = 360f / numberOfDusts; + int particleAmt = Player.Calamity().alchFlask ? 1 : 2; + int dustSpawnAmt = Player.Calamity().alchFlask ? 4 : 7; if (Player.miscCounter % 4 == 0) { - for (int i = 0; i < 2; i++) + for (int i = 0; i < particleAmt; i++) { - DirectionalPulseRing pulse = new DirectionalPulseRing(Player.Calamity().RandomDebuffVisualSpot, Vector2.Zero, Main.rand.NextBool(3) ? Color.LimeGreen : Color.Green, new Vector2(1, 1), 0, Main.rand.NextFloat(0.07f, 0.18f), 0f, 35); + float pulseScale = Main.rand.NextFloat(Player.Calamity().alchFlask ? 0.04f : 0.07f, Player.Calamity().alchFlask ? 0.12f : 0.18f); + DirectionalPulseRing pulse = new DirectionalPulseRing(Player.Calamity().RandomDebuffVisualSpot, Vector2.Zero, Main.rand.NextBool(3) ? Color.LimeGreen : Color.Green, Vector2.One, 0, pulseScale, 0f, 20); GeneralParticleHandler.SpawnParticle(pulse); } - for (int i = 0; i < 7; i++) + for (int i = 0; i < dustSpawnAmt; i++) { int DustID = Main.rand.NextBool(30) ? 220 : 89; float rot = MathHelper.ToRadians(i * rotFactor); @@ -62,7 +65,7 @@ namespace CalamityMod.Buffs.DamageOverTime Vector2 npcSize = npc.Center + new Vector2(Main.rand.NextFloat(-npc.width / 2, npc.width / 2), Main.rand.NextFloat(-npc.height / 2, npc.height / 2)); if (Main.rand.NextBool(3)) { - DirectionalPulseRing pulse = new DirectionalPulseRing(npcSize, Vector2.Zero, Main.rand.NextBool(3) ? Color.LimeGreen : Color.Green, new Vector2(1, 1), 0, Main.rand.NextFloat(0.07f, 0.18f) + (0.0000007f * npc.width * npc.height), 0f, 35); + DirectionalPulseRing pulse = new DirectionalPulseRing(npcSize, Vector2.Zero, Main.rand.NextBool(3) ? Color.LimeGreen : Color.Green, new Vector2(1, 1), 0, Main.rand.NextFloat(0.07f, 0.18f) + (0.0000007f * npc.width * npc.height), 0f, 15); GeneralParticleHandler.SpawnParticle(pulse); for (int i = 0; i < 4; i++) diff --git a/Buffs/Placeables/CirrusPurpleCandleBuff.cs b/Buffs/Placeables/CirrusPurpleCandleBuff.cs index 1d50225a40..a56d3e179b 100644 --- a/Buffs/Placeables/CirrusPurpleCandleBuff.cs +++ b/Buffs/Placeables/CirrusPurpleCandleBuff.cs @@ -6,7 +6,7 @@ namespace CalamityMod.Buffs.Placeables { public class CirrusPurpleCandleBuff : ModBuff { - public static float DefenseRatioBonus = 0.15f; + public static float DefenseRatioBonus = 0.1f; public override void SetStaticDefaults() { diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 9d7c7fd4dd..774b08df3f 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -508,6 +508,7 @@ namespace CalamityMod.CalPlayer public bool ascendantTrail = false; public bool eGauntlet = false; public int gloveLevel = 0; // Used to prevent glove stacking + public bool alreadyHasFrogLeg = false; // Used to prevent Frog Leg tinker stacking public bool eTalisman = false; public int statisTimer = 0; public bool nucleogenesis = false; @@ -1705,6 +1706,7 @@ namespace CalamityMod.CalPlayer ascendantTrail = false; eGauntlet = false; gloveLevel = 0; + alreadyHasFrogLeg = false; eTalisman = false; nucleogenesis = false; nuclearFuelRod = false; @@ -4385,13 +4387,7 @@ namespace CalamityMod.CalPlayer Player.blockExtraJumps = true; Player.rocketBoots = 0; - Player.jumpBoost = false; - Player.slowFall = false; - Player.gravControl = false; - Player.gravControl2 = false; - Player.jumpSpeedBoost = 0f; Player.wingTimeMax = (int)(Player.wingTimeMax * 0.5); - Player.balloon = -1; } #endregion diff --git a/CalPlayer/CalamityPlayerHitHurt.cs b/CalPlayer/CalamityPlayerHitHurt.cs index 7dad272e20..7430951616 100644 --- a/CalPlayer/CalamityPlayerHitHurt.cs +++ b/CalPlayer/CalamityPlayerHitHurt.cs @@ -1172,6 +1172,8 @@ namespace CalamityMod.CalPlayer if (crawCarapace) { npc.AddBuff(ModContent.BuffType(), 900); + int onHitDamage = Player.CalcIntDamage(40); + Player.ApplyDamageToNPC(npc, onHitDamage, 0f, 0, false); SoundEngine.PlaySound(SoundID.NPCHit33 with { Volume = 0.5f }, Player.Center); } @@ -1179,6 +1181,8 @@ namespace CalamityMod.CalPlayer { npc.AddBuff(ModContent.BuffType(), 900); npc.AddBuff(ModContent.BuffType(), 900); + int onHitDamage = Player.CalcIntDamage(250); + Player.ApplyDamageToNPC(npc, onHitDamage, 0f, 0, false); SoundEngine.PlaySound(BaroclawHit, Player.Center); Vector2 bloodSpawnPosition = Player.Center + Main.rand.NextVector2Circular(Player.width, Player.height) * 0.04f; Vector2 splatterDirection = (Player.Center - bloodSpawnPosition).SafeNormalize(Vector2.UnitY); @@ -1198,6 +1202,8 @@ namespace CalamityMod.CalPlayer if (absorber) { npc.AddBuff(ModContent.BuffType(), 900); + int onHitDamage = Player.CalcIntDamage(350); + Player.ApplyDamageToNPC(npc, onHitDamage, 0f, 0, false); SoundEngine.PlaySound(AbsorberHit, Player.Center); Vector2 bloodSpawnPosition = Player.Center + Main.rand.NextVector2Circular(Player.width, Player.height) * 0.04f; Vector2 splatterDirection = (Player.Center - bloodSpawnPosition).SafeNormalize(Vector2.UnitY); @@ -1233,13 +1239,13 @@ namespace CalamityMod.CalPlayer if (Main.player[proj.owner] is null) { if (!Main.npc[proj.owner].friendly) - Main.npc[proj.owner].AddBuff(BuffID.Poisoned, 120); + Main.npc[proj.owner].AddBuff(BuffID.Poisoned, 60); } else { Player p = Main.player[proj.owner]; if (p.hostile && Player.hostile && (Player.team != p.team || p.team == 0)) - p.AddBuff(BuffID.Poisoned, 120); + p.AddBuff(BuffID.Poisoned, 60); } } @@ -1672,7 +1678,7 @@ namespace CalamityMod.CalPlayer if (blazingCoreParry > 0) //check for active parry { - if (blazingCoreParry >= 18) //only the first 12 frames (0.2 seconds) counts for a valid parry + if (blazingCoreParry >= 12) //only the first 18 frames (0.3 seconds) counts for a valid parry { if (!Player.HasCooldown(ParryCooldown.ID)) { @@ -1696,7 +1702,7 @@ namespace CalamityMod.CalPlayer } else if (flameLickedShellParry > 0) { - if (flameLickedShellParry >= 18) + if (flameLickedShellParry >= 12) { if (!Player.HasCooldown(ParryCooldown.ID)) { diff --git a/CalPlayer/CalamityPlayerLifeRegen.cs b/CalPlayer/CalamityPlayerLifeRegen.cs index 1762d11e43..c9b3239176 100644 --- a/CalPlayer/CalamityPlayerLifeRegen.cs +++ b/CalPlayer/CalamityPlayerLifeRegen.cs @@ -107,7 +107,7 @@ namespace CalamityMod.CalPlayer ApplyDoTDebuff(vHex, 35); ApplyDoTDebuff(cDepth, 18, purity); ApplyDoTDebuff(astralInfection, 24, infectedJewel || purity); - ApplyDoTDebuff(pFlames, 30, purity); + ApplyDoTDebuff(pFlames, alchFlask ? 10 : 30, purity); ApplyDoTDebuff(cragsLava, 30); ApplyDoTDebuff(shadowflame, 30, purity); // Profaned Soul Crystal turns you into Providence, a God, and you take more damage from God Slayer Inferno @@ -423,8 +423,8 @@ namespace CalamityMod.CalPlayer if (rOoze || aAmpoule || purity) { float missingLifeRatio = (Player.statLifeMax2 - Player.statLife) / Player.statLifeMax2; - //Ambrosial Ampule and ooze give between 2 and 6 hp/s, Purity gives between 3 and 7 hp/s - float lifeRegenToGive = MathHelper.Lerp(purity ? 6f : 4f, purity ? 14f : 12f, missingLifeRatio); + //Ambrosial Ampule and ooze give between 2 and 6 hp/s + float lifeRegenToGive = MathHelper.Lerp(4f, 12f, missingLifeRatio); Player.lifeRegen += (int)lifeRegenToGive; } @@ -586,13 +586,6 @@ namespace CalamityMod.CalPlayer } } } - - // TODO -- Why is this here? - if (weakPetrification) - { - if (Player.mount.Active) - Player.mount.Dismount(Player); - } #endregion // Chalice of the Blood God bleedout diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index e7486c2ef0..03434292cc 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -310,9 +310,9 @@ namespace CalamityMod.CalPlayer SparkParticle spark2 = new SparkParticle(Player.Center + Player.velocity.RotatedBy(-2f * Player.direction) * 1.5f, SparkVelocity2, false, Main.rand.Next(11, 13), sparkscale, Main.rand.NextBool() ? Color.DarkOrange : Color.OrangeRed); GeneralParticleHandler.SpawnParticle(spark2); - if (Player.miscCounter % 5 == 0 && Player.velocity != Vector2.Zero) //every other frame spawn the hitbox + if (Player.miscCounter % 6 == 0 && Player.velocity != Vector2.Zero) { - int damage = Player.ApplyArmorAccDamageBonusesTo(Player.GetBestClassDamage().ApplyTo(175)); + int damage = Player.ApplyArmorAccDamageBonusesTo(Player.GetBestClassDamage().ApplyTo(170)); Projectile.NewProjectile(Player.GetSource_FromThis(), Player.Center + Player.velocity * 1.5f, Vector2.Zero, ModContent.ProjectileType(), damage, 10f, Player.whoAmI); } } @@ -2581,10 +2581,13 @@ namespace CalamityMod.CalPlayer } if (crawCarapace) - Player.GetDamage() += 0.05f; + Player.GetDamage() += 0.07f; if (baroclaw) + { + Player.endurance += 0.05f; Player.GetDamage() += 0.1f; + } if (aeroStone && !Player.slowFall && Player.wingTime < Player.wingTimeMax) { @@ -2819,7 +2822,7 @@ namespace CalamityMod.CalPlayer (harpyRing ? 0.2 : 0D) + (reaverSpeed ? 0.1 : 0D) + (angelTreads ? 0.1 : 0D) + - (blueCandle ? 0.1 : 0D) + + (blueCandle ? 0.05 : 0D) + (soaring ? 0.1 : 0D) + (prismaticGreaves ? 0.1 : 0D) + (plagueReaper ? 0.05 : 0D) + @@ -2827,7 +2830,7 @@ namespace CalamityMod.CalPlayer (Player.empressBrooch ? 0.25 : 0D); if (blueCandle) - Player.moveSpeed += 0.1f; + Player.moveSpeed += 0.05f; if (community) { @@ -2915,15 +2918,17 @@ namespace CalamityMod.CalPlayer } if (wDeath && !purity) - Player.GetDamage() -= 0.25f; + Player.GetDamage() -= 0.2f; if (astralInfection && !(infectedJewel || purity)) - Player.GetDamage() -= 0.15f; + Player.GetDamage() -= 0.1f; if (pFlames && !purity) { - Player.blind = true; - Player.GetDamage() -= 0.15f; + if (!alchFlask) + Player.blind = true; + + Player.GetDamage() -= 0.1f; } if (aCrunch && !laudanum && !purity) diff --git a/CalPlayer/CalamityPlayerOnHit.cs b/CalPlayer/CalamityPlayerOnHit.cs index 42a6b1c2af..d4463c46bd 100644 --- a/CalPlayer/CalamityPlayerOnHit.cs +++ b/CalPlayer/CalamityPlayerOnHit.cs @@ -1266,7 +1266,7 @@ namespace CalamityMod.CalPlayer if (omegaBlueChestplate) target.AddBuff(BuffType(), 180); if (sulphurSet) - target.AddBuff(BuffID.Poisoned, 120); + target.AddBuff(BuffID.Poisoned, 60); if (abyssalAmulet) { CalamityUtils.Inflict246DebuffsNPC(target, BuffType()); diff --git a/CalamityLists.cs b/CalamityLists.cs index 1ed3a84fba..cb15f1a441 100644 --- a/CalamityLists.cs +++ b/CalamityLists.cs @@ -901,9 +901,9 @@ namespace CalamityMod enemyImmunityList = new List() { NPCID.KingSlime, - NPCType(), - NPCType(), - NPCType(), + NPCType(), + NPCType(), + NPCType(), NPCID.EaterofWorldsHead, NPCID.EaterofWorldsBody, NPCID.EaterofWorldsTail, @@ -2428,9 +2428,9 @@ namespace CalamityMod { NPCID.UmbrellaSlime, 5400 }, { NPCID.RainbowSlime, 30000 }, { NPCID.Pinky, 15000 }, - { NPCType(), 21000 }, - { NPCType(), 18000 }, - { NPCType(), 24000 }, + { NPCType(), 21000 }, + { NPCType(), 18000 }, + { NPCType(), 24000 }, { NPCID.EyeofCthulhu, 450000 }, // 30 seconds { NPCID.ServantofCthulhu, 6000 }, diff --git a/DataStructures/NPCStats.cs b/DataStructures/NPCStats.cs index 4c0a22518d..0aec9726b2 100644 --- a/DataStructures/NPCStats.cs +++ b/DataStructures/NPCStats.cs @@ -295,7 +295,7 @@ namespace CalamityMod EnemyStats.ContactDamageValues = new SortedDictionary { { NPCID.KingSlime, new int[] { 40, 64, 80, 96, 144 } }, - { ModContent.NPCType(), new int[] { 30, 44, 60, 76, 114 } }, + { ModContent.NPCType(), new int[] { 30, 44, 60, 76, 114 } }, { ModContent.NPCType(), new int[] { 45, 66, 88, 110, 165 } }, { ModContent.NPCType(), new int[] { 24, 32, 40, 48, 72 } }, @@ -561,7 +561,7 @@ namespace CalamityMod EnemyStats.ProjectileDamageValues = new SortedDictionary, int[]> { - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 26, 36, 44, 52, 84 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 26, 36, 44, 52, 84 } }, { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 26, 36, 44, 52, 84 } }, { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 26, 36, 44, 52, 84 } }, @@ -656,7 +656,7 @@ namespace CalamityMod { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 80, 140, 160, 180, 270 } }, { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 70, 112, 128, 144, 216 } }, { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 80, 140, 160, 180, 270 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 120, 200, 240, 280, 420 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 120, 200, 240, 280, 420 } }, // Split shots: 72, 120, 144, 168, 252 { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 80, 140, 160, 180, 270 } }, { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 70, 112, 128, 144, 216 } }, diff --git a/Enums/NPCTargetType.cs b/Enums/NPCTargetType.cs new file mode 100644 index 0000000000..6fc9b0ac5c --- /dev/null +++ b/Enums/NPCTargetType.cs @@ -0,0 +1,9 @@ +namespace CalamityMod.Enums +{ + public enum NPCTargetType + { + Anyone = 0, + PreferSame = 1, + ForceSwitch = 2, + } +} diff --git a/Events/BossRushEvent.cs b/Events/BossRushEvent.cs index 6da1815a4d..5c8491e682 100644 --- a/Events/BossRushEvent.cs +++ b/Events/BossRushEvent.cs @@ -150,8 +150,8 @@ namespace CalamityMod.Events DownedBossSystem.startedBossRushAtLeastOnce = true; }, permittedNPCs: new int[] { NPCID.BlueSlime, NPCID.YellowSlime, NPCID.PurpleSlime, NPCID.RedSlime, NPCID.GreenSlime, NPCID.RedSlime, - NPCID.IceSlime, NPCID.UmbrellaSlime, NPCID.Pinky, NPCID.SlimeSpiked, NPCID.RainbowSlime, ModContent.NPCType(), - ModContent.NPCType(), ModContent.NPCType() }), + NPCID.IceSlime, NPCID.UmbrellaSlime, NPCID.Pinky, NPCID.SlimeSpiked, NPCID.RainbowSlime, ModContent.NPCType(), + ModContent.NPCType(), ModContent.NPCType() }), new Boss(ModContent.NPCType(), spawnContext: type => { diff --git a/ILEditing/BalancingILChanges.cs b/ILEditing/BalancingILChanges.cs index 0d4956e672..ef06ec1d55 100644 --- a/ILEditing/BalancingILChanges.cs +++ b/ILEditing/BalancingILChanges.cs @@ -27,7 +27,7 @@ namespace CalamityMod.ILEditing #endregion - #region Soaring Insignia Changes + #region Remove Soaring Insignia Infinite Flight private static void RemoveSoaringInsigniaInfiniteWingTime(ILContext il) { // Prevent the infinite flight effect. @@ -42,34 +42,6 @@ namespace CalamityMod.ILEditing cursor.Emit(OpCodes.Ldc_I4_0); cursor.Emit(OpCodes.And); } - - private static void NerfSoaringInsigniaRunAcceleration(ILContext il) - { - // Nerf the run acceleration boost from 1.75x to 1.1x. - var cursor = new ILCursor(il); - if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdfld("empressBrooch"))) - { - LogFailure("Soaring Insignia Mobility Nerf", "Could not locate the Soaring Insignia bool."); - return; - } - if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcR4(1.75f))) - { - LogFailure("Soaring Insignia Mobility Nerf", "Could not locate the Soaring Insignia run acceleration multiplier."); - return; - } - cursor.Next.Operand = 1.1f; - - // Prevent the rocket boots infinite flight effect. - if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdfld("empressBrooch"))) - { - LogFailure("Soaring Insignia Mobility Nerf", "Could not locate the Soaring Insignia bool."); - return; - } - - // AND with 0 (false) so that the Soaring Insignia is never considered equipped and thus infinite rocket boots never triggers. - cursor.Emit(OpCodes.Ldc_I4_0); - cursor.Emit(OpCodes.And); - } #endregion #region Jump Height Changes @@ -258,6 +230,78 @@ namespace CalamityMod.ILEditing cursor.Emit(OpCodes.Ldc_R4, iceSkateTopSpeed); } } + + private static void NerfOverpoweredRunAccelerationSources(ILContext il) + { + // First: Soaring Insignia. Find the check for whether it's equipped for run speeds. + var cursor = new ILCursor(il); + if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdfld("empressBrooch"))) + { + LogFailure("Run Acceleration Nerfs", "Could not locate the Soaring Insignia bool."); + return; + } + + if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcR4(1.75f))) + { + LogFailure("Run Acceleration Nerfs", "Could not locate the Soaring Insignia run acceleration multiplier."); + return; + } + cursor.Next.Operand = BalancingConstants.SoaringInsigniaRunAccelerationMultiplier; + + // Second: Magiluminescence. Find the check for whether it's equipped for run speeds. + if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdfld("hasMagiluminescence"))) + { + LogFailure("Run Acceleration Nerfs", "Could not locate the Magiluminescence bool."); + return; + } + + // + // Don't actually do anything. Magiluminescence is not intended to be nerfed by Calamity. + // + + // Third: Shadow Armor. Find the check for whether it's equipped for run speeds. + if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdfld("shadowArmor"))) + { + LogFailure("Run Acceleration Nerfs", "Could not locate the Shadow Armor bool."); + return; + } + + // Load the player onto the stack as an argument to the following delegate. + // Emit a delegate which consumes the Shadow Armor bool, performs Calamity effects, then always returns false. + // Returning false ensures vanilla Shadow Armor code never runs. + cursor.Emit(OpCodes.Ldarg_0); + + cursor.EmitDelegate((bool shadowArmor, Player p) => { + // If you don't even have Shadow Armor equipped, do nothing. + if (!shadowArmor) + return 0; + + // Shadow Armor does not stack with Magiluminescence if you are on the ground. + if (p.hasMagiluminescence && p.velocity.Y == 0) + return 0; + + // Shadow Armor grants reduced movement bonuses if in the air, or on the ground WITHOUT Magiluminescence. + p.runAcceleration *= BalancingConstants.ShadowArmorRunAccelerationMultiplier; + p.maxRunSpeed *= BalancingConstants.ShadowArmorMaxRunSpeedMultiplier; + p.accRunSpeed *= BalancingConstants.ShadowArmorAccRunSpeedMultiplier; + p.runSlowdown *= BalancingConstants.ShadowArmorRunSlowdownMultiplier; + + // Vanilla Shadow Armor behavior should still always be skipped. + return 0; + }); + + + // Finally: Back to Soaring Insignia. Prevent the rocket boots infinite flight effect, since it's in the same function. + if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdfld("empressBrooch"))) + { + LogFailure("Run Acceleration Nerfs", "Could not locate the Soaring Insignia bool."); + return; + } + + // AND with 0 (false) so that the Soaring Insignia is never considered equipped and thus infinite rocket boots never triggers. + cursor.Emit(OpCodes.Ldc_I4_0); + cursor.Emit(OpCodes.And); + } #endregion #region Life Regen Changes diff --git a/ILEditing/ILChangesLoading.cs b/ILEditing/ILChangesLoading.cs index 2c8fb20700..c2ea95f2b1 100644 --- a/ILEditing/ILChangesLoading.cs +++ b/ILEditing/ILChangesLoading.cs @@ -107,7 +107,7 @@ namespace CalamityMod.ILEditing IL_Player.UpdateJumpHeight += FixJumpHeightBoosts; IL_Player.Update += BaseJumpHeightAdjustment; IL_Player.Update += RunSpeedAdjustments; - IL_Player.Update += NerfSoaringInsigniaRunAcceleration; + IL_Player.Update += NerfOverpoweredRunAccelerationSources; // Soaring Insignia, Magiluminescence, and Shadow Armor IL_Player.WingMovement += RemoveSoaringInsigniaInfiniteWingTime; // Life regen balance diff --git a/Items/Accessories/AlchemicalFlask.cs b/Items/Accessories/AlchemicalFlask.cs index 909aa4106f..86d4aa1de4 100644 --- a/Items/Accessories/AlchemicalFlask.cs +++ b/Items/Accessories/AlchemicalFlask.cs @@ -23,7 +23,6 @@ namespace CalamityMod.Items.Accessories { CalamityPlayer modPlayer = player.Calamity(); modPlayer.alchFlask = true; - player.buffImmune[ModContent.BuffType()] = true; } public override void AddRecipes() diff --git a/Items/Accessories/AmbrosialAmpoule.cs b/Items/Accessories/AmbrosialAmpoule.cs index ae0904ba07..6d42653934 100644 --- a/Items/Accessories/AmbrosialAmpoule.cs +++ b/Items/Accessories/AmbrosialAmpoule.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { CalamityPlayer modPlayer = player.Calamity(); - player.statLifeMax2 += 70; + player.statLifeMax2 += 50; // bool left in for abyss light purposes and life regen effects modPlayer.aAmpoule = true; diff --git a/Items/Accessories/AsgardianAegis.cs b/Items/Accessories/AsgardianAegis.cs index 4bffcce0e7..cbb8941b60 100644 --- a/Items/Accessories/AsgardianAegis.cs +++ b/Items/Accessories/AsgardianAegis.cs @@ -27,7 +27,7 @@ namespace CalamityMod.Items.Accessories Item.width = 60; Item.height = 54; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; - Item.defense = 20; + Item.defense = 12; Item.accessory = true; Item.rare = ModContent.RarityType(); } diff --git a/Items/Accessories/AsgardsValor.cs b/Items/Accessories/AsgardsValor.cs index e2aacf1b97..a4e4da6e8c 100644 --- a/Items/Accessories/AsgardsValor.cs +++ b/Items/Accessories/AsgardsValor.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Accessories Item.height = 44; Item.value = CalamityGlobalItem.RarityLimeBuyPrice; Item.rare = ItemRarityID.Lime; - Item.defense = 12; // we buff Ankh Shield to 12 + Item.defense = 8; // we buff Ankh Shield to 8 Item.accessory = true; } diff --git a/Items/Accessories/BlazingCore.cs b/Items/Accessories/BlazingCore.cs index b481df9a76..95911b09b7 100644 --- a/Items/Accessories/BlazingCore.cs +++ b/Items/Accessories/BlazingCore.cs @@ -67,7 +67,7 @@ namespace CalamityMod.Items.Accessories for (int i = 0; i < chains; i++) { int projectileType = ModContent.ProjectileType(); - int dmgAmt = 90; + int dmgAmt = 250; if (!empowered && Main.rand.NextBool(5)) { projectileType = ModContent.ProjectileType(); diff --git a/Items/Accessories/ElysianAegis.cs b/Items/Accessories/ElysianAegis.cs index a7231b9b11..3c1b4d6f67 100644 --- a/Items/Accessories/ElysianAegis.cs +++ b/Items/Accessories/ElysianAegis.cs @@ -25,7 +25,7 @@ namespace CalamityMod.Items.Accessories Item.height = 42; Item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; Item.rare = ModContent.RarityType(); - Item.defense = 16; + Item.defense = 10; Item.accessory = true; } diff --git a/Items/Accessories/FlameLickedShell.cs b/Items/Accessories/FlameLickedShell.cs index cbf6b96a33..733218f7e3 100644 --- a/Items/Accessories/FlameLickedShell.cs +++ b/Items/Accessories/FlameLickedShell.cs @@ -55,7 +55,7 @@ namespace CalamityMod.Items.Accessories int totalProjectiles = 6; float offsetAngle = (float)Math.PI * radialOffset; int type = ModContent.ProjectileType(); - int damage = (int)player.GetBestClassDamage().ApplyTo(60); + int damage = (int)player.GetBestClassDamage().ApplyTo(200); damage = player.ApplyArmorAccDamageBonusesTo(damage); if (player.whoAmI == Main.myPlayer) @@ -72,7 +72,7 @@ namespace CalamityMod.Items.Accessories totalProjectiles = 12; float radians2 = MathHelper.TwoPi / totalProjectiles; type = ModContent.ProjectileType(); - damage = (int)player.GetBestClassDamage().ApplyTo(20); + damage = (int)player.GetBestClassDamage().ApplyTo(70); damage = player.ApplyArmorAccDamageBonusesTo(damage); double angleA = radians2 * 0.5; diff --git a/Items/Accessories/OldDukeScales.cs b/Items/Accessories/OldDukeScales.cs index 43a9746187..94816ec2a7 100644 --- a/Items/Accessories/OldDukeScales.cs +++ b/Items/Accessories/OldDukeScales.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Accessories { public new string LocalizationCategory => "Items.Accessories"; - public static int RecoverTime = 120; + public static int RecoverTime = 90; public static int DashFatigueIncrease = 240; public static int MaxFatigue = 1200; // This is also the time that it takes the player to recover from the loss of all stamina. @@ -128,8 +128,9 @@ namespace CalamityMod.Items.Accessories RecoverTimer--; // If the player has recovered, start decreasing the fatigue. + bool PressingMoveKeys = Player.controlLeft || Player.controlRight || Player.controlDown || Player.controlJump; if (Fatigue > 0 && RecoverTimer <= 0) - Fatigue -= Player.StandingStill() ? 2 : 1; + Fatigue -= PressingMoveKeys ? 3 : 5; // The fatigue cannot go higher than the max. if (Fatigue >= OldDukeScales.MaxFatigue) diff --git a/Items/Accessories/OrnateShield.cs b/Items/Accessories/OrnateShield.cs index 4591e8c680..2b12a2aa69 100644 --- a/Items/Accessories/OrnateShield.cs +++ b/Items/Accessories/OrnateShield.cs @@ -20,7 +20,7 @@ namespace CalamityMod.Items.Accessories Item.height = 32; Item.value = CalamityGlobalItem.RarityPinkBuyPrice; Item.rare = ItemRarityID.Pink; - Item.defense = 8; + Item.defense = 4; // This has a ram dash, it should give a bit less defense due to how good it is Item.accessory = true; } diff --git a/Items/Accessories/Radiance.cs b/Items/Accessories/Radiance.cs index b8f71335c4..68b3b5836c 100644 --- a/Items/Accessories/Radiance.cs +++ b/Items/Accessories/Radiance.cs @@ -33,7 +33,7 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { CalamityPlayer modPlayer = player.Calamity(); - player.statLifeMax2 += 100; + player.statLifeMax2 += 70; // Abyss light, debuff near-immunity, life regen effects, and massively enhances debuff halving modPlayer.purity = true; diff --git a/Items/Accessories/RampartofDeities.cs b/Items/Accessories/RampartofDeities.cs index 04b7481d08..2ac41f439d 100644 --- a/Items/Accessories/RampartofDeities.cs +++ b/Items/Accessories/RampartofDeities.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Accessories Item.width = 64; Item.height = 62; Item.value = CalamityGlobalItem.RarityVioletBuyPrice; - Item.defense = 18; + Item.defense = 12; Item.accessory = true; Item.rare = ModContent.RarityType(); } diff --git a/Items/Accessories/Regenator.cs b/Items/Accessories/Regenator.cs index 292b762fa4..f13b41822a 100644 --- a/Items/Accessories/Regenator.cs +++ b/Items/Accessories/Regenator.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.Accessories Item.height = 56; Item.value = CalamityGlobalItem.RarityLimeBuyPrice; Item.rare = ItemRarityID.Lime; - Item.defense = 10; + Item.defense = 4; // This should have less defense due to the regen it provides Item.accessory = true; } diff --git a/Items/Accessories/ShieldoftheHighRuler.cs b/Items/Accessories/ShieldoftheHighRuler.cs index f717c20560..aa530beaaa 100644 --- a/Items/Accessories/ShieldoftheHighRuler.cs +++ b/Items/Accessories/ShieldoftheHighRuler.cs @@ -25,7 +25,7 @@ namespace CalamityMod.Items.Accessories Item.value = CalamityGlobalItem.RarityYellowBuyPrice; Item.rare = ItemRarityID.Yellow; Item.Calamity().donorItem = true; - Item.defense = 12; + Item.defense = 6; Item.accessory = true; } diff --git a/Items/Accessories/YharimsGift.cs b/Items/Accessories/YharimsGift.cs index 6f5cc3c2e9..0a59362b0f 100644 --- a/Items/Accessories/YharimsGift.cs +++ b/Items/Accessories/YharimsGift.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Accessories { Item.width = 20; Item.height = 22; - Item.defense = 30; + Item.defense = 15; // Why did this give 30 defense? This thing really needs a rework lol Item.accessory = true; Item.value = CalamityGlobalItem.RarityVioletBuyPrice; Item.rare = ModContent.RarityType(); diff --git a/Items/Ammo/DryadsTear.cs b/Items/Ammo/DryadsTear.cs index 657029031b..24866b5488 100644 --- a/Items/Ammo/DryadsTear.cs +++ b/Items/Ammo/DryadsTear.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Ammo { Item.width = 8; Item.height = 8; - Item.damage = 8; + Item.damage = 10; Item.DamageType = DamageClass.Ranged; Item.maxStack = 9999; Item.consumable = true; diff --git a/Items/Ammo/HolyFireBullet.cs b/Items/Ammo/HolyFireBullet.cs index 9135150910..9c54ed0152 100644 --- a/Items/Ammo/HolyFireBullet.cs +++ b/Items/Ammo/HolyFireBullet.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Items.Ammo public class HolyFireBullet : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Ammo"; - internal const float ExplosionMultiplier = 0.33f; + internal const float ExplosionMultiplier = 0.275f; public static readonly SoundStyle Explosion = new("CalamityMod/Sounds/Item/HolyFireBulletExplosion") { PitchVariance = 0.2f, Volume = 0.6f }; public override void SetStaticDefaults() { @@ -21,7 +21,7 @@ namespace CalamityMod.Items.Ammo { Item.width = 22; Item.height = 22; - Item.damage = 22; + Item.damage = 20; Item.DamageType = DamageClass.Ranged; Item.maxStack = 9999; Item.consumable = true; diff --git a/Items/Ammo/HyperiusBullet.cs b/Items/Ammo/HyperiusBullet.cs index 39653cceb2..6812c127eb 100644 --- a/Items/Ammo/HyperiusBullet.cs +++ b/Items/Ammo/HyperiusBullet.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Items.Ammo { public new string LocalizationCategory => "Items.Ammo"; - public static int SplitBulletBonusDamage = 10; + public static int SplitBulletBonusDamage = 16; public override void SetStaticDefaults() { diff --git a/Items/Ammo/VeriumBolt.cs b/Items/Ammo/VeriumBolt.cs index b2a1adb08a..bbc4756fe6 100644 --- a/Items/Ammo/VeriumBolt.cs +++ b/Items/Ammo/VeriumBolt.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Ammo { Item.width = 8; Item.height = 8; - Item.damage = 7; + Item.damage = 11; Item.DamageType = DamageClass.Ranged; Item.maxStack = 9999; Item.consumable = true; diff --git a/Items/Armor/Sulphurous/SulphurousBreastplate.cs b/Items/Armor/Sulphurous/SulphurousBreastplate.cs index ee6c63df21..6848c2825b 100644 --- a/Items/Armor/Sulphurous/SulphurousBreastplate.cs +++ b/Items/Armor/Sulphurous/SulphurousBreastplate.cs @@ -22,8 +22,8 @@ namespace CalamityMod.Items.Armor.Sulphurous public override void UpdateEquip(Player player) { - player.GetDamage() += 0.08f; - player.GetCritChance() += 5; + player.GetDamage() += 0.06f; + player.GetCritChance() += 4; } public override void AddRecipes() diff --git a/Items/Armor/Sulphurous/SulphurousHelmet.cs b/Items/Armor/Sulphurous/SulphurousHelmet.cs index b2b6e7b765..f7375d88c0 100644 --- a/Items/Armor/Sulphurous/SulphurousHelmet.cs +++ b/Items/Armor/Sulphurous/SulphurousHelmet.cs @@ -33,7 +33,7 @@ namespace CalamityMod.Items.Armor.Sulphurous var modPlayer = player.Calamity(); modPlayer.sulphurSet = true; player.GetJumpState().Enable(); - modPlayer.rogueStealthMax += 0.7f; + modPlayer.rogueStealthMax += 0.65f; modPlayer.wearingRogueArmor = true; player.ignoreWater = true; } diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index 8c6efe6774..077b34fc84 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using CalamityMod.Balancing; using CalamityMod.Buffs.StatBuffs; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.CalPlayer; @@ -437,8 +438,8 @@ namespace CalamityMod.Items modPlayer.canFireAtaxiaRogueProjectile = false; int flareID = ModContent.ProjectileType(); - // Ataxia Rogue Flares: 6 x 50%, soft cap starts at 90 base damage - int flareDamage = CalamityUtils.DamageSoftCap(damage * 0.5, 90); + // Hydrothermic Rogue Flares: 6 x (50 + 15%), soft cap starts at 90 base damage + int flareDamage = CalamityUtils.DamageSoftCap(50 + damage * 0.15, 90); flareDamage = player.ApplyArmorAccDamageBonusesTo(flareDamage); if (player.whoAmI == Main.myPlayer) @@ -1237,6 +1238,35 @@ namespace CalamityMod.Items player.GetDamage() += 0.02f; } + // The Frog Leg line is prevented from stacking. + // Additionally, Amphibian boots are directly nerfed so they aren't the best in slot boots at all times. + // + // 21MAY2024: Ozzatron: Disabled this code. Frog Leg is allowed to stack. Amphibian Boots specific nerf is applied below. + /* + switch (item.type) + { + default: + break; + case ItemID.AmphibianBoots: + if (modPlayer.alreadyHasFrogLeg) + player.jumpSpeedBoost -= BalancingConstants.VanillaFrogLegJumpSpeedBoost; + else + player.jumpSpeedBoost += BalancingConstants.AmphibianBootsJumpSpeedBoost - BalancingConstants.VanillaFrogLegJumpSpeedBoost; + modPlayer.alreadyHasFrogLeg = true; + break; + case ItemID.FrogLeg: + case ItemID.FrogFlipper: + case ItemID.FrogGear: + case ItemID.FrogWebbing: + if (modPlayer.alreadyHasFrogLeg) + player.jumpSpeedBoost -= BalancingConstants.VanillaFrogLegJumpSpeedBoost; + modPlayer.alreadyHasFrogLeg = true; + break; + } + */ + if (item.type == ItemID.AmphibianBoots) + player.jumpSpeedBoost += BalancingConstants.AmphibianBootsJumpSpeedBoost - BalancingConstants.VanillaFrogLegJumpSpeedBoost; + // Feral Claws line melee speed adjustments and nonstacking // First removes all their melee speed so it can be given based on which you wear without stacking if (item.type == ItemID.FeralClaws) diff --git a/Items/CalamityGlobalItemTooltip.cs b/Items/CalamityGlobalItemTooltip.cs index dcf49bcac9..3cff630860 100644 --- a/Items/CalamityGlobalItemTooltip.cs +++ b/Items/CalamityGlobalItemTooltip.cs @@ -292,6 +292,37 @@ namespace CalamityMod.Items EditTooltipByNum(0, (line) => line.Text += "\nDemon Altars now drop Souls of Night instead of generating ores when destroyed" + "\nHardmode ores now generate after defeating Mechanical Bosses for the first time"); + // Exact life regen descriptions + bool isCampfire = item.type == ItemID.Campfire || item.type == ItemID.CursedCampfire || item.type == ItemID.DemonCampfire || item.type == ItemID.FrozenCampfire || item.type == ItemID.IchorCampfire || item.type == ItemID.RainbowCampfire || item.type == ItemID.UltraBrightCampfire || item.type == ItemID.BoneCampfire || item.type == ItemID.DesertCampfire || item.type == ItemID.CoralCampfire || item.type == ItemID.CorruptCampfire || item.type == ItemID.CrimsonCampfire || item.type == ItemID.HallowedCampfire || item.type == ItemID.JungleCampfire || item.type == ItemID.MushroomCampfire || item.type == ItemID.ShimmerCampfire; + if (isCampfire) + EditTooltipByNum(0, (line) => line.Text = "Life regen is increased by 0.5 HP/s when near a campfire"); + + if (item.type == ItemID.HeartLantern) + EditTooltipByNum(0, (line) => line.Text = "Grants +1 HP/s life regeneration when placed nearby"); + + if (item.type == ItemID.BottledHoney) + EditTooltipByNum(0, (line) => line.Text = "Grants +1 HP/s life regen for a short time" + + "\nGrants an additional +1 HP/s life regen while inflicted with a damaging debuff"); + + if (item.type == ItemID.ShinyStone) + EditTooltipByNum(0, (line) => line.Text = "Grants +2 HP/s life regen and accelerates natural life regen when not moving"); + + if (item.type == ItemID.BandofRegeneration) + EditTooltipByNum(0, (line) => line.Text = "Grants +1 HP/s life regeneration"); + + if (item.type == ItemID.CharmofMyths) + EditTooltipByNum(0, (line) => line.Text = "Grants +1 HP/s life regeneration and reduces the cooldown of healing potions by 25%"); + + if (item.type == ItemID.RegenerationPotion) + EditTooltipByNum(0, (line) => line.Text = "Provides +2 HP/s life regeneration"); + + if (item.type == ItemID.SoulDrain) + EditTooltipByNum(0, (line) => line.Text += "\nThis grants +1.5 HP/s life regen and accelerates natural life regen" + + "\nLife drain stacks based on the number of enemies being hit"); + + if (item.type == ItemID.HamBat) + EditTooltipByNum(1, (line) => line.Text = "Defeating enemies temporarily grants +3 HP/s life regen"); + // Warmth Potion provides debuff immunities if (item.type == ItemID.WarmthPotion) { @@ -326,7 +357,7 @@ namespace CalamityMod.Items // There are no item sets for tombstones wtf if (item.type == ItemID.Tombstone || item.type == ItemID.GraveMarker || item.type == ItemID.CrossGraveMarker || item.type == ItemID.Headstone || item.type == ItemID.Gravestone || item.type == ItemID.Obelisk || item.type == ItemID.RichGravestone1 || item.type == ItemID.RichGravestone2 || item.type == ItemID.RichGravestone3 || item.type == ItemID.RichGravestone4 || item.type == ItemID.RichGravestone5) - EditTooltipByName("Material", (line) => line.Text += "\n20 of any tombstone turns the surrounding area into a graveyard" + EditTooltipByName("Material", (line) => line.Text += "\n13 of any tombstone turns the surrounding area into a graveyard" + "\nGraveyards have various new item sales and recipes"); // Eternity Crystal notifies the player that they can accelerate the invasion @@ -841,17 +872,14 @@ namespace CalamityMod.Items if (item.type == ItemID.JunglePants || item.type == ItemID.AncientCobaltLeggings) EditTooltipByNum(1, (line) => line.Text = line.Text.Replace("6%", "3%")); - // Shadow - if (item.type == ItemID.ShadowHelmet || item.type == ItemID.AncientShadowHelmet || item.type == ItemID.ShadowScalemail || item.type == ItemID.AncientShadowScalemail || item.type == ItemID.ShadowGreaves || item.type == ItemID.AncientShadowGreaves) - EditTooltipByNum(0, (line) => line.Text = "5% increased damage and 7% increased jump speed"); - // Crimson if (item.type == ItemID.CrimsonHelmet || item.type == ItemID.CrimsonScalemail || item.type == ItemID.CrimsonGreaves) { EditTooltipByNum(0, (line) => { - string newTooltip = line.Text.Replace("3%", "5%"); - newTooltip += "\n+0.5 HP/s life regen"; + string newTooltip = line.Text.Replace("3%", "6%"); + // Chest piece has 2 regen instead of 1 + newTooltip += item.type == ItemID.CrimsonScalemail ? "\n+1 HP/s life regen" : "\n+0.5 HP/s life regen"; line.Text = newTooltip; }); } @@ -903,8 +931,10 @@ namespace CalamityMod.Items // DD2 armor tooltip edits #region DD2 Armor - // Reduce DD2 armor piece bonuses because they're overpowered + // Reduce DD2 armor piece bonuses because they're overpowered, and clarify life regen boosts // Squire armor + if (item.type == ItemID.SquireGreatHelm) + EditTooltipByNum(0, (line) => line.Text = "Increases your max number of sentries by 1 and grants +2 HP/s life regen"); if (item.type == ItemID.SquirePlating) EditTooltipByNum(0, (line) => line.Text = "10% increased minion and melee damage"); if (item.type == ItemID.SquireGreaves) @@ -934,7 +964,7 @@ namespace CalamityMod.Items // Valhalla Knight armor if (item.type == ItemID.SquireAltShirt) - EditTooltipByNum(0, (line) => line.Text = "30% increased minion damage and increased life regeneration"); + EditTooltipByNum(0, (line) => line.Text = "30% increased minion damage and grants +4 HP/s life regen"); if (item.type == ItemID.SquireAltPants) EditTooltipByNum(0, (line) => line.Text = "10% increased minion damage and melee critical strike chance"); diff --git a/Items/CalamityGlobalItemTweaks.cs b/Items/CalamityGlobalItemTweaks.cs index 4b73cceaba..7cb2d01cd2 100644 --- a/Items/CalamityGlobalItemTweaks.cs +++ b/Items/CalamityGlobalItemTweaks.cs @@ -162,6 +162,7 @@ namespace CalamityMod.Items { ItemID.MonkStaffT1, Do(TrueMeleeNoSpeed, DamageExact(83)) }, // Sleepy Octopod { ItemID.MonkStaffT2, Do(AutoReuse, TrueMelee, DamageExact(90)) }, // Ghastly Glaive { ItemID.MonkStaffT3, Do(DamageExact(225)) }, // Sky Dragon's Fury + { ItemID.MoonlordBullet, Do(DamageExact(19)) }, // Luminite Bullet { ItemID.MoonlordTurretStaff, Do(DamageExact(50), UseExact(15)) }, //Lunar Portal Staff { ItemID.Muramasa, Do(CritDelta(+20)) }, { ItemID.MushroomSpear, Do(AutoReuse, TrueMelee, UseRatio(0.8f), DamageExact(100)) }, @@ -211,13 +212,12 @@ namespace CalamityMod.Items { ItemID.RocketLauncher, Do(DamageExact(70)) }, { ItemID.Sandgun, Do(PointBlank, DamageExact(22), UseExact(20)) }, { ItemID.SapphireStaff, Do(DamageExact(25)) }, - { ItemID.SDMG, Do(PointBlank, DamageExact(80)) }, { ItemID.Seedler, Do(UseMeleeSpeed, DamageExact(74), ShootSpeedDelta(+4f)) }, { ItemID.ShadowbeamStaff, Do(DamageExact(100)) }, { ItemID.ShadowFlameBow, Do(PointBlank, DamageExact(55)) }, { ItemID.ShadowFlameHexDoll, Do(DamageExact(40), ShootSpeedExact(30)) }, { ItemID.ShadowFlameKnife, Do(DamageExact(70)) }, - { ItemID.SharpTears, Do(DamageExact(49)) }, + { ItemID.SharpTears, Do(DamageExact(49)) }, // Blood Thorn { ItemID.Shotgun, Do(PointBlank, DamageExact(36), AutoReuse) }, { ItemID.Shroomerang, Do(ShootSpeedExact(11)) }, { ItemID.SilverBullet, Do(DamageExact(8)) }, @@ -225,6 +225,7 @@ namespace CalamityMod.Items { ItemID.SkyFracture, Do(DamageExact(54), ShootSpeedExact(30f)) }, { ItemID.SlapHand, Do(UseTurn, DamageExact(120)) }, { ItemID.Smolstar, Do(DamageExact(9), AutoReuse, UseExact(25)) }, // Blade Staff + { ItemID.SniperRifle, Do(PointBlank, DamageExact(215)) }, { ItemID.SolarEruption, Do(DamageExact(157)) }, { ItemID.SoulDrain, Do(DamageExact(38)) }, // Life Drain { ItemID.SpaceGun, Do(DamageExact(25)) }, @@ -238,7 +239,7 @@ namespace CalamityMod.Items { ItemID.StylistKilLaKillScissorsIWish, Do(AutoReuse, UseTurn, DamageExact(18)) }, // Stylish Scissors { ItemID.Stynger, Do(DamageExact(75)) }, { ItemID.Swordfish, Do(AutoReuse, TrueMelee, DamageExact(24)) }, - { ItemID.TacticalShotgun, Do(PointBlank, DamageExact(34)) }, + { ItemID.TacticalShotgun, Do(PointBlank, DamageExact(41)) }, { ItemID.TaxCollectorsStickOfDoom, Do(AutoReuse, UseTurn, UseRatio(0.8f), DamageExact(70)) }, // Classy Cane { ItemID.TendonBow, Do(PointBlank, DamageExact(17), AutoReuse) }, { ItemID.TerraBlade, Do(DamageExact(122)) }, @@ -267,6 +268,7 @@ namespace CalamityMod.Items { ItemID.VampireKnives, Do(DamageExact(38)) }, { ItemID.ValkyrieYoyo, Do(AutoReuse, DamageExact(48)) }, // Red's Throw and Valkyrie Yoyo have the same stats { ItemID.VenomStaff, Do(DamageExact(55)) }, + { ItemID.VenusMagnum, Do(PointBlank, DamageExact(65)) }, { ItemID.WaspGun, Do(UseExact(11), DamageExact(58)) }, { ItemID.WaterBolt, Do(DamageExact(23)) }, { ItemID.WhitePhaseblade, Do(AutoReuse, UseTurn, DamageExact(32)) }, @@ -282,31 +284,31 @@ namespace CalamityMod.Items #region CATEGORY 2: Defense Balancing { ItemID.AncientHallowedGreaves, Do(DefenseDelta(+2)) }, { ItemID.AncientHallowedPlateMail, Do(DefenseDelta(+3)) }, - { ItemID.AnkhShield, Do(DefenseDelta(+8)) }, - { ItemID.CobaltShield, Do(DefenseDelta(+3)) }, + { ItemID.AnkhShield, Do(DefenseDelta(+4)) }, // 8 total + { ItemID.CobaltShield, Do(DefenseDelta(+3)) }, // 4 total { ItemID.EoCShield, Do(DefenseDelta(+1)) }, // Shield of Cthulhu - { ItemID.FrozenShield, Do(DefenseDelta(+7)) }, + { ItemID.FrozenShield, Do(DefenseDelta(+4)) }, // 10 total (plus the Frozen Turtle Shell DR effect) { ItemID.FrozenTurtleShell, Do(DefenseExact(6)) }, { ItemID.HallowedGreaves, Do(DefenseDelta(+2)) }, { ItemID.HallowedPlateMail, Do(DefenseDelta(+3)) }, - { ItemID.HeroShield, Do(DefenseDelta(+10)) }, + { ItemID.HeroShield, Do(DefenseDelta(+5)) }, // 15 total (plus increased max life) { ItemID.LavaSkull, Do(DefenseExact(4)) }, // Magma Skull { ItemID.MoltenSkullRose, Do(DefenseExact(8)) }, - { ItemID.ObsidianShield, Do(DefenseDelta(+5)) }, - { ItemID.ObsidianSkull, Do(DefenseDelta(+1)) }, + { ItemID.ObsidianShield, Do(DefenseDelta(+4)) }, // 6 total + { ItemID.ObsidianSkull, Do(DefenseDelta(+1)) }, // 2 total { ItemID.ObsidianSkullRose, Do(DefenseExact(4)) }, { ItemID.OrichalcumBreastplate, Do(DefenseDelta(+3)) }, { ItemID.OrichalcumHeadgear, Do(DefenseDelta(+2)) }, { ItemID.OrichalcumHelmet, Do(DefenseDelta(+3)) }, { ItemID.OrichalcumLeggings, Do(DefenseDelta(+4)) }, { ItemID.OrichalcumMask, Do(DefenseDelta(+3)) }, - { ItemID.PaladinsShield, Do(DefenseDelta(+3)) }, + { ItemID.PaladinsShield, Do(DefenseDelta(+2)) }, // 8 total { ItemID.PalladiumBreastplate, Do(DefenseDelta(+3)) }, { ItemID.PalladiumHeadgear, Do(DefenseDelta(+2)) }, { ItemID.PalladiumHelmet, Do(DefenseDelta(+3)) }, { ItemID.PalladiumMask, Do(DefenseDelta(+1)) }, { ItemID.PalladiumLeggings, Do(DefenseDelta(+3)) }, - { ItemID.Shackle, Do(DefenseDelta(+2)) }, + { ItemID.Shackle, Do(DefenseDelta(+2)) }, // 3 total #endregion #region CATEGORY 3: Tool Balancing @@ -454,15 +456,14 @@ namespace CalamityMod.Items { ItemID.PulseBow, pointBlank }, { ItemID.Revolver, Do(PointBlank, AutoReuse) }, { ItemID.RichMahoganyBow, pointBlank }, + { ItemID.SDMG, pointBlank }, { ItemID.ShadewoodBow, pointBlank }, { ItemID.SilverBow, pointBlank }, - { ItemID.SniperRifle, pointBlank }, { ItemID.SnowballCannon, pointBlank }, { ItemID.StakeLauncher, pointBlank }, { ItemID.TinBow, pointBlank }, { ItemID.TungstenBow, pointBlank }, { ItemID.Uzi, pointBlank }, - { ItemID.VenusMagnum, pointBlank }, { ItemID.VortexBeater, pointBlank }, { ItemID.WoodenBow, pointBlank }, #endregion diff --git a/Items/Dyes/AerialiteDye.png b/Items/Dyes/AerialiteDye.png index 99402471c4..d5b2f4c35e 100644 Binary files a/Items/Dyes/AerialiteDye.png and b/Items/Dyes/AerialiteDye.png differ diff --git a/Items/Fishing/EnchantedStarfish.cs b/Items/Fishing/EnchantedStarfish.cs index 2109fcecc4..8102c4c1c9 100644 --- a/Items/Fishing/EnchantedStarfish.cs +++ b/Items/Fishing/EnchantedStarfish.cs @@ -13,7 +13,8 @@ namespace CalamityMod.Items.Fishing Item.ResearchUnlockCount = 10; ItemID.Sets.CanBePlacedOnWeaponRacks[Item.type] = true; // For some reason Life/Mana boosting items are in this set (along with Magic Mirror+) - ItemID.Sets.SortingPriorityBossSpawns[Type] = 19; // Mana Crystal + ItemID.Sets.SortingPriorityBossSpawns[Type] = 21; // Mana Crystal + ItemID.Sets.ShimmerTransformToItem[Type] = ItemID.ArcaneCrystal; } public override void SetDefaults() diff --git a/Items/Placeables/Furniture/BossRelics/AstrumDeusRelic.png b/Items/Placeables/Furniture/BossRelics/AstrumDeusRelic.png index beecae5c78..cfbfe599d3 100644 Binary files a/Items/Placeables/Furniture/BossRelics/AstrumDeusRelic.png and b/Items/Placeables/Furniture/BossRelics/AstrumDeusRelic.png differ diff --git a/Items/Placeables/Furniture/DevPaintings/ThankYouPainting.cs b/Items/Placeables/Furniture/DevPaintings/ThankYouPainting.cs index 17aec33a70..63db3bcde1 100644 --- a/Items/Placeables/Furniture/DevPaintings/ThankYouPainting.cs +++ b/Items/Placeables/Furniture/DevPaintings/ThankYouPainting.cs @@ -72,8 +72,8 @@ namespace CalamityMod.Items.Placeables.Furniture.DevPaintings "CosmaticMango", "CrabBar", "Dia", - "DylanDoe21", "enamoured", + "ENNWAY", "Fluffi", "HaguriHat", "Heart Plus Up!", @@ -94,7 +94,6 @@ namespace CalamityMod.Items.Placeables.Furniture.DevPaintings "Shayy", "Spider Prov", "StipulateVenus", - "Tomat", "Triangle", "Uncle Danny", "Xyk", @@ -126,10 +125,10 @@ namespace CalamityMod.Items.Placeables.Furniture.DevPaintings "Doog", "drh", "dwshin", + "DylanDoe21", "Earth", "EchoDuck", "Ein", - "ENNWAY", "Enreden", "Epsilon", "Fargowilta", @@ -191,6 +190,7 @@ namespace CalamityMod.Items.Placeables.Furniture.DevPaintings "ThousandFields", "TikiWiki", "Tinymanx", + "Tomat", "Trivaxy", "Uberransy", "Vaikyia", diff --git a/Items/Placeables/Furniture/Monoliths/BossRushMonolith.png b/Items/Placeables/Furniture/Monoliths/BossRushMonolith.png index d00e2fd304..700f5dca6d 100644 Binary files a/Items/Placeables/Furniture/Monoliths/BossRushMonolith.png and b/Items/Placeables/Furniture/Monoliths/BossRushMonolith.png differ diff --git a/Items/SummonItems/AstralChunk.cs b/Items/SummonItems/AstralChunk.cs index c5094efa77..4a0116a906 100644 --- a/Items/SummonItems/AstralChunk.cs +++ b/Items/SummonItems/AstralChunk.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.SummonItems public new string LocalizationCategory => "Items.SummonItems"; public override void SetStaticDefaults() { - ItemID.Sets.SortingPriorityBossSpawns[Type] = 14; // Frost Moon + ItemID.Sets.SortingPriorityBossSpawns[Type] = 12; // Truffle Worm } public override void SetDefaults() diff --git a/Items/SummonItems/CharredIdol.cs b/Items/SummonItems/CharredIdol.cs index 69c33b9bfc..152bac38b9 100644 --- a/Items/SummonItems/CharredIdol.cs +++ b/Items/SummonItems/CharredIdol.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.SummonItems public new string LocalizationCategory => "Items.SummonItems"; public override void SetStaticDefaults() { - ItemID.Sets.SortingPriorityBossSpawns[Type] = 9; // Mechanical Skull + ItemID.Sets.SortingPriorityBossSpawns[Type] = 10; // Mechanical Skull } public override void SetDefaults() diff --git a/Items/SummonItems/CryoKey.cs b/Items/SummonItems/CryoKey.cs index 6fee06e1f8..a128adc1a4 100644 --- a/Items/SummonItems/CryoKey.cs +++ b/Items/SummonItems/CryoKey.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.SummonItems public new string LocalizationCategory => "Items.SummonItems"; public override void SetStaticDefaults() { - ItemID.Sets.SortingPriorityBossSpawns[Type] = 7; // Mechanical Eye + ItemID.Sets.SortingPriorityBossSpawns[Type] = 7; // Ocram's Razor (1 below Mechanical Eye) } public override void SetDefaults() diff --git a/Items/SummonItems/EyeofDesolation.cs b/Items/SummonItems/EyeofDesolation.cs index 7e66341a3c..f8e683b1bf 100644 --- a/Items/SummonItems/EyeofDesolation.cs +++ b/Items/SummonItems/EyeofDesolation.cs @@ -26,7 +26,7 @@ namespace CalamityMod.Items.SummonItems public int spawnYAdd = 0; public override void SetStaticDefaults() { - ItemID.Sets.SortingPriorityBossSpawns[Type] = 10; // Pirate Map + ItemID.Sets.SortingPriorityBossSpawns[Type] = 11; // Pirate Map (1 above Mechanical Skull) } public override void SetDefaults() diff --git a/Items/SummonItems/OldPowerCell.cs b/Items/SummonItems/OldPowerCell.cs index 29ac9bf111..02c26ef26e 100644 --- a/Items/SummonItems/OldPowerCell.cs +++ b/Items/SummonItems/OldPowerCell.cs @@ -15,7 +15,7 @@ namespace CalamityMod.Items.SummonItems public override void SetStaticDefaults() { NPCID.Sets.MPAllowedEnemies[NPCID.Golem] = true; - ItemID.Sets.SortingPriorityBossSpawns[Type] = 15; // Lihzahrd Power Cell + ItemID.Sets.SortingPriorityBossSpawns[Type] = 16; // Lihzahrd Power Cell } public override void SetDefaults() diff --git a/Items/SummonItems/Portabulb.cs b/Items/SummonItems/Portabulb.cs index 0217cd7379..2f239988b5 100644 --- a/Items/SummonItems/Portabulb.cs +++ b/Items/SummonItems/Portabulb.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.SummonItems public override void SetStaticDefaults() { NPCID.Sets.MPAllowedEnemies[NPCID.Plantera] = true; - ItemID.Sets.SortingPriorityBossSpawns[Type] = 11; // Truffle Worm + ItemID.Sets.SortingPriorityBossSpawns[Type] = 11; // Pirate Map (1 above Mechanical Skull) } public override void SetDefaults() diff --git a/Items/SummonItems/ProfanedShard.cs b/Items/SummonItems/ProfanedShard.cs index f5e1076208..e65cceda1b 100644 --- a/Items/SummonItems/ProfanedShard.cs +++ b/Items/SummonItems/ProfanedShard.cs @@ -36,7 +36,7 @@ namespace CalamityMod.Items.SummonItems public override bool CanUseItem(Player player) { - return !NPC.AnyNPCs(ModContent.NPCType()) && (Main.dayTime || Main.remixWorld) && (player.ZoneHallow || player.ZoneUnderworldHeight) && !BossRushEvent.BossRushActive; + return !NPC.AnyNPCs(ModContent.NPCType()) && (player.ZoneHallow || player.ZoneUnderworldHeight) && !BossRushEvent.BossRushActive; } public override bool? UseItem(Player player) diff --git a/Items/SummonItems/SandstormsCore.cs b/Items/SummonItems/SandstormsCore.cs index 1426db53d5..32dba4f830 100644 --- a/Items/SummonItems/SandstormsCore.cs +++ b/Items/SummonItems/SandstormsCore.cs @@ -15,7 +15,7 @@ namespace CalamityMod.Items.SummonItems public new string LocalizationCategory => "Items.SummonItems"; public override void SetStaticDefaults() { - ItemID.Sets.SortingPriorityBossSpawns[Type] = 12; // Frost Legion + ItemID.Sets.SortingPriorityBossSpawns[Type] = 13; // Frost Legion } public override void SetDefaults() diff --git a/Items/SummonItems/Seafood.cs b/Items/SummonItems/Seafood.cs index f6618275c1..4d780eb9e0 100644 --- a/Items/SummonItems/Seafood.cs +++ b/Items/SummonItems/Seafood.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.SummonItems public new string LocalizationCategory => "Items.SummonItems"; public override void SetStaticDefaults() { - ItemID.Sets.SortingPriorityBossSpawns[Type] = 8; // Mechanical Worm + ItemID.Sets.SortingPriorityBossSpawns[Type] = 9; // Mechanical Worm } public override void SetDefaults() diff --git a/Items/VanillaArmorChanges/CrimsonArmorSetChange.cs b/Items/VanillaArmorChanges/CrimsonArmorSetChange.cs index c8314dbaac..d74e80cff3 100644 --- a/Items/VanillaArmorChanges/CrimsonArmorSetChange.cs +++ b/Items/VanillaArmorChanges/CrimsonArmorSetChange.cs @@ -14,17 +14,17 @@ namespace CalamityMod.Items.VanillaArmorChanges public override string ArmorSetName => "Crimson"; - public const float ArmorPieceDamage = 0.05f; + public const float ArmorPieceDamage = 0.06f; public const int ArmorPieceLifeRegen = 1; + public const int ChestPieceBonusLifeRegen = 1; // Set bonus clarification public override void UpdateSetBonusText(ref string setBonusText) { - Player player = Main.LocalPlayer; setBonusText = $"{CalamityUtils.GetTextValue($"Vanilla.Armor.SetBonus.{ArmorSetName}")}"; } - private void ApplyAnyPieceEffect(Player player) + private static void ApplyAnyPieceEffect(Player player) { // Remove the vanilla +3% damage and add the new damage value at the same time player.GetDamage() += ArmorPieceDamage - 0.03f; @@ -35,7 +35,11 @@ namespace CalamityMod.Items.VanillaArmorChanges public override void ApplyHeadPieceEffect(Player player) => ApplyAnyPieceEffect(player); - public override void ApplyBodyPieceEffect(Player player) => ApplyAnyPieceEffect(player); + public override void ApplyBodyPieceEffect(Player player) + { + ApplyAnyPieceEffect(player); + player.lifeRegen += ChestPieceBonusLifeRegen; + } public override void ApplyLegPieceEffect(Player player) => ApplyAnyPieceEffect(player); } diff --git a/Items/VanillaArmorChanges/MythrilArmorSetChange.cs b/Items/VanillaArmorChanges/MythrilArmorSetChange.cs index c92a58262a..772fad8a35 100644 --- a/Items/VanillaArmorChanges/MythrilArmorSetChange.cs +++ b/Items/VanillaArmorChanges/MythrilArmorSetChange.cs @@ -20,7 +20,7 @@ namespace CalamityMod.Items.VanillaArmorChanges public const int MaxManaBoost = 20; public const int FlareFrameSpawnDelay = 12; - public const int FlareDamageSoftcap = 50; + public const int FlareDamageSoftcap = 40; public override void UpdateSetBonusText(ref string setBonusText) { @@ -51,7 +51,7 @@ namespace CalamityMod.Items.VanillaArmorChanges // Reset the spawn delay. owner.Calamity().MythrilFlareSpawnCountdown = FlareFrameSpawnDelay; - int flareDamage = CalamityUtils.DamageSoftCap(originalDamage * 0.4, FlareDamageSoftcap); + int flareDamage = CalamityUtils.DamageSoftCap(originalDamage * 0.3, FlareDamageSoftcap); flareDamage = owner.ApplyArmorAccDamageBonusesTo(flareDamage); Vector2 flareSpawnPosition = victim.Center + Main.rand.NextVector2Circular(10f, 10f); diff --git a/Items/VanillaArmorChanges/ShadowArmorSetChange.cs b/Items/VanillaArmorChanges/ShadowArmorSetChange.cs index b046bb9c76..b93bb0d478 100644 --- a/Items/VanillaArmorChanges/ShadowArmorSetChange.cs +++ b/Items/VanillaArmorChanges/ShadowArmorSetChange.cs @@ -1,6 +1,5 @@ using Terraria; using Terraria.ID; -using Terraria.ModLoader; namespace CalamityMod.Items.VanillaArmorChanges { @@ -18,17 +17,14 @@ namespace CalamityMod.Items.VanillaArmorChanges public override string ArmorSetName => "Shadow"; - public const float ArmorPieceDamage = 0.05f; - public const float ArmorPieceJumpBoost = 0.07f; - - private void ApplyAnyPieceEffect(Player player) + private static void ApplyAnyPieceEffect(Player player) { - // Remove the vanilla crit chance buff and replace it with damage - player.GetCritChance() -= 5; - player.GetDamage() += ArmorPieceDamage; - - // Give jump boost - player.jumpSpeedBoost += 5f * ArmorPieceJumpBoost; + // 15MAY2024: Ozzatron: Removed all standard changes to Shadow Armor. + // As such, this method intentionally does nothing. + // + // Shadow Armor's movement speed boosting effect is separately nerfed via an IL edit. + // + // Class is being left here so that further changes can be made to Shadow Armor as needed. } public override void ApplyHeadPieceEffect(Player player) => ApplyAnyPieceEffect(player); diff --git a/Items/Weapons/DraedonsArsenal/PulseRifle.cs b/Items/Weapons/DraedonsArsenal/PulseRifle.cs index 21190b3ab9..9a68a38931 100644 --- a/Items/Weapons/DraedonsArsenal/PulseRifle.cs +++ b/Items/Weapons/DraedonsArsenal/PulseRifle.cs @@ -27,7 +27,7 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal { CalamityGlobalItem modItem = Item.Calamity(); - Item.width = 98; + Item.width = 100; Item.height = 32; Item.DamageType = DamageClass.Ranged; Item.damage = BaseDamage; @@ -37,7 +37,7 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal Item.autoReuse = true; Item.useStyle = ItemUseStyleID.Shoot; - Item.UseSound = null; + Item.UseSound = FireSound; Item.noMelee = true; Item.value = CalamityGlobalItem.RarityDarkBlueBuyPrice; @@ -53,7 +53,6 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - SoundEngine.PlaySound(FireSound); Projectile.NewProjectile(source, position, velocity, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f, 0f); return false; diff --git a/Items/Weapons/DraedonsArsenal/PulseRifle.png b/Items/Weapons/DraedonsArsenal/PulseRifle.png index 4075f9d594..bcb3e668d9 100644 Binary files a/Items/Weapons/DraedonsArsenal/PulseRifle.png and b/Items/Weapons/DraedonsArsenal/PulseRifle.png differ diff --git a/Items/Weapons/DraedonsArsenal/PulseRifleGlow.png b/Items/Weapons/DraedonsArsenal/PulseRifleGlow.png index 8a109d4ccf..49124dc1d0 100644 Binary files a/Items/Weapons/DraedonsArsenal/PulseRifleGlow.png and b/Items/Weapons/DraedonsArsenal/PulseRifleGlow.png differ diff --git a/Items/Weapons/Magic/AetherfluxCannon.cs b/Items/Weapons/Magic/AetherfluxCannon.cs index 11d3ad3d29..782fffeba9 100644 --- a/Items/Weapons/Magic/AetherfluxCannon.cs +++ b/Items/Weapons/Magic/AetherfluxCannon.cs @@ -39,11 +39,12 @@ namespace CalamityMod.Items.Weapons.Magic public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; + public override void HoldItem(Player player) => player.Calamity().mouseRotationListener = true; + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - Vector2 shootVelocity = velocity; - Vector2 shootDirection = shootVelocity.SafeNormalize(Vector2.UnitX * player.direction); - Projectile.NewProjectile(source, position, shootDirection, type, damage, knockback, player.whoAmI); + Vector2 spawnPosition = player.RotatedRelativePoint(player.MountedCenter, true); + Projectile.NewProjectileDirect(source, spawnPosition, player.Calamity().mouseWorld - spawnPosition, ModContent.ProjectileType(), damage, knockback, player.whoAmI); return false; } diff --git a/Items/Weapons/Magic/Genesis.cs b/Items/Weapons/Magic/Genesis.cs index 26a83161e8..44c82b67ff 100644 --- a/Items/Weapons/Magic/Genesis.cs +++ b/Items/Weapons/Magic/Genesis.cs @@ -11,7 +11,11 @@ namespace CalamityMod.Items.Weapons.Magic [LegacyName("Genisis")] public class Genesis : ModItem, ILocalizedModType { + public static float FireRate = 15f; + public static float StarterWindup = 60f; + public new string LocalizationCategory => "Items.Weapons.Magic"; + public override void SetDefaults() { Item.width = 108; @@ -34,17 +38,18 @@ namespace CalamityMod.Items.Weapons.Magic Item.shoot = ModContent.ProjectileType(); } - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] == 0; // Makes the rotation of the mouse around the player sync in multiplayer. public override void HoldItem(Player player) => player.Calamity().mouseRotationListener = true; + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - Projectile holdout = Projectile.NewProjectileDirect(source, player.MountedCenter, Vector2.Zero, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0, 0, 0); - holdout.velocity = (player.Calamity().mouseWorld - player.MountedCenter).SafeNormalize(Vector2.Zero); - + Projectile holdout = Projectile.NewProjectileDirect(source, player.MountedCenter, Vector2.Zero, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0, 0); + holdout.velocity = player.Calamity().mouseWorld - player.RotatedRelativePoint(player.MountedCenter); return false; } + public override void AddRecipes() { CreateRecipe(). diff --git a/Items/Weapons/Magic/GloriousEnd.cs b/Items/Weapons/Magic/GloriousEnd.cs index 29c4d96f19..59db80cd1d 100644 --- a/Items/Weapons/Magic/GloriousEnd.cs +++ b/Items/Weapons/Magic/GloriousEnd.cs @@ -31,5 +31,7 @@ namespace CalamityMod.Items.Weapons.Magic } public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; + + public override void HoldItem(Player player) => player.Calamity().mouseWorldListener = true; } } diff --git a/Items/Weapons/Magic/NanoPurge.cs b/Items/Weapons/Magic/NanoPurge.cs index 558c24ab99..a0522394b9 100644 --- a/Items/Weapons/Magic/NanoPurge.cs +++ b/Items/Weapons/Magic/NanoPurge.cs @@ -10,8 +10,9 @@ namespace CalamityMod.Items.Weapons.Magic [LegacyName("Purge")] public class NanoPurge : ModItem, ILocalizedModType { + public static int UseTime = 20; + public new string LocalizationCategory => "Items.Weapons.Magic"; - public const int UseTime = 20; public override void SetDefaults() { @@ -35,11 +36,12 @@ namespace CalamityMod.Items.Weapons.Magic public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; + public override void HoldItem(Player player) => player.Calamity().mouseRotationListener = true; + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - Vector2 shootVelocity = velocity; - Vector2 shootDirection = shootVelocity.SafeNormalize(Vector2.UnitX * player.direction); - Projectile.NewProjectile(source, position, shootDirection, type, damage, knockback, player.whoAmI); + Vector2 spawnPosition = player.RotatedRelativePoint(player.MountedCenter, true); + Projectile.NewProjectileDirect(source, spawnPosition, player.Calamity().mouseWorld - spawnPosition, ModContent.ProjectileType(), damage, knockback, player.whoAmI); return false; } diff --git a/Items/Weapons/Magic/Omicron.cs b/Items/Weapons/Magic/Omicron.cs index 5028c9f3a0..2f5274a96d 100644 --- a/Items/Weapons/Magic/Omicron.cs +++ b/Items/Weapons/Magic/Omicron.cs @@ -1,4 +1,6 @@ -using CalamityMod.Items.Materials; +using CalamityMod.CalPlayer; +using CalamityMod.DataStructures; +using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Magic; using CalamityMod.Rarities; using CalamityMod.Tiles.Furniture.CraftingStations; @@ -12,6 +14,10 @@ namespace CalamityMod.Items.Weapons.Magic { public class Omicron : ModItem, ILocalizedModType { + public static float FireRate = 15f; + public static float StarterWinup = 60f; + public static float WingmanFireRate = 10f; + public new string LocalizationCategory => "Items.Weapons.Magic"; public override void SetDefaults() @@ -37,7 +43,14 @@ namespace CalamityMod.Items.Weapons.Magic public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0 && player.ownedProjectileCounts[ModContent.ProjectileType()] < 2; // Makes the rotation of the mouse around the player sync in multiplayer. - public override void HoldItem(Player player) => player.Calamity().mouseRotationListener = true; + public override void HoldItem(Player player) + { + CalamityPlayer calPlayer = player.Calamity(); + calPlayer.mouseWorldListener = true; + calPlayer.mouseRotationListener = true; + calPlayer.rightClickListener = true; + } + 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 < 2; i++) diff --git a/Items/Weapons/Magic/Wingman.cs b/Items/Weapons/Magic/Wingman.cs index 1526be5dd7..b4960be3d1 100644 --- a/Items/Weapons/Magic/Wingman.cs +++ b/Items/Weapons/Magic/Wingman.cs @@ -35,7 +35,12 @@ namespace CalamityMod.Items.Weapons.Magic public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] < 2; // Makes the rotation of the mouse around the player sync in multiplayer. - public override void HoldItem(Player player) => player.Calamity().mouseRotationListener = true; + public override void HoldItem(Player player) + { + var modPlayer = player.Calamity(); + modPlayer.mouseRotationListener = true; + modPlayer.rightClickListener = true; + } 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/Basher.cs b/Items/Weapons/Melee/Basher.cs index ae3d491e6c..f63ec86d3d 100644 --- a/Items/Weapons/Melee/Basher.cs +++ b/Items/Weapons/Melee/Basher.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.Weapons.Melee { Item.width = 56; Item.height = 60; - Item.damage = 41; + Item.damage = 50; Item.DamageType = DamageClass.Melee; Item.useAnimation = Item.useTime = 40; Item.useStyle = ItemUseStyleID.Swing; diff --git a/Items/Weapons/Melee/DepthCrusher.cs b/Items/Weapons/Melee/DepthCrusher.cs index 1714581a67..86f994eb02 100644 --- a/Items/Weapons/Melee/DepthCrusher.cs +++ b/Items/Weapons/Melee/DepthCrusher.cs @@ -16,12 +16,12 @@ namespace CalamityMod.Items.Weapons.Melee { Item.width = 56; Item.height = 50; - Item.damage = 35; + Item.damage = 48; Item.knockBack = 7.25f; Item.useTime = 65; Item.useAnimation = 65; Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 3f; + Item.shootSpeed = 6f; Item.noMelee = true; Item.noUseGraphic = true; diff --git a/Items/Weapons/Melee/ElementalLance.cs b/Items/Weapons/Melee/ElementalLance.cs index 899b8a5f36..a4cf059a36 100644 --- a/Items/Weapons/Melee/ElementalLance.cs +++ b/Items/Weapons/Melee/ElementalLance.cs @@ -19,14 +19,14 @@ namespace CalamityMod.Items.Weapons.Melee { Item.width = 88; Item.height = 88; - Item.damage = 160; + Item.damage = 240; Item.DamageType = DamageClass.Melee; Item.noMelee = true; Item.useTurn = true; Item.noUseGraphic = true; - Item.useAnimation = 30; + Item.useAnimation = 45; Item.useStyle = ItemUseStyleID.Shoot; - Item.useTime = 30; + Item.useTime = 45; Item.knockBack = 9.5f; Item.UseSound = SoundID.Item1; Item.autoReuse = true; diff --git a/Items/Weapons/Ranged/Alluvion.cs b/Items/Weapons/Ranged/Alluvion.cs index 86ef655e99..a062ad960f 100644 --- a/Items/Weapons/Ranged/Alluvion.cs +++ b/Items/Weapons/Ranged/Alluvion.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 62; Item.height = 90; - Item.damage = 78; + Item.damage = 83; Item.DamageType = DamageClass.Ranged; Item.useTime = 15; Item.useAnimation = 30; diff --git a/Items/Weapons/Ranged/AngelicShotgun.cs b/Items/Weapons/Ranged/AngelicShotgun.cs index d2fce9bbca..bd1547fa45 100644 --- a/Items/Weapons/Ranged/AngelicShotgun.cs +++ b/Items/Weapons/Ranged/AngelicShotgun.cs @@ -21,14 +21,14 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 86; Item.height = 38; - Item.damage = 96; + Item.damage = 92; Item.knockBack = 3f; Item.DamageType = DamageClass.Ranged; Item.noMelee = true; Item.autoReuse = true; - Item.useTime = 24; - Item.useAnimation = 24; + Item.useTime = 26; + Item.useAnimation = 26; Item.UseSound = SoundID.Item38; Item.useStyle = ItemUseStyleID.Shoot; @@ -49,7 +49,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - int NumBullets = Main.rand.Next(5, 8); + int NumBullets = Main.rand.Next(5, 6+1); Vector2 baseVelocity = velocity.SafeNormalize(Vector2.Zero) * BulletSpeed; // If Musket Balls are used, damage is set to match Hallow-Point Rounds for both bullets and lasers @@ -71,7 +71,7 @@ namespace CalamityMod.Items.Weapons.Ranged // Spawn a beam from the sky ala Deathhail Staff or Lunar Flare float laserSpeed = 8f; - int laserDamage = 3 * damage; + int laserDamage = (int)(damage * 2.5f); float laserKB = 5f; Vector2 rrp = player.RotatedRelativePoint(player.MountedCenter, true); diff --git a/Items/Weapons/Ranged/ArcNovaDiffuser.cs b/Items/Weapons/Ranged/ArcNovaDiffuser.cs index c47d25ca28..2ce192c482 100644 --- a/Items/Weapons/Ranged/ArcNovaDiffuser.cs +++ b/Items/Weapons/Ranged/ArcNovaDiffuser.cs @@ -26,10 +26,8 @@ namespace CalamityMod.Items.Weapons.Ranged public new string LocalizationCategory => "Items.Weapons.Ranged"; - public override void SetStaticDefaults() - { - ItemID.Sets.IsRangedSpecialistWeapon[Item.type] = true; - } + public override void SetStaticDefaults() => ItemID.Sets.IsRangedSpecialistWeapon[Type] = true; + public override void SetDefaults() { Item.width = 58; @@ -53,6 +51,15 @@ namespace CalamityMod.Items.Weapons.Ranged public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; + public override void HoldItem(Player player) => player.Calamity().mouseWorldListener = true; + + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + Projectile holdout = Projectile.NewProjectileDirect(source, player.MountedCenter, Vector2.Zero, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0, 1); + holdout.velocity = player.Calamity().mouseWorld - player.RotatedRelativePoint(player.MountedCenter); + return false; + } + public override void AddRecipes() { CreateRecipe(). diff --git a/Items/Weapons/Ranged/ClockGatlignum.cs b/Items/Weapons/Ranged/ClockGatlignum.cs index 47e81821e0..422f865ff1 100644 --- a/Items/Weapons/Ranged/ClockGatlignum.cs +++ b/Items/Weapons/Ranged/ClockGatlignum.cs @@ -33,7 +33,7 @@ namespace CalamityMod.Items.Weapons.Ranged Item.Calamity().canFirePointBlankShots = true; } - public override Vector2? HoldoutOffset() => new Vector2(-5, 0); + public override Vector2? HoldoutOffset() => new Vector2(-14, 0); 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/Ranged/ClockGatlignum.png b/Items/Weapons/Ranged/ClockGatlignum.png index b3ec232734..d9483a7d49 100644 Binary files a/Items/Weapons/Ranged/ClockGatlignum.png and b/Items/Weapons/Ranged/ClockGatlignum.png differ diff --git a/Items/Weapons/Ranged/Condemnation.cs b/Items/Weapons/Ranged/Condemnation.cs index 9f80655ae3..8adb29a61a 100644 --- a/Items/Weapons/Ranged/Condemnation.cs +++ b/Items/Weapons/Ranged/Condemnation.cs @@ -44,10 +44,15 @@ namespace CalamityMod.Items.Weapons.Ranged public override void HoldItem(Player player) { - if (Main.myPlayer == player.whoAmI) - player.Calamity().rightClickListener = true; + var calPlayer = player.Calamity(); - if (player.Calamity().mouseRight && player.ownedProjectileCounts[ModContent.ProjectileType()] <= 0) + if (Main.myPlayer == player.whoAmI) + { + calPlayer.rightClickListener = true; + calPlayer.mouseRotationListener = true; + } + + if (calPlayer.mouseRight && player.ownedProjectileCounts[ModContent.ProjectileType()] <= 0) { Item.noUseGraphic = false; } diff --git a/Items/Weapons/Ranged/Disseminator.cs b/Items/Weapons/Ranged/Disseminator.cs index a777199c5a..255bbf4bc3 100644 --- a/Items/Weapons/Ranged/Disseminator.cs +++ b/Items/Weapons/Ranged/Disseminator.cs @@ -14,10 +14,10 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 66; Item.height = 24; - Item.damage = 58; + Item.damage = 61; Item.DamageType = DamageClass.Ranged; - Item.useTime = 35; - Item.useAnimation = 35; + Item.useTime = 32; + Item.useAnimation = 32; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 4.5f; diff --git a/Items/Weapons/Ranged/ElementalEruption.cs b/Items/Weapons/Ranged/ElementalEruption.cs index 8c8449aafd..e282838825 100644 --- a/Items/Weapons/Ranged/ElementalEruption.cs +++ b/Items/Weapons/Ranged/ElementalEruption.cs @@ -14,10 +14,7 @@ namespace CalamityMod.Items.Weapons.Ranged public int FlareCounter = 0; - public override void SetStaticDefaults() - { - ItemID.Sets.ItemsThatAllowRepeatedRightClick[Item.type] = true; - } + public override void SetStaticDefaults() => ItemID.Sets.ItemsThatAllowRepeatedRightClick[Type] = true; public override void SetDefaults() { @@ -41,13 +38,18 @@ namespace CalamityMod.Items.Weapons.Ranged } public override Vector2? HoldoutOffset() => new Vector2(-10, 0); + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; + public override void HoldItem(Player player) => player.Calamity().mouseWorldListener = true; + // Spawning the holdout cannot consume ammo public override bool CanConsumeAmmo(Item ammo, Player player) => player.ownedProjectileCounts[Item.shoot] > 0; + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - Projectile.NewProjectile(source, position, Vector2.Zero, type, 0, 0f, player.whoAmI); + Projectile holdout = Projectile.NewProjectileDirect(source, player.MountedCenter, Vector2.Zero, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0, 1); + holdout.velocity = player.Calamity().mouseWorld - player.RotatedRelativePoint(player.MountedCenter); return false; } diff --git a/Items/Weapons/Ranged/FrostbiteBlaster.cs b/Items/Weapons/Ranged/FrostbiteBlaster.cs index 470c62ed7a..38f5f1dca7 100644 --- a/Items/Weapons/Ranged/FrostbiteBlaster.cs +++ b/Items/Weapons/Ranged/FrostbiteBlaster.cs @@ -34,6 +34,8 @@ namespace CalamityMod.Items.Weapons.Ranged Item.Calamity().canFirePointBlankShots = true; } + public override Vector2? HoldoutOffset() => new Vector2(-14, 0); + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { SoundEngine.PlaySound(SoundID.Item36, position); diff --git a/Items/Weapons/Ranged/HavocsBreath.cs b/Items/Weapons/Ranged/HavocsBreath.cs index efad9edd1e..fa23d2cd9b 100644 --- a/Items/Weapons/Ranged/HavocsBreath.cs +++ b/Items/Weapons/Ranged/HavocsBreath.cs @@ -20,6 +20,7 @@ namespace CalamityMod.Items.Weapons.Ranged Item.useTime = 5; Item.useAnimation = 35; Item.reuseDelay = 20; + Item.useLimitPerAnimation = 7; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 1.5f; diff --git a/Items/Weapons/Ranged/Leviatitan.cs b/Items/Weapons/Ranged/Leviatitan.cs index 2e83fff9d7..2130046725 100644 --- a/Items/Weapons/Ranged/Leviatitan.cs +++ b/Items/Weapons/Ranged/Leviatitan.cs @@ -14,10 +14,10 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 82; Item.height = 28; - Item.damage = 80; + Item.damage = 77; Item.DamageType = DamageClass.Ranged; - Item.useTime = 9; - Item.useAnimation = 9; + Item.useTime = 10; + Item.useAnimation = 10; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 5f; diff --git a/Items/Weapons/Ranged/MagnaCannon.cs b/Items/Weapons/Ranged/MagnaCannon.cs index 4a320fba08..aa926fe2ab 100644 --- a/Items/Weapons/Ranged/MagnaCannon.cs +++ b/Items/Weapons/Ranged/MagnaCannon.cs @@ -22,10 +22,8 @@ namespace CalamityMod.Items.Weapons.Ranged public new string LocalizationCategory => "Items.Weapons.Ranged"; - public override void SetStaticDefaults() - { - ItemID.Sets.IsRangedSpecialistWeapon[Item.type] = true; - } + public override void SetStaticDefaults() => ItemID.Sets.IsRangedSpecialistWeapon[Item.type] = true; + public override void SetDefaults() { Item.width = 56; @@ -49,6 +47,15 @@ namespace CalamityMod.Items.Weapons.Ranged public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; + public override void HoldItem(Player player) => player.Calamity().mouseRotationListener = true; + + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + Vector2 spawnPosition = player.RotatedRelativePoint(player.MountedCenter); + Projectile.NewProjectileDirect(source, spawnPosition, player.Calamity().mouseWorld - player.RotatedRelativePoint(player.MountedCenter), ModContent.ProjectileType(), damage, knockback, player.whoAmI); + return false; + } + public override void AddRecipes() { CreateRecipe(). diff --git a/Items/Weapons/Ranged/MineralMortar.cs b/Items/Weapons/Ranged/MineralMortar.cs index aef7481495..2b06fe3f35 100644 --- a/Items/Weapons/Ranged/MineralMortar.cs +++ b/Items/Weapons/Ranged/MineralMortar.cs @@ -43,11 +43,8 @@ namespace CalamityMod.Items.Weapons.Ranged public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - Projectile holdout = Projectile.NewProjectileDirect(source, player.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, player.whoAmI); - - // We set the rotation to the direction to the mouse so the first frame doesn't appear bugged out. - holdout.rotation = (player.Calamity().mouseWorld - player.MountedCenter).SafeNormalize(Vector2.Zero).ToRotation(); - + Vector2 spawnPosition = player.RotatedRelativePoint(player.MountedCenter, true); + Projectile.NewProjectileDirect(source, spawnPosition, player.Calamity().mouseWorld - spawnPosition, ModContent.ProjectileType(), 0, 0f, player.whoAmI); return false; } diff --git a/Items/Weapons/Ranged/NitroExpressRifle.cs b/Items/Weapons/Ranged/NitroExpressRifle.cs index 8964b33364..eab45c79d1 100644 --- a/Items/Weapons/Ranged/NitroExpressRifle.cs +++ b/Items/Weapons/Ranged/NitroExpressRifle.cs @@ -32,7 +32,7 @@ namespace CalamityMod.Items.Weapons.Ranged Item.value = CalamityGlobalItem.RarityLightRedBuyPrice; Item.UseSound = FireSound; Item.autoReuse = true; - Item.shoot = ModContent.ProjectileType(); + Item.shoot = ProjectileID.Bullet; Item.shootSpeed = 12f; Item.useAmmo = AmmoID.Bullet; Item.rare = ItemRarityID.LightRed; @@ -66,7 +66,9 @@ namespace CalamityMod.Items.Weapons.Ranged public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { player.velocity += -velocity * 0.3f; - Projectile.NewProjectile(source, position, velocity, ModContent.ProjectileType(), damage, knockback, player.whoAmI, 0f); + if (type == ProjectileID.Bullet) + type = ModContent.ProjectileType(); + Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI, 0f); return false; } diff --git a/Items/Weapons/Ranged/OpalStriker.cs b/Items/Weapons/Ranged/OpalStriker.cs index b7add585c2..2367059962 100644 --- a/Items/Weapons/Ranged/OpalStriker.cs +++ b/Items/Weapons/Ranged/OpalStriker.cs @@ -21,10 +21,8 @@ namespace CalamityMod.Items.Weapons.Ranged public static int AftershotCooldownFrames = 17; public static int FullChargeFrames = 88; - public override void SetStaticDefaults() - { - ItemID.Sets.IsRangedSpecialistWeapon[Item.type] = true; - } + public override void SetStaticDefaults() => ItemID.Sets.IsRangedSpecialistWeapon[Type] = true; + public override void SetDefaults() { Item.width = 48; @@ -48,6 +46,15 @@ namespace CalamityMod.Items.Weapons.Ranged public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; + public override void HoldItem(Player player) => player.Calamity().mouseRotationListener = true; + + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + Vector2 spawnPosition = player.RotatedRelativePoint(player.MountedCenter, true); + Projectile.NewProjectileDirect(source, spawnPosition, player.Calamity().mouseWorld - spawnPosition, ModContent.ProjectileType(), damage, knockback, player.whoAmI); + return false; + } + public override void AddRecipes() { CreateRecipe(). diff --git a/Items/Weapons/Ranged/Phangasm.cs b/Items/Weapons/Ranged/Phangasm.cs index 5f4e9d8ac4..7a8aab8725 100644 --- a/Items/Weapons/Ranged/Phangasm.cs +++ b/Items/Weapons/Ranged/Phangasm.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 48; Item.height = 82; - Item.damage = 87; + Item.damage = 117; Item.useTime = 12; Item.useAnimation = 12; Item.useStyle = ItemUseStyleID.Shoot; diff --git a/Items/Weapons/Ranged/RealmRavager.cs b/Items/Weapons/Ranged/RealmRavager.cs index 2f0bbf6805..baaed6a188 100644 --- a/Items/Weapons/Ranged/RealmRavager.cs +++ b/Items/Weapons/Ranged/RealmRavager.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 76; Item.height = 32; - Item.damage = 50; + Item.damage = 54; Item.DamageType = DamageClass.Ranged; Item.useTime = 22; Item.useAnimation = 22; @@ -35,11 +35,11 @@ namespace CalamityMod.Items.Weapons.Ranged public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - int numBullets = Main.rand.NextBool() ? 4 : 3; + int numBullets = 4; for (int index = 0; index < numBullets; ++index) { - float SpeedX = velocity.X + Main.rand.Next(-75, 76) * 0.05f; - float SpeedY = velocity.Y + Main.rand.Next(-75, 76) * 0.05f; + float SpeedX = velocity.X + (index == 0 ? 0 : Main.rand.Next(-75, 76) * 0.05f); + float SpeedY = velocity.Y + (index == 0 ? 0 : Main.rand.Next(-75, 76) * 0.05f); if (type == ProjectileID.Bullet) Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, ModContent.ProjectileType(), damage, knockback, player.whoAmI); diff --git a/Items/Weapons/Ranged/Shadethrower.cs b/Items/Weapons/Ranged/Shadethrower.cs index a212cfe9d1..ddb3786745 100644 --- a/Items/Weapons/Ranged/Shadethrower.cs +++ b/Items/Weapons/Ranged/Shadethrower.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Ranged Item.damage = 23; Item.DamageType = DamageClass.Ranged; Item.useTime = 10; - Item.useAnimation = 30; + Item.useAnimation = 40; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 1.5f; diff --git a/Items/Weapons/Ranged/SparkSpreader.cs b/Items/Weapons/Ranged/SparkSpreader.cs index 8b292401c2..8ff1657262 100644 --- a/Items/Weapons/Ranged/SparkSpreader.cs +++ b/Items/Weapons/Ranged/SparkSpreader.cs @@ -13,12 +13,14 @@ namespace CalamityMod.Items.Weapons.Ranged { Item.width = 56; Item.height = 26; - Item.damage = 10; + Item.damage = 16; Item.knockBack = 1f; Item.DamageType = DamageClass.Ranged; Item.autoReuse = true; Item.useTime = 12; - Item.useAnimation = 36; + Item.useAnimation = 48; + Item.reuseDelay = 12; + Item.useLimitPerAnimation = 4; Item.useAmmo = AmmoID.Gel; Item.consumeAmmoOnFirstShotOnly = true; Item.shootSpeed = 6f; diff --git a/Items/Weapons/Ranged/TheHive.cs b/Items/Weapons/Ranged/TheHive.cs index 2092626a5c..89e585472d 100644 --- a/Items/Weapons/Ranged/TheHive.cs +++ b/Items/Weapons/Ranged/TheHive.cs @@ -14,6 +14,7 @@ namespace CalamityMod.Items.Weapons.Ranged { public new string LocalizationCategory => "Items.Weapons.Ranged"; + public static float MaxCharge = 90f; public static int OriginalUseTime = 34; public override void SetDefaults() diff --git a/Items/Weapons/Ranged/WildfireBloom.cs b/Items/Weapons/Ranged/WildfireBloom.cs index b6c2286b1a..d821089aeb 100644 --- a/Items/Weapons/Ranged/WildfireBloom.cs +++ b/Items/Weapons/Ranged/WildfireBloom.cs @@ -39,13 +39,21 @@ namespace CalamityMod.Items.Weapons.Ranged } public override Vector2? HoldoutOffset() => new Vector2(-10, 0); + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; + public override void HoldItem(Player player) => player.Calamity().mouseWorldListener = true; + // Spawning the holdout cannot consume ammo public override bool CanConsumeAmmo(Item ammo, Player player) => player.ownedProjectileCounts[Item.shoot] > 0; + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - Projectile.NewProjectile(source, position, Vector2.Zero, type, 0, 0f, player.whoAmI); + Projectile holdout = Projectile.NewProjectileDirect(source, position, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, player.whoAmI); + + // We set the rotation to the direction to the mouse so the first frame doesn't appear bugged out. + holdout.velocity = (player.Calamity().mouseWorld - player.MountedCenter).SafeNormalize(Vector2.Zero); + return false; } diff --git a/Items/Weapons/Rogue/AlphaVirus.cs b/Items/Weapons/Rogue/AlphaVirus.cs index 2cedc925c2..136298988c 100644 --- a/Items/Weapons/Rogue/AlphaVirus.cs +++ b/Items/Weapons/Rogue/AlphaVirus.cs @@ -32,6 +32,8 @@ namespace CalamityMod.Items.Weapons.Rogue Item.DamageType = RogueDamageClass.Instance; } + public override float StealthDamageMultiplier => 0.70f; + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { if (player.Calamity().StealthStrikeAvailable()) diff --git a/Items/Weapons/Summon/HarvestStaff.cs b/Items/Weapons/Summon/HarvestStaff.cs index f16756177b..96da01b29c 100644 --- a/Items/Weapons/Summon/HarvestStaff.cs +++ b/Items/Weapons/Summon/HarvestStaff.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Weapons.Summon public override void SetDefaults() { - Item.damage = 26; + Item.damage = 27; Item.DamageType = DamageClass.Summon; Item.shoot = ModContent.ProjectileType(); Item.knockBack = 5f; diff --git a/Items/Weapons/Summon/LiliesOfFinality.cs b/Items/Weapons/Summon/LiliesOfFinality.cs index 849286cb14..7e441ab524 100644 --- a/Items/Weapons/Summon/LiliesOfFinality.cs +++ b/Items/Weapons/Summon/LiliesOfFinality.cs @@ -59,8 +59,8 @@ namespace CalamityMod.Items.Weapons.Summon public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - Projectile.NewProjectileDirect(source, Main.MouseWorld, new Vector2(-1f, -1f) * 3f, type, damage, knockback, player.whoAmI); - Projectile.NewProjectileDirect(source, Main.MouseWorld, new Vector2(1f, -1f) * 3f, ProjectileType(), damage, knockback, player.whoAmI); + Projectile.NewProjectileDirect(source, player.Calamity().mouseWorld, new Vector2(-1f, -1f) * 3f, type, damage, knockback, player.whoAmI); + Projectile.NewProjectileDirect(source, player.Calamity().mouseWorld, new Vector2(1f, -1f) * 3f, ProjectileType(), damage, knockback, player.whoAmI); if (Main.dedServ) return false; diff --git a/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson b/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson index 5726d7ac9a..3404dbabe0 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson @@ -102,7 +102,7 @@ AlchemicalFlask: { DisplayName: Alchemical Flask Tooltip: ''' - All attacks inflict the Plague and grants immunity to the Plague + All attacks inflict the Plague and reduces damage taken from the Plague Projectiles spawn plague seekers on enemy hits ''' } @@ -136,10 +136,10 @@ AmbrosialAmpoule: { DisplayName: Ambrosial Ampoule Tooltip: ''' - +70 max life + +50 max life Grants +2 to +6 HP/s life regen based on missing health - Provides life regeneration equivalent to standing in Honey - Standing still grants extremely powerful regen + Grants +1 HP/s life regen and an additional 1 HP/s life regen when inflicted with a damage debuff + Standing still grants +1.5 HP/s life regen Halves how long you are afflicted with fire and sickness debuffs You emit yellow light if visibility is enabled ''' @@ -428,7 +428,7 @@ CrawCarapace: { DisplayName: Craw Carapace Tooltip: ''' - 5% increased damage + 7% increased damage Enemies that hit you take damage and are inflicted with Crumbling ''' } @@ -437,7 +437,7 @@ Baroclaw: { DisplayName: Baroclaw Tooltip: ''' - 10% increased damage + 10% increased damage and 5% increased damage reduction Enemies that hit you take high damage and are inflicted with Armor Crunch and Crush Depth ''' } @@ -885,8 +885,9 @@ HallowedRune: { Tooltip: ''' Whenever your minions hit an enemy you will gain a random buff, does not stack with downgrades - These buffs will either boost your defense, summon damage, or life regen for a while - If you have the offensive boost, enemies hit by minions will sometimes be hit by stars + Hallowed Power increases summon damage by 10% and makes minion hits rain stars + Hallowed Defense increases defense by 8 and DR by 4% + Hallowed Regen grants +1.5 HP/s life regeneration ''' } @@ -935,8 +936,8 @@ HoneyDew: { Tooltip: ''' +30 max life - Provides life regeneration equivalent to standing in Honey - Standing still in Honey grants extremely powerful regen + Grants +1 HP/s life regen and an additional 1 HP/s life regen when inflicted with a damage debuff + Standing still in Honey grants +1.5 HP/s life regen Halves how long you are afflicted with sickness debuffs ''' } @@ -1023,8 +1024,8 @@ LivingDew: { Tooltip: ''' +50 max life - Provides life regeneration equivalent to standing in Honey - Standing still in Honey grants extremely powerful regen + Grants +1 HP/s life regen and an additional 1 HP/s life regen when inflicted with a damage debuff + Standing still in Honey grants +1.5 HP/s life regen Halves how long you are afflicted with fire and sickness debuffs ''' } @@ -1064,8 +1065,7 @@ ManaPolarizer: { ''' Increases max mana by 50 and magic damage by 6% -1.5 HP/s life regen if mana is above 50% of its maximum - Grants spectre healing, the amount healed scales with your mana - The healing only works while holding a magic weapon + Magic projectiles give lifesteal while holding a magic weapon The more mana you have, the more you heal ''' } @@ -1243,10 +1243,9 @@ PhantomicArtifact: { Tooltip: ''' Whenever your minions hit an enemy you will gain a random phantomic buff, does not stack with downgrades - These buffs will either boost your defense, summon damage, or life regen for a while - If you have the offensive boost, enemies hit by minions will sometimes be hit by phantomic knives - If you have the regenerative boost, a phantomic heart will occasionally materialise granting massive health regen - If you have the defensive boost, a phantomic bulwark will absorb 20% of the next projectile's damage that hits the bulwark, shattering it + Phantomic Empowerment increases summon damage by 10% and makes minion hits spawn phantomic knives + Phantomic Shield increases defense by 10 and DR by 5% and spawns a phantomic bulwark which absorbs 20% of the next projectile's damage that touches it + Phantomic Regen grants +2 HP/s life regen and spawns a phantomic heart which grants an additional 2 HP/s life regen when touched ''' } @@ -1331,10 +1330,10 @@ Radiance: { DisplayName: Radiance Tooltip: ''' - +100 max life - Grants +3 to +7 HP/s life regen based on missing health - Provides life regeneration equivalent to standing in Honey - Standing still grants extremely powerful regen + +70 max life + Grants +2 to +6 HP/s life regen based on missing health + Grants +1 HP/s life regen and an additional 1 HP/s life regen when inflicted with a damage debuff + Standing still grants +2 HP/s life regen Grants 20 defense and continuous healing while afflicted with any debuff The healing eventually slows down if debuffed for an extended period of time Massively boosts natural life regen while afflicted with any debuff @@ -1587,7 +1586,9 @@ SpiritGlyph: { Tooltip: ''' Whenever your minions hit an enemy you will gain a random buff - These buffs will either boost your defense, summon damage, or life regen for a while + Spirit Power increases summon damage by 10% + Spirit Defense increases defense by 6 and DR by 3% + Spirit Regen grants +1 HP/s life regeneration ''' } diff --git a/Localization/en-US/Mods.CalamityMod.Items.Ammo.hjson b/Localization/en-US/Mods.CalamityMod.Items.Ammo.hjson index ee6be6c217..e582fd1bcc 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Ammo.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Ammo.hjson @@ -50,6 +50,11 @@ CinderArrow: { Tooltip: Explosive arrows that burst into weak flaming shards that inflict Brimstone Flames } +DryadsTear: { + DisplayName: Dryad's Tear + Tooltip: Splits into homing nature shards on impact which ignore enemy defense +} + ElysianArrow: { DisplayName: Elysian Arrow Tooltip: @@ -98,7 +103,7 @@ HailstormBullet: { ''' Bullets imbued with potent ice magic These bullets rapidly decelerate after being fired - Critical hits cause a flash freeze, dealing additional damage + Critical hits cause a flash freeze, dealing additional damage and freezing normal enemies ''' } @@ -159,11 +164,6 @@ SproutingArrow: { ''' } -DryadsTear: { - DisplayName: Dryad's Tear - Tooltip: Explodes and splits into homing nature shards on impact -} - VanquisherArrow: { DisplayName: Vanquisher Arrow Tooltip: diff --git a/Localization/en-US/Mods.CalamityMod.Items.Armor.PostMoonLord.hjson b/Localization/en-US/Mods.CalamityMod.Items.Armor.PostMoonLord.hjson index 06272e4042..f4e3ddf84b 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Armor.PostMoonLord.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Armor.PostMoonLord.hjson @@ -527,7 +527,7 @@ TarragonHeadMelee: { ''' 15% increased melee speed Enemies are more likely to target you - You gain a life regen buff when you take damage + Taking damage gives the Tarra Life buff, which grants +1.5 HP/s life regen Press {0} to cloak yourself in life energy that heavily reduces enemy contact damage for 10 seconds This has a 30 second cooldown ''' diff --git a/Localization/en-US/Mods.CalamityMod.Items.Armor.PreHardmode.hjson b/Localization/en-US/Mods.CalamityMod.Items.Armor.PreHardmode.hjson index b1f4f411f9..ab21fcb087 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Armor.PreHardmode.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Armor.PreHardmode.hjson @@ -186,7 +186,7 @@ StatigelHeadSummon: { SulphurousBreastplate: { DisplayName: Sulphurous Breastplate - Tooltip: 8% increased rogue damage and 5% increased rogue critical strike chance + Tooltip: 6% increased rogue damage and 4% increased rogue critical strike chance } SulphurousHelmet: { @@ -199,7 +199,7 @@ SulphurousHelmet: { ''' SetBonus: ''' - +70 maximum stealth + +65 maximum stealth Attacking and being attacked by enemies inflicts poison Grants an additional jump that summons a sulphurous bubble Provides increased underwater mobility and reduces the severity of the sulphuric waters diff --git a/Localization/en-US/Mods.CalamityMod.Items.Fishing.hjson b/Localization/en-US/Mods.CalamityMod.Items.Fishing.hjson index 8e96193a93..433e0e4d83 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Fishing.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Fishing.hjson @@ -54,8 +54,8 @@ Bloodfin: { DisplayName: Bloodfin Tooltip: ''' - Grants a buff that boosts life regen for 10 seconds - The life regen boost is stronger if below 75% health + Grants a buff that grants +2.5 HP/s life regen + This buff directly restores HP if below 75% health 10 second duration 'The wonders of angiogenesis' ''' diff --git a/Localization/en-US/Mods.CalamityMod.Items.Placeables.hjson b/Localization/en-US/Mods.CalamityMod.Items.Placeables.hjson index 2db3dd95ea..ddb61fbc36 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Placeables.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Placeables.hjson @@ -360,7 +360,7 @@ AstrumAureusRelic: { AstrumDeusRelic: { DisplayName: Astrum Deus Relic - Tooltip: A glimpse into what could have been... + Tooltip: "" } BrimstoneElementalRelic: { @@ -523,7 +523,6 @@ AltarOfTheAccursedItem: { ''' Offer Ashes of Calamity at this altar to summon the Witch Doing so will create a square arena of blocks, with the altar at its center - During the battle, heart pickups only heal for half as much The Witch enrages while you are outside of the arena {$CommonItemTooltip.SpecialCrafting} ''' @@ -730,7 +729,7 @@ ResilientCandle: { DisplayName: Resilient Candle Tooltip: ''' - When placed, nearby players' defense blocks 15% more damage + When placed, nearby players' defense blocks 10% more damage 'Neither rain nor wind can snuff its undying flame' ''' } @@ -984,7 +983,7 @@ WeightlessCandle: { DisplayName: Weightless Candle Tooltip: ''' - When placed, nearby players gain 10% movement speed, 10% wing time and 5% acceleration + When placed, nearby players gain 5% increased movement speed, wing time and acceleration 'The floating flame seems to uplift your very spirit' ''' } diff --git a/Localization/en-US/Mods.CalamityMod.Items.Potions.hjson b/Localization/en-US/Mods.CalamityMod.Items.Potions.hjson index 0c7a8a0250..94bfd6c74c 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Potions.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Potions.hjson @@ -18,7 +18,7 @@ Baguette: { Tooltip: ''' {$CommonItemTooltip.MinorStats} - Boosts the effects of Red Wine + Red Wine heals 250 HP, but reduces life regen by 2 HP/s [c/FCE391:'je suis Monte'] ''' } @@ -104,7 +104,8 @@ PhotosynthesisPotion: { DisplayName: Photosynthesis Potion Tooltip: ''' - You regen life quickly while not moving, this effect is five times as strong during daytime + Grants +0.5 HP/s life regen and accelerates natural life regen while not moving + This natural life regen effect is five times as strong during daytime Dropped hearts heal more HP ''' } diff --git a/Localization/en-US/Mods.CalamityMod.Items.SummonItems.hjson b/Localization/en-US/Mods.CalamityMod.Items.SummonItems.hjson index 09de1c4991..9329498724 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.SummonItems.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.SummonItems.hjson @@ -231,11 +231,14 @@ ProfanedShard: { Tooltip: ''' [SPAWN] - Enrage when not in the Hallow or Underworld Not consumable 'Her Guardians seek the holder of such vast stolen power.' ''' - SpawnNormal: Summons the Profaned Guardians when used in the Hallow or Underworld during daytime + SpawnNormal: + ''' + Summons the Profaned Guardians when used in the Hallow or Underworld + Enrages when fought during nighttime + ''' SpawnRemix: Summons the Profaned Guardians when used in the Hallow or Underworld } @@ -302,11 +305,7 @@ Teratoma: { Terminus: { DisplayName: Terminus GFBName: Ogscule - Tooltip: - ''' - Activates Boss Rush Mode, using it again will deactivate Boss Rush Mode - During the Boss Rush, all wires and wired devices will be disabled - ''' + Tooltip: Activates Boss Rush Mode, using it again will deactivate Boss Rush Mode } YharonEgg: { diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson index 900842eba5..7c20016cf2 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson @@ -392,11 +392,6 @@ HadalUrn: { ''' } -HarvestStaff: { - DisplayName: Harvest Staff - Tooltip: Casts flaming pumpkins -} - HeliumFlash: { DisplayName: Helium Flash Tooltip: @@ -861,11 +856,7 @@ Tradewinds: { UltraLiquidator: { DisplayName: Ultra Liquidator - Tooltip: - ''' - Summons liquidation blades that summon more blades on enemy hits - The blades inflict ichor, cursed inferno and brimstone flames - ''' + Tooltip: Summons liquidation blades that summon more blades on enemy hits } UndinesRetribution: { diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Melee.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Melee.hjson index afeab0b76b..88b9e92839 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Melee.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Melee.hjson @@ -287,7 +287,7 @@ CosmicDischarge: { Tooltip: ''' Striking an enemy with the whip causes glacial explosions and grants the player the cosmic freeze buff - This buff gives the player increased life regen while standing still and freezes enemies near the player + This buff gives the player +2 HP/s life regen while standing still and freezes enemies near the player ''' } @@ -707,7 +707,7 @@ Lacerator: { DisplayName: Lacerator Tooltip: ''' - Enemies that are hit by the yoyo will have their life drained + Accelerates natural life regeneration on hits with the yoyo An exceptionally agile yoyo [GFB] ''' diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson index 1afa9921f4..548c6fcb2c 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson @@ -987,7 +987,7 @@ RealmRavager: { DisplayName: Realm Ravager Tooltip: ''' - Shoots a burst of 3 to 4 bullets + Shoots a burst of 4 bullets Converts musket balls into explosive bullets ''' } diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Rogue.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Rogue.hjson index abd9755e31..69ed27ce98 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Rogue.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Rogue.hjson @@ -193,7 +193,7 @@ CorpusAvertor: { Attacks grant lifesteal based on damage dealt The lower your HP the more damage this weapon does and heals the player on enemy hits Stealth strikes throw a single rainbow outlined dagger - On enemy hits, this dagger boosts the damage and life regen of all members of your team + On enemy hits, this dagger grants 10% damage and +2 HP/s life regen to all members of your team However, there is a small chance it will cut your health in half instead 'Seems like it has worn down over time' ''' diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson index 0b7073c368..2fa9a00315 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson @@ -789,7 +789,7 @@ WulfrumController: { Summons a wulfrum droid to fight for you Hold right click while holding the remote to switch all of your drones into supercharge mode Supercharged droids will stop attacking and focus wulfrum energy onto you - The beam provides extra regeneration and defense + Supercharged droids provide +0.5 HP/s life regen and 3 defense per droid Can also be used to heal other players by keeping your mouse cursor close enough to them ''' } diff --git a/Localization/en-US/Mods.CalamityMod.NPCs.hjson b/Localization/en-US/Mods.CalamityMod.NPCs.hjson index 1d7421b644..42d943f37f 100644 --- a/Localization/en-US/Mods.CalamityMod.NPCs.hjson +++ b/Localization/en-US/Mods.CalamityMod.NPCs.hjson @@ -623,3 +623,7 @@ WITCH: { Princess_LovesNPC: "{NPCName} is always lonely, it's why I want to hang out with her, no one should be left alone like that!" } } + +KingSlimeJewelEmerald.DisplayName: King Slime Jewel Emerald +KingSlimeJewelRuby.DisplayName: King Slime Jewel Ruby +KingSlimeJewelSapphire.DisplayName: King Slime Jewel Sapphire diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Melee.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Melee.hjson index 6f5c733c72..f49ed13e17 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Melee.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Melee.hjson @@ -268,8 +268,8 @@ TaintedBladeSlasher.DisplayName: Tainted Blade TenebreusTidesWaterProjectile.DisplayName: Water Spear TenebreusTidesWaterSpear.DisplayName: Tenebreus Tides Water Spear TenebreusTidesWaterSword.DisplayName: Tenebreus Tides Water Sword -TerratomereBeam.DisplayName: Terra Slash Beam -TerratomereBigSlash.DisplayName: Terratomere Slash +TerratomereMeleeSlash.DisplayName: Terratomere Slash +TerratomereSwordBeam.DisplayName: Terra Slash Beam TerratomereExplosion.DisplayName: Terratomere Explosion TerratomereHoldoutProj.DisplayName: Terratomere TerratomereSlash.DisplayName: Terratomere Slash diff --git a/Localization/en-US/Mods.CalamityMod.UI.hjson b/Localization/en-US/Mods.CalamityMod.UI.hjson index 6b9aaf1a93..47a076ebb1 100644 --- a/Localization/en-US/Mods.CalamityMod.UI.hjson +++ b/Localization/en-US/Mods.CalamityMod.UI.hjson @@ -261,7 +261,7 @@ Communication: { The final to begin construction was Artemis. Rather than being founded on raw power, it was made to be the apex of speed and accuracy. There is elegance in simplicity, for all of Artemis' combat efficacy comes from an onboard predictive AI and a battery of hard-light bolt emitters.\n - It was the perfect partner to its twin and required no revisions. Organic beings are naturally inclined to fixate their senses on fire, presenting Artemis with the perfect opportunity to strike with unparalleled precision. + It was the perfect partner to its twin and required only a single revision. Organic beings are naturally inclined to fixate their senses on fire, presenting Artemis with the perfect opportunity to strike with unparalleled precision. ''' } diff --git a/ModSupport/WeakReferenceSupport.cs b/ModSupport/WeakReferenceSupport.cs index 8b86ba908d..fbf4dbf23b 100644 --- a/ModSupport/WeakReferenceSupport.cs +++ b/ModSupport/WeakReferenceSupport.cs @@ -295,9 +295,9 @@ namespace CalamityMod // Enemies EnemyRedirect(NPCType(), "Hive (enemy)"); - EnemyRedirect(NPCType(), "Ruby Jewel (enemy)"); - EnemyRedirect(NPCType(), "Sapphire Jewel (enemy)"); - EnemyRedirect(NPCType(), "Emerald Jewel (enemy)"); + EnemyRedirect(NPCType(), "Crown Jewels"); + EnemyRedirect(NPCType(), "Crown Jewels"); + EnemyRedirect(NPCType(), "Crown Jewels"); EnemyRedirect(NPCType(), "Tooth Ball (Old Duke)"); EnemyRedirect(NPCType(), "Enchantment"); EnemyRedirect(NPCType(), "%3F%3F%3F"); diff --git a/NPCs/Abyss/ColossalSquid.cs b/NPCs/Abyss/ColossalSquid.cs index 3081a1a826..e44d689057 100644 --- a/NPCs/Abyss/ColossalSquid.cs +++ b/NPCs/Abyss/ColossalSquid.cs @@ -630,7 +630,7 @@ namespace CalamityMod.NPCs.Abyss public override void ModifyNPCLoot(NPCLoot npcLoot) { npcLoot.Add(ItemID.BlackInk, 1, 3, 5); - npcLoot.Add(ModContent.ItemType(), 5); + npcLoot.Add(ModContent.ItemType(), 3); var postLevi = npcLoot.DefineConditionalDropSet(DropHelper.PostLevi()); postLevi.Add(DropHelper.NormalVsExpertQuantity(ModContent.ItemType(), 2, 26, 38, 31, 45)); diff --git a/NPCs/Abyss/Cuttlefish.cs b/NPCs/Abyss/Cuttlefish.cs index 1770f6b684..fe588479a6 100644 --- a/NPCs/Abyss/Cuttlefish.cs +++ b/NPCs/Abyss/Cuttlefish.cs @@ -379,7 +379,7 @@ namespace CalamityMod.NPCs.Abyss public override void ModifyNPCLoot(NPCLoot npcLoot) { npcLoot.Add(ModContent.ItemType(), 2); - npcLoot.Add(ItemDropRule.NormalvsExpert(ModContent.ItemType(), 20, 10)); + npcLoot.Add(ItemDropRule.NormalvsExpert(ModContent.ItemType(), 10, 5)); } public override void HitEffect(NPC.HitInfo hit) diff --git a/NPCs/Abyss/EidolonWyrmHead.cs b/NPCs/Abyss/EidolonWyrmHead.cs index 8b23bec9cf..b7b311396f 100644 --- a/NPCs/Abyss/EidolonWyrmHead.cs +++ b/NPCs/Abyss/EidolonWyrmHead.cs @@ -118,19 +118,18 @@ namespace CalamityMod.NPCs.Abyss } if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead) - { - NPC.TargetClosest(true); - } + NPC.TargetClosest(); + if (NPC.justHit || detectsPlayer || Main.player[NPC.target].chaosState || adultWyrmAlive || (Main.player[NPC.target].Center - NPC.Center).Length() < Main.player[NPC.target].Calamity().GetAbyssAggro(160f)) { detectsPlayer = true; NPC.damage = Main.expertMode ? 340 : 170; } else - { NPC.damage = 0; - } + NPC.chaseable = detectsPlayer; + if (detectsPlayer) { if (NPC.soundDelay <= 0) @@ -142,14 +141,12 @@ namespace CalamityMod.NPCs.Abyss else { if (Main.rand.NextBool(900)) - { SoundEngine.PlaySound(roar, NPC.Center); - } } + if (NPC.ai[2] > 0f) - { NPC.realLife = (int)NPC.ai[2]; - } + if (Main.netMode != NetmodeID.MultiplayerClient) { if (!TailSpawned && NPC.ai[0] == 0f) @@ -161,18 +158,13 @@ namespace CalamityMod.NPCs.Abyss if (segments >= 0 && segments < minLength) { if (segments % 2 == 0) - { lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType(), NPC.whoAmI); - } else - { lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType(), NPC.whoAmI); - } } else - { lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType(), NPC.whoAmI); - } + Main.npc[lol].realLife = NPC.whoAmI; Main.npc[lol].ai[2] = (float)NPC.whoAmI; Main.npc[lol].ai[1] = (float)Previous; @@ -180,17 +172,16 @@ namespace CalamityMod.NPCs.Abyss NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, lol, 0f, 0f, 0f, 0); Previous = lol; } + TailSpawned = true; } } + if (NPC.velocity.X < 0f) - { NPC.spriteDirection = -1; - } else if (NPC.velocity.X > 0f) - { NPC.spriteDirection = 1; - } + if (Main.player[NPC.target].dead) { NPC.TargetClosest(false); @@ -208,14 +199,16 @@ namespace CalamityMod.NPCs.Abyss } } } + NPC.alpha -= 42; if (NPC.alpha < 0) - { NPC.alpha = 0; - } + if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > 6400f) { - NPC.active = false; + NPC.TargetClosest(false); + if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > 6400f) + NPC.active = false; } float currentSpeed = speed; diff --git a/NPCs/Abyss/GulperEelHead.cs b/NPCs/Abyss/GulperEelHead.cs index 1d09fd334f..395fc3d696 100644 --- a/NPCs/Abyss/GulperEelHead.cs +++ b/NPCs/Abyss/GulperEelHead.cs @@ -115,19 +115,16 @@ namespace CalamityMod.NPCs.Abyss } if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead) - { - NPC.TargetClosest(true); - } - if ((Main.player[NPC.target].Center - NPC.Center).Length() < Main.player[NPC.target].Calamity().GetAbyssAggro(160f) || - NPC.justHit) - { + NPC.TargetClosest(); + + if ((Main.player[NPC.target].Center - NPC.Center).Length() < Main.player[NPC.target].Calamity().GetAbyssAggro(160f) || NPC.justHit) detectsPlayer = true; - } + NPC.chaseable = detectsPlayer; + if (NPC.ai[2] > 0f) - { NPC.realLife = (int)NPC.ai[2]; - } + if (Main.netMode != NetmodeID.MultiplayerClient) { if (!TailSpawned && NPC.ai[0] == 0f) @@ -139,18 +136,13 @@ namespace CalamityMod.NPCs.Abyss if (segments >= 0 && segments < minLength) { if (segments == 0) - { lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType(), NPC.whoAmI); - } else - { lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType(), NPC.whoAmI); - } } else - { lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType(), NPC.whoAmI); - } + Main.npc[lol].realLife = NPC.whoAmI; Main.npc[lol].ai[2] = (float)NPC.whoAmI; Main.npc[lol].ai[1] = (float)Previous; @@ -158,29 +150,28 @@ namespace CalamityMod.NPCs.Abyss NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, lol, 0f, 0f, 0f, 0); Previous = lol; } + TailSpawned = true; } } + if (NPC.velocity.X < 0f) - { NPC.spriteDirection = 1; - } else if (NPC.velocity.X > 0f) - { NPC.spriteDirection = -1; - } + if (Main.player[NPC.target].dead) - { NPC.TargetClosest(false); - } + NPC.alpha -= 42; if (NPC.alpha < 0) - { NPC.alpha = 0; - } + if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > 5600f) { - NPC.active = false; + NPC.TargetClosest(false); + if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > 5600f) + NPC.active = false; } float currentSpeed = speed; diff --git a/NPCs/Abyss/OarfishHead.cs b/NPCs/Abyss/OarfishHead.cs index 5945215fc8..9459276e5a 100644 --- a/NPCs/Abyss/OarfishHead.cs +++ b/NPCs/Abyss/OarfishHead.cs @@ -155,7 +155,11 @@ namespace CalamityMod.NPCs.Abyss NPC.alpha = 0; if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > 5600f) - NPC.active = false; + { + NPC.TargetClosest(false); + if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > 5600f) + NPC.active = false; + } float currentSpeed = speed; float currentTurnSpeed = turnSpeed; diff --git a/NPCs/AstrumDeus/AstrumDeusBody.cs b/NPCs/AstrumDeus/AstrumDeusBody.cs index df1beaab43..dfc682dcb0 100644 --- a/NPCs/AstrumDeus/AstrumDeusBody.cs +++ b/NPCs/AstrumDeus/AstrumDeusBody.cs @@ -82,6 +82,7 @@ namespace CalamityMod.NPCs.AstrumDeus public override void SendExtraAI(BinaryWriter writer) { + writer.Write(NPC.localAI[3]); writer.Write(NPC.dontTakeDamage); for (int i = 0; i < 4; i++) writer.Write(NPC.Calamity().newAI[i]); @@ -89,6 +90,7 @@ namespace CalamityMod.NPCs.AstrumDeus public override void ReceiveExtraAI(BinaryReader reader) { + NPC.localAI[3] = reader.ReadSingle(); NPC.dontTakeDamage = reader.ReadBoolean(); for (int i = 0; i < 4; i++) NPC.Calamity().newAI[i] = reader.ReadSingle(); diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index 67f1b44711..69712bf4e7 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -1462,9 +1462,9 @@ namespace CalamityMod.NPCs else if (npc.type == NPCID.SkeletronHand) { if (CalamityWorld.death) - npc.lifeMax = (int)Math.Round(npc.lifeMax * 0.65); + npc.lifeMax = (int)Math.Round(npc.lifeMax * 0.5); else - npc.lifeMax = (int)Math.Round(npc.lifeMax * 0.9); + npc.lifeMax = (int)Math.Round(npc.lifeMax * 0.75); } else if (npc.type == NPCID.QueenBee) { @@ -3311,6 +3311,7 @@ namespace CalamityMod.NPCs // Apply flat reductions first. All vanilla debuffs check their internal booleans. FlatEditDR(ref calcDR, npc.poisoned, BuffID.Poisoned); FlatEditDR(ref calcDR, npc.onFire, BuffID.OnFire); + FlatEditDR(ref calcDR, npc.onFire3, BuffID.OnFire3); FlatEditDR(ref calcDR, npc.venom, BuffID.Venom); FlatEditDR(ref calcDR, npc.onFrostBurn, BuffID.Frostburn); FlatEditDR(ref calcDR, npc.shadowFlame, BuffID.ShadowFlame); @@ -3329,6 +3330,7 @@ namespace CalamityMod.NPCs // Apply multiplicative reductions second. All vanilla debuffs check their internal booleans. MultEditDR(ref calcDR, npc.poisoned, BuffID.Poisoned); MultEditDR(ref calcDR, npc.onFire, BuffID.OnFire); + MultEditDR(ref calcDR, npc.onFire3, BuffID.OnFire3); MultEditDR(ref calcDR, npc.venom, BuffID.Venom); MultEditDR(ref calcDR, npc.onFrostBurn, BuffID.Frostburn); MultEditDR(ref calcDR, npc.shadowFlame, BuffID.ShadowFlame); @@ -3355,7 +3357,9 @@ namespace CalamityMod.NPCs { if (npc.type == NPCID.DukeFishron && (CalamityWorld.death || BossRushEvent.BossRushActive)) { - if (npc.life / (float)npc.lifeMax < 0.4f) + float lifeRatio = npc.life / (float)npc.lifeMax; + float mapIconVanishValue = Main.masterMode ? 0.3f : 0.4f; + if (lifeRatio < mapIconVanishValue || (lifeRatio > 0.9f && Main.masterMode)) index = -1; } } @@ -5257,7 +5261,7 @@ namespace CalamityMod.NPCs return; if (target.Calamity().sulphurSet) - npc.AddBuff(BuffID.Poisoned, 120); + npc.AddBuff(BuffID.Poisoned, 60); if (target.Calamity().snowman) { @@ -5820,24 +5824,37 @@ namespace CalamityMod.NPCs } } + // Plague debuff on kill effect if (pFlames > 0 && npc.life <= 0) { - Rectangle hitbox = npc.Hitbox; - for (int i = 0; i < 20; i++) - { - int idx = Dust.NewDust(hitbox.TopLeft(), npc.width, npc.height, DustID.GemEmerald, 0f, -2.5f); - Dust dust = Main.dust[idx]; - dust.alpha = 200; - dust.velocity *= 1.4f; - dust.scale += Main.rand.NextFloat(); - } - if (Main.netMode != NetmodeID.MultiplayerClient) { - foreach (NPC nPC in Main.ActiveNPCs) + for (int i = 0; i < 10; i++) { - if (!nPC.buffImmune[BuffType()] && npc.Distance(nPC.Center) < 100f && !nPC.dontTakeDamage && nPC.lifeMax > 5 && !nPC.friendly && !nPC.townNPC) - nPC.AddBuff(BuffType(), 300); + int DustID = 220; + Dust dust2 = Dust.NewDustDirect(npc.Center, npc.width, npc.height, DustID); + dust2.scale = Main.rand.NextFloat(0.6f, 0.75f); + dust2.velocity = new Vector2(12, 12).RotatedByRandom(100) * Main.rand.NextFloat(0.5f, 0.8f); + dust2.noGravity = true; + } + + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC target = Main.npc[i]; + + if (target != null && target.IsAnEnemy(true, true) && !target.buffImmune[BuffType()] && Vector2.Distance(target.Center, npc.Center) < 400) + { + if (target.HasBuff() || target.life <= 0) + { + target.AddBuff(BuffType(), 300); + } + else + { + target.AddBuff(BuffType(), 300); + DirectionalPulseRing pulse = new DirectionalPulseRing(target.Center, Vector2.Zero, Main.rand.NextBool(3) ? Color.LimeGreen : Color.Green, new Vector2(1, 1), 0, Main.rand.NextFloat(0.07f, 0.18f) * 3, 0f, 15); + GeneralParticleHandler.SpawnParticle(pulse); + } + } } } } @@ -6451,7 +6468,10 @@ namespace CalamityMod.NPCs drawColor = Color.Cyan; else if (electrified > 0) - drawColor = Main.rand.NextBool(5) ? Color.White : Color.SlateGray; + { + int scaleFactor = (int)(Utils.Remap(npc.width, 30, 400, 5, 15, true)); + drawColor = Main.rand.NextBool(scaleFactor) ? Color.Lerp(Color.SlateGray, Color.White, Utils.Remap(npc.width, 30, 400, 0, 0.7f, true)) : Color.White; + } else if (absorberAffliction > 0) drawColor = Color.DarkSeaGreen; @@ -6476,7 +6496,7 @@ namespace CalamityMod.NPCs return new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, Main.DiscoR); if (npc.type == NPCID.KingSlime && Main.masterMode && CalamityWorld.revenge) - return NPC.AnyNPCs(ModContent.NPCType()) ? Color.Lerp(new Color(0, 0, 150, npc.alpha), new Color(125, 125, 255, npc.alpha), (float)Math.Sin(Main.GlobalTimeWrappedHourly) / 2f + 0.5f) : null; + return NPC.AnyNPCs(ModContent.NPCType()) ? Color.Lerp(new Color(0, 0, 150, npc.alpha), new Color(125, 125, 255, npc.alpha), (float)Math.Sin(Main.GlobalTimeWrappedHourly) / 2f + 0.5f) : null; if (npc.type == NPCID.QueenBee && Main.zenithWorld) { @@ -6816,7 +6836,9 @@ namespace CalamityMod.NPCs Vector2 halfSize = npc.frame.Size() / 2; - spriteBatch.Draw(TextureAssets.Npc[npc.type].Value, new Vector2(position.X - screenPos.X + (float)(npc.width / 2) - (float)TextureAssets.Npc[npc.type].Width() * npc.scale / 2f + halfSize.X * npc.scale, position.Y - screenPos.Y + (float)npc.height - (float)TextureAssets.Npc[npc.type].Height() * npc.scale / (float)Main.npcFrameCount[npc.type] + 4f + halfSize.Y * npc.scale + npc.gfxOffY), npc.frame, alphaColor, npc.rotation, halfSize, npc.scale, spriteEffects, 0f); + int width = TextureAssets.Npc[npc.type] is null ? 0 : TextureAssets.Npc[npc.type].Width(); + int height = TextureAssets.Npc[npc.type] is null ? 0 : TextureAssets.Npc[npc.type].Height(); + spriteBatch.Draw(TextureAssets.Npc[npc.type].Value, new Vector2(position.X - screenPos.X + (float)(npc.width / 2) - (float)width * npc.scale / 2f + halfSize.X * npc.scale, position.Y - screenPos.Y + (float)npc.height - (float)height * npc.scale / (float)Main.npcFrameCount[npc.type] + 4f + halfSize.Y * npc.scale + npc.gfxOffY), npc.frame, alphaColor, npc.rotation, halfSize, npc.scale, spriteEffects, 0f); } } else @@ -6958,14 +6980,6 @@ namespace CalamityMod.NPCs if (npc.spriteDirection == 1) spriteEffects = SpriteEffects.FlipHorizontally; - if (npc.type == NPCID.TheDestroyerBody) - { - if (npc.ai[2] == 0f) - npc.frame.Y = 0; - else - npc.frame.Y = frameHeight; - } - Color segmentDrawColor = npc.GetAlpha(drawColor); // Check if Destroyer is behind tiles and, if so, how much of the segment is behind tiles and adjust color accordingly @@ -7191,7 +7205,9 @@ namespace CalamityMod.NPCs if (npc.spriteDirection == 1) spriteEffects = SpriteEffects.FlipHorizontally; - spriteBatch.Draw(TextureAssets.Npc[npc.type].Value, new Vector2(position.X - screenPos.X + (float)(npc.width / 2) - (float)TextureAssets.Npc[npc.type].Width() * npc.scale / 2f + halfSize.X * npc.scale, position.Y - screenPos.Y + (float)npc.height - (float)TextureAssets.Npc[npc.type].Height() * npc.scale / (float)Main.npcFrameCount[npc.type] + 4f + halfSize.Y * npc.scale + npc.gfxOffY), npc.frame, currentColor, npc.rotation, halfSize, npc.scale, spriteEffects, 0f); + int width = TextureAssets.Npc[npc.type] is null ? 0 : TextureAssets.Npc[npc.type].Width(); + int height = TextureAssets.Npc[npc.type] is null ? 0 : TextureAssets.Npc[npc.type].Height(); + spriteBatch.Draw(TextureAssets.Npc[npc.type].Value, new Vector2(position.X - screenPos.X + (float)(npc.width / 2) - (float)width * npc.scale / 2f + halfSize.X * npc.scale, position.Y - screenPos.Y + (float)npc.height - (float)height * npc.scale / (float)Main.npcFrameCount[npc.type] + 4f + halfSize.Y * npc.scale + npc.gfxOffY), npc.frame, currentColor, npc.rotation, halfSize, npc.scale, spriteEffects, 0f); } } } @@ -7241,7 +7257,9 @@ namespace CalamityMod.NPCs position.Y -= npc.height / 2; - spriteBatch.Draw(TextureAssets.Npc[npc.type].Value, new Vector2(position.X - screenPos.X + (float)(npc.width / 2) - (float)TextureAssets.Npc[npc.type].Width() * npc.scale / 2f + halfSize.X * npc.scale, position.Y - screenPos.Y + (float)npc.height - (float)TextureAssets.Npc[npc.type].Height() * npc.scale / (float)Main.npcFrameCount[npc.type] + 4f + halfSize.Y * npc.scale + npc.gfxOffY), npc.frame, currentColor, npc.rotation, halfSize, npc.scale, spriteEffects, 0f); + int width = TextureAssets.Npc[npc.type] is null ? 0 : TextureAssets.Npc[npc.type].Width(); + int height = TextureAssets.Npc[npc.type] is null ? 0 : TextureAssets.Npc[npc.type].Height(); + spriteBatch.Draw(TextureAssets.Npc[npc.type].Value, new Vector2(position.X - screenPos.X + (float)(npc.width / 2) - (float)width * npc.scale / 2f + halfSize.X * npc.scale, position.Y - screenPos.Y + (float)npc.height - (float)height * npc.scale / (float)Main.npcFrameCount[npc.type] + 4f + halfSize.Y * npc.scale + npc.gfxOffY), npc.frame, currentColor, npc.rotation, halfSize, npc.scale, spriteEffects, 0f); } float secondAfterimageSetHealthValue = (int)(Main.npc[NPC.crimsonBoss].lifeMax * 0.8f); @@ -7322,7 +7340,9 @@ namespace CalamityMod.NPCs position.X -= npc.width / 2; position.Y -= npc.height / 2; - spriteBatch.Draw(TextureAssets.Npc[npc.type].Value, new Vector2(position.X - screenPos.X + (float)(npc.width / 2) - (float)TextureAssets.Npc[npc.type].Width() * npc.scale / 2f + halfSize.X * npc.scale, position.Y - screenPos.Y + (float)npc.height - (float)TextureAssets.Npc[npc.type].Height() * npc.scale / (float)Main.npcFrameCount[npc.type] + 4f + halfSize.Y * npc.scale + npc.gfxOffY), npc.frame, currentColor, npc.rotation, halfSize, npc.scale, spriteEffects, 0f); + int width = TextureAssets.Npc[npc.type] is null ? 0 : TextureAssets.Npc[npc.type].Width(); + int height = TextureAssets.Npc[npc.type] is null ? 0 : TextureAssets.Npc[npc.type].Height(); + spriteBatch.Draw(TextureAssets.Npc[npc.type].Value, new Vector2(position.X - screenPos.X + (float)(npc.width / 2) - (float)width * npc.scale / 2f + halfSize.X * npc.scale, position.Y - screenPos.Y + (float)npc.height - (float)height * npc.scale / (float)Main.npcFrameCount[npc.type] + 4f + halfSize.Y * npc.scale + npc.gfxOffY), npc.frame, currentColor, npc.rotation, halfSize, npc.scale, spriteEffects, 0f); } } } diff --git a/NPCs/DesertScourge/DesertNuisanceBody.cs b/NPCs/DesertScourge/DesertNuisanceBody.cs index e666fc7b04..3498f8fe14 100644 --- a/NPCs/DesertScourge/DesertNuisanceBody.cs +++ b/NPCs/DesertScourge/DesertNuisanceBody.cs @@ -33,6 +33,7 @@ namespace CalamityMod.NPCs.DesertScourge BodyTexture3 = ModContent.Request(Texture + "3", AssetRequestMode.AsyncLoad); BodyTexture4 = ModContent.Request(Texture + "4", AssetRequestMode.AsyncLoad); } + NPCID.Sets.CantTakeLunchMoney[Type] = true; } public override void SetDefaults() @@ -69,23 +70,6 @@ namespace CalamityMod.NPCs.DesertScourge public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) => false; - public override void SendExtraAI(BinaryWriter writer) - { - // Frame syncs - writer.Write(NPC.frame.X); - writer.Write(NPC.frame.Y); - writer.Write(NPC.frame.Width); - writer.Write(NPC.frame.Height); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - // Frame syncs - Rectangle frame = new Rectangle(reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32()); - if (frame.Width > 0 && frame.Height > 0) - NPC.frame = frame; - } - public override void AI() { bool bossRush = BossRushEvent.BossRushActive; @@ -104,10 +88,8 @@ namespace CalamityMod.NPCs.DesertScourge NPC.ai[3] = 1f; NPC.position = NPC.Center; - //NPC.width = (int)(BodyTexture2.Width() * NPC.scale); - //NPC.height = (int)(BodyTexture2.Height() * NPC.scale); NPC.position -= NPC.Size * 0.5f; - NPC.frame = new Rectangle(0, 0, BodyTexture2.Width(), BodyTexture2.Height()); + NPC.frame = new Rectangle(0, 0, BodyTexture2 is null ? 0 : BodyTexture2.Width(), BodyTexture2 is null ? 0 : BodyTexture2.Height()); NPC.netUpdate = true; @@ -121,10 +103,8 @@ namespace CalamityMod.NPCs.DesertScourge NPC.ai[3] = 2f; NPC.position = NPC.Center; - //NPC.width = (int)(BodyTexture3.Width() * NPC.scale); - //NPC.height = (int)(BodyTexture3.Height() * NPC.scale); NPC.position -= NPC.Size * 0.5f; - NPC.frame = new Rectangle(0, 0, BodyTexture3.Width(), BodyTexture3.Height()); + NPC.frame = new Rectangle(0, 0, BodyTexture3 is null ? 0 : BodyTexture3.Width(), BodyTexture3 is null ? 0 : BodyTexture3.Height()); NPC.netUpdate = true; @@ -138,10 +118,8 @@ namespace CalamityMod.NPCs.DesertScourge NPC.ai[3] = 3f; NPC.position = NPC.Center; - //NPC.width = (int)(BodyTexture4.Width() * NPC.scale); - //NPC.height = (int)(BodyTexture4.Height() * NPC.scale); NPC.position -= NPC.Size * 0.5f; - NPC.frame = new Rectangle(0, 0, BodyTexture4.Width(), BodyTexture4.Height()); + NPC.frame = new Rectangle(0, 0, BodyTexture4 is null ? 0 : BodyTexture4.Width(), BodyTexture4 is null ? 0 : BodyTexture4.Height()); NPC.netUpdate = true; diff --git a/NPCs/DesertScourge/DesertNuisanceBodyYoung.cs b/NPCs/DesertScourge/DesertNuisanceBodyYoung.cs index 86b3514232..5e9f85ba16 100644 --- a/NPCs/DesertScourge/DesertNuisanceBodyYoung.cs +++ b/NPCs/DesertScourge/DesertNuisanceBodyYoung.cs @@ -33,6 +33,7 @@ namespace CalamityMod.NPCs.DesertScourge BodyTexture3 = ModContent.Request(Texture + "3", AssetRequestMode.AsyncLoad); BodyTexture4 = ModContent.Request(Texture + "4", AssetRequestMode.AsyncLoad); } + NPCID.Sets.CantTakeLunchMoney[Type] = true; } public override void SetDefaults() @@ -69,23 +70,6 @@ namespace CalamityMod.NPCs.DesertScourge public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) => false; - public override void SendExtraAI(BinaryWriter writer) - { - // Frame syncs - writer.Write(NPC.frame.X); - writer.Write(NPC.frame.Y); - writer.Write(NPC.frame.Width); - writer.Write(NPC.frame.Height); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - // Frame syncs - Rectangle frame = new Rectangle(reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32()); - if (frame.Width > 0 && frame.Height > 0) - NPC.frame = frame; - } - public override void AI() { bool bossRush = BossRushEvent.BossRushActive; @@ -104,10 +88,8 @@ namespace CalamityMod.NPCs.DesertScourge NPC.ai[3] = 1f; NPC.position = NPC.Center; - //NPC.width = (int)(BodyTexture2.Width() * NPC.scale); - //NPC.height = (int)(BodyTexture2.Height() * NPC.scale); NPC.position -= NPC.Size * 0.5f; - NPC.frame = new Rectangle(0, 0, BodyTexture2.Width(), BodyTexture2.Height()); + NPC.frame = new Rectangle(0, 0, BodyTexture2 is null ? 0 : BodyTexture2.Width(), BodyTexture2 is null ? 0 : BodyTexture2.Height()); NPC.netUpdate = true; @@ -121,10 +103,8 @@ namespace CalamityMod.NPCs.DesertScourge NPC.ai[3] = 2f; NPC.position = NPC.Center; - //NPC.width = (int)(BodyTexture3.Width() * NPC.scale); - //NPC.height = (int)(BodyTexture3.Height() * NPC.scale); NPC.position -= NPC.Size * 0.5f; - NPC.frame = new Rectangle(0, 0, BodyTexture3.Width(), BodyTexture3.Height()); + NPC.frame = new Rectangle(0, 0, BodyTexture3 is null ? 0 : BodyTexture3.Width(), BodyTexture3 is null ? 0 : BodyTexture3.Height()); NPC.netUpdate = true; @@ -138,10 +118,8 @@ namespace CalamityMod.NPCs.DesertScourge NPC.ai[3] = 3f; NPC.position = NPC.Center; - //NPC.width = (int)(BodyTexture4.Width() * NPC.scale); - //NPC.height = (int)(BodyTexture4.Height() * NPC.scale); NPC.position -= NPC.Size * 0.5f; - NPC.frame = new Rectangle(0, 0, BodyTexture4.Width(), BodyTexture4.Height()); + NPC.frame = new Rectangle(0, 0, BodyTexture4 is null ? 0 : BodyTexture4.Width(), BodyTexture4 is null ? 0 : BodyTexture4.Height()); NPC.netUpdate = true; diff --git a/NPCs/DesertScourge/DesertNuisanceHead.cs b/NPCs/DesertScourge/DesertNuisanceHead.cs index 564cf646cc..71e547d8f9 100644 --- a/NPCs/DesertScourge/DesertNuisanceHead.cs +++ b/NPCs/DesertScourge/DesertNuisanceHead.cs @@ -45,6 +45,7 @@ namespace CalamityMod.NPCs.DesertScourge value.Position.Y += 30; NPCID.Sets.NPCBestiaryDrawOffset[Type] = value; NPCID.Sets.MPAllowedEnemies[Type] = true; + NPCID.Sets.CantTakeLunchMoney[Type] = true; } public override void SetDefaults() @@ -138,12 +139,12 @@ namespace CalamityMod.NPCs.DesertScourge // Percent life remaining. float lifeRatio = NPC.life / (float)NPC.lifeMax; - float speed = death ? 0.2f : 0.17f; - float turnSpeed = death ? 0.3f : 0.25f; + float speed = death ? 0.18f : 0.16f; + float turnSpeed = death ? 0.26f : 0.22f; speed += speed * 0.4f * (1f - lifeRatio); turnSpeed += turnSpeed * 0.4f * (1f - lifeRatio); - speed += 0.17f * enrageScale; - turnSpeed += 0.25f * enrageScale; + speed += 0.16f * enrageScale; + turnSpeed += 0.22f * enrageScale; if (Main.getGoodWorld) { @@ -317,8 +318,10 @@ namespace CalamityMod.NPCs.DesertScourge if (!shouldFly) { - NPC.TargetClosest(); NPC.velocity.Y += 0.15f; + if (NPC.velocity.Y > 0f && Math.Abs(NPC.Center.Y - Main.player[NPC.target].Center.Y) > 180f) + NPC.velocity.Y += 0.05f; + if (NPC.velocity.Y > maxChaseSpeed) NPC.velocity.Y = maxChaseSpeed; diff --git a/NPCs/DesertScourge/DesertNuisanceHeadYoung.cs b/NPCs/DesertScourge/DesertNuisanceHeadYoung.cs index 9a3e19a915..e984be408c 100644 --- a/NPCs/DesertScourge/DesertNuisanceHeadYoung.cs +++ b/NPCs/DesertScourge/DesertNuisanceHeadYoung.cs @@ -37,6 +37,7 @@ namespace CalamityMod.NPCs.DesertScourge Main.npcFrameCount[NPC.type] = 7; this.HideFromBestiary(); NPCID.Sets.MPAllowedEnemies[Type] = true; + NPCID.Sets.CantTakeLunchMoney[Type] = true; } public override void SetDefaults() @@ -134,12 +135,12 @@ namespace CalamityMod.NPCs.DesertScourge // Percent life remaining. float lifeRatio = NPC.life / (float)NPC.lifeMax; - float speed = death ? 0.22f : 0.19f; - float turnSpeed = death ? 0.32f : 0.27f; + float speed = death ? 0.16f : 0.14f; + float turnSpeed = death ? 0.24f : 0.2f; speed += speed * 0.4f * (1f - lifeRatio); turnSpeed += turnSpeed * 0.4f * (1f - lifeRatio); - speed += 0.19f * enrageScale; - turnSpeed += 0.27f * enrageScale; + speed += 0.14f * enrageScale; + turnSpeed += 0.2f * enrageScale; if (Main.getGoodWorld) { @@ -361,7 +362,6 @@ namespace CalamityMod.NPCs.DesertScourge if (!shouldFly) { - NPC.TargetClosest(); NPC.velocity.Y += 0.15f; if (NPC.velocity.Y > maxChaseSpeed) NPC.velocity.Y = maxChaseSpeed; diff --git a/NPCs/DesertScourge/DesertNuisanceTail.cs b/NPCs/DesertScourge/DesertNuisanceTail.cs index 860e56f7b0..709710af2f 100644 --- a/NPCs/DesertScourge/DesertNuisanceTail.cs +++ b/NPCs/DesertScourge/DesertNuisanceTail.cs @@ -15,6 +15,7 @@ namespace CalamityMod.NPCs.DesertScourge public override void SetStaticDefaults() { this.HideFromBestiary(); + NPCID.Sets.CantTakeLunchMoney[Type] = true; } public override void SetDefaults() diff --git a/NPCs/DesertScourge/DesertNuisanceTailYoung.cs b/NPCs/DesertScourge/DesertNuisanceTailYoung.cs index df82733592..c2b49d23c3 100644 --- a/NPCs/DesertScourge/DesertNuisanceTailYoung.cs +++ b/NPCs/DesertScourge/DesertNuisanceTailYoung.cs @@ -15,6 +15,7 @@ namespace CalamityMod.NPCs.DesertScourge public override void SetStaticDefaults() { this.HideFromBestiary(); + NPCID.Sets.CantTakeLunchMoney[Type] = true; } public override void SetDefaults() diff --git a/NPCs/DesertScourge/DesertScourgeBody.cs b/NPCs/DesertScourge/DesertScourgeBody.cs index daa0b54eae..1d30f4e6ce 100644 --- a/NPCs/DesertScourge/DesertScourgeBody.cs +++ b/NPCs/DesertScourge/DesertScourgeBody.cs @@ -80,23 +80,12 @@ namespace CalamityMod.NPCs.DesertScourge { writer.Write(NPC.alpha); writer.Write(NPC.dontTakeDamage); - - // Frame syncs - writer.Write(NPC.frame.X); - writer.Write(NPC.frame.Y); - writer.Write(NPC.frame.Width); - writer.Write(NPC.frame.Height); } public override void ReceiveExtraAI(BinaryReader reader) { NPC.alpha = reader.ReadInt32(); NPC.dontTakeDamage = reader.ReadBoolean(); - - // Frame syncs - Rectangle frame = new Rectangle(reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32()); - if (frame.Width > 0 && frame.Height > 0) - NPC.frame = frame; } public override void AI() @@ -117,10 +106,8 @@ namespace CalamityMod.NPCs.DesertScourge NPC.ai[3] = 1f; NPC.position = NPC.Center; - //NPC.width = (int)(BodyTexture2.Width() * NPC.scale); - //NPC.height = (int)(BodyTexture2.Height() * NPC.scale); NPC.position -= NPC.Size * 0.5f; - NPC.frame = new Rectangle(0, 0, BodyTexture2.Width(), BodyTexture2.Height()); + NPC.frame = new Rectangle(0, 0, BodyTexture2 is null ? 0 : BodyTexture2.Width(), BodyTexture2 is null ? 0 : BodyTexture2.Height()); NPC.netUpdate = true; @@ -134,10 +121,8 @@ namespace CalamityMod.NPCs.DesertScourge NPC.ai[3] = 2f; NPC.position = NPC.Center; - //NPC.width = (int)(BodyTexture3.Width() * NPC.scale); - //NPC.height = (int)(BodyTexture3.Height() * NPC.scale); NPC.position -= NPC.Size * 0.5f; - NPC.frame = new Rectangle(0, 0, BodyTexture3.Width(), BodyTexture3.Height()); + NPC.frame = new Rectangle(0, 0, BodyTexture3 is null ? 0 : BodyTexture3.Width(), BodyTexture3 is null ? 0 : BodyTexture3.Height()); NPC.netUpdate = true; @@ -151,10 +136,8 @@ namespace CalamityMod.NPCs.DesertScourge NPC.ai[3] = 3f; NPC.position = NPC.Center; - //NPC.width = (int)(BodyTexture4.Width() * NPC.scale); - //NPC.height = (int)(BodyTexture4.Height() * NPC.scale); NPC.position -= NPC.Size * 0.5f; - NPC.frame = new Rectangle(0, 0, BodyTexture4.Width(), BodyTexture4.Height()); + NPC.frame = new Rectangle(0, 0, BodyTexture4 is null ? 0 : BodyTexture4.Width(), BodyTexture4 is null ? 0 : BodyTexture4.Height()); NPC.netUpdate = true; diff --git a/NPCs/DesertScourge/DesertScourgeHead.cs b/NPCs/DesertScourge/DesertScourgeHead.cs index 803655aa4d..4cd787ab44 100644 --- a/NPCs/DesertScourge/DesertScourgeHead.cs +++ b/NPCs/DesertScourge/DesertScourgeHead.cs @@ -183,10 +183,6 @@ namespace CalamityMod.NPCs.DesertScourge if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) NPC.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - NPC.TargetClosest(); - Player player = Main.player[NPC.target]; // Enrage @@ -238,8 +234,8 @@ namespace CalamityMod.NPCs.DesertScourge float burrowDistance = hide ? BurrowDistance_Hide : bossRush ? BurrowDistance_BossRush : BurrowDistance; - float speed = death ? 0.18f : 0.15f; - float turnSpeed = death ? 0.36f : 0.3f; + float speed = death ? 0.15f : 0.12f; + float turnSpeed = death ? 0.3f : 0.24f; if (expertMode) { @@ -249,12 +245,12 @@ namespace CalamityMod.NPCs.DesertScourge if (revenge) { - speed += (death ? 0.06f : 0.05f) * (1f - lifeRatio); - turnSpeed += (death ? 0.12f : 0.1f) * (1f - lifeRatio); + speed += (death ? 0.05f : 0.04f) * (1f - lifeRatio); + turnSpeed += (death ? 0.1f : 0.08f) * (1f - lifeRatio); } - speed += 0.15f * enrageScale; - turnSpeed += 0.3f * enrageScale; + speed += 0.12f * enrageScale; + turnSpeed += 0.24f * enrageScale; if (Main.getGoodWorld) { @@ -262,47 +258,6 @@ namespace CalamityMod.NPCs.DesertScourge turnSpeed *= 1.2f; } - // Projectile spit (unused, for now) - /*if ((phase2 || death) && revenge && NPC.Distance(Main.player[NPC.target].Center) > 400f && (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY).ToRotation().AngleTowards(NPC.velocity.ToRotation(), MathHelper.PiOver4) == NPC.velocity.ToRotation()) - { - if (NPC.Calamity().newAI[0] % (death ? SpitGateValue_Death : SpitGateValue) == 0f) - { - SoundEngine.PlaySound(SoundID.NPCDeath11, NPC.Center); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Vector2 projectileVelocity = (Main.player[NPC.target].Center - NPC.Center).SafeNormalize(Vector2.UnitY) * (masterMode ? 10f : 8f); - int numProj = death ? 9 : 6; - int spread = masterMode ? 49 : 35; - if (masterMode) - { - numProj += 3; - spread += 14; - } - - float rotation = MathHelper.ToRadians(spread); - int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - for (int i = 0; i < numProj; i++) - { - Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); - - for (int k = 0; k < 10; k++) - { - int dust = Dust.NewDust(NPC.Center + Vector2.Normalize(perturbedSpeed) * 5f, 10, 10, (int)CalamityDusts.SulphurousSeaAcid); - Main.dust[dust].velocity = perturbedSpeed; - } - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * 5f, perturbedSpeed, type, damage, 0f, Main.myPlayer); - Main.projectile[proj].aiStyle = -1; - Main.projectile[proj].netUpdate = true; - } - } - } - } - }*/ - // Sand splash if (!quickFall) { @@ -595,7 +550,7 @@ namespace CalamityMod.NPCs.DesertScourge float targetDistance = (float)Math.Sqrt((double)(playerX * playerX + targettingPosition * targettingPosition)); // Lunge up towards target - if (burrow && NPC.Center.Y >= burrowTarget - 16f) + if (burrow && NPC.Center.Y >= burrowTarget - 16f && !lungeUpward && !quickFall) { NPC.Calamity().newAI[1] = 1f; NPC.localAI[3] = 0f; @@ -607,7 +562,7 @@ namespace CalamityMod.NPCs.DesertScourge } // Quickly fall back down once above target - if (lungeUpward && NPC.Center.Y <= NPC.Calamity().newAI[3] + LungeUpwardDistanceOffset - LungeUpwardCutoffDistance && Math.Abs(NPC.Center.X - player.Center.X) < 480f) + if (lungeUpward && NPC.Center.Y <= NPC.Calamity().newAI[3] + LungeUpwardDistanceOffset - LungeUpwardCutoffDistance && Math.Abs(NPC.Center.X - player.Center.X) < 480f && !quickFall) { // Spit a huge spread of sand upwards that falls down SoundEngine.PlaySound(SoundID.NPCDeath13, NPC.Center); @@ -660,7 +615,9 @@ namespace CalamityMod.NPCs.DesertScourge { NPC.Calamity().newAI[0] = 0f; NPC.Calamity().newAI[1] = 0f; + NPC.Calamity().newAI[3] = 0f; NPC.localAI[3] = 0f; + playRoarSound = false; } if (hide && !player.dead) @@ -669,8 +626,14 @@ namespace CalamityMod.NPCs.DesertScourge } else if (!shouldFly) { - NPC.TargetClosest(); NPC.velocity.Y += 0.15f; + if (NPC.Center.Y - player.Center.Y < -180f) + { + NPC.velocity.Y += 0.05f; + if (NPC.velocity.Y > 0f) + NPC.velocity.Y += 0.05f; + } + if (NPC.velocity.Y > maxChaseSpeed) NPC.velocity.Y = maxChaseSpeed; diff --git a/NPCs/DevourerofGods/DevourerofGodsHead.cs b/NPCs/DevourerofGods/DevourerofGodsHead.cs index 705f248c4c..9d5119195f 100644 --- a/NPCs/DevourerofGods/DevourerofGodsHead.cs +++ b/NPCs/DevourerofGods/DevourerofGodsHead.cs @@ -355,12 +355,10 @@ namespace CalamityMod.NPCs.DevourerofGods if (CalamityConfig.Instance.BossesStopWeather) CalamityMod.StopRain(); - // Get a target + // Get a target (time is checked in the second check to ensure a new target isn't being set constantly) if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) NPC.TargetClosest(); - - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) + else if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles && Main.time % 60D == 0D) NPC.TargetClosest(); Player player = Main.player[NPC.target]; @@ -2354,6 +2352,10 @@ namespace CalamityMod.NPCs.DevourerofGods } } + // There is no escape... + if (NPC.Distance(player.Center) > 2400f) + NPC.velocity += (player.Center - NPC.Center).SafeNormalize(Vector2.UnitY) * turnSpeed; + // Calculate contact damage based on velocity float minimalContactDamageVelocity = segmentVelocity * 0.25f; float minimalDamageVelocity = segmentVelocity * 0.5f; diff --git a/NPCs/HiveMind/HiveMind.cs b/NPCs/HiveMind/HiveMind.cs index 6337421d61..fee10f41f3 100644 --- a/NPCs/HiveMind/HiveMind.cs +++ b/NPCs/HiveMind/HiveMind.cs @@ -216,11 +216,6 @@ namespace CalamityMod.NPCs.HiveMind writer.Write(reelCount); writer.Write(frameX); writer.Write(frameY); - - writer.Write(NPC.frame.X); - writer.Write(NPC.frame.Y); - writer.Write(NPC.frame.Width); - writer.Write(NPC.frame.Height); } public override void ReceiveExtraAI(BinaryReader reader) @@ -243,10 +238,6 @@ namespace CalamityMod.NPCs.HiveMind reelCount = reader.ReadInt32(); frameX = reader.ReadInt32(); frameY = reader.ReadInt32(); - - Rectangle frame = new Rectangle(reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32()); - if (frame.Width > 0 && frame.Height > 0) - NPC.frame = frame; } public override void FindFrame(int frameHeight) @@ -279,8 +270,6 @@ namespace CalamityMod.NPCs.HiveMind if ((frameX * maxFramesY_Phase2) + frameY > 15) frameX = frameY = 0; } - - NPC.frame = new Rectangle(NPC.width * frameX, NPC.height * frameY, NPC.width, NPC.height); } else { @@ -300,7 +289,7 @@ namespace CalamityMod.NPCs.HiveMind { SpriteEffects spriteEffects = NPC.direction == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; Texture2D texture = Phase2Texture.Value; - Vector2 vector = new Vector2(NPC.width / 2, NPC.height / 2); + Vector2 vector = new Vector2(NPC.width / 2, height_Phase2 / 2); Color afterimageBaseColor = Color.White; int numAfterimages = 5; @@ -312,15 +301,15 @@ namespace CalamityMod.NPCs.HiveMind afterimageColor = Color.Lerp(afterimageColor, afterimageBaseColor, 0.5f); afterimageColor = NPC.GetAlpha(afterimageColor); afterimageColor *= (numAfterimages - i) / 15f; - Vector2 afterimageCenter = NPC.oldPos[i] + new Vector2(NPC.width, NPC.height) / 2f - screenPos; + Vector2 afterimageCenter = NPC.oldPos[i] + new Vector2(NPC.width, height_Phase2) / 2f - screenPos; afterimageCenter -= new Vector2(texture.Width, texture.Height) / new Vector2(maxFramesX_Phase2, maxFramesY_Phase2) * NPC.scale / 2f; afterimageCenter += vector * NPC.scale + new Vector2(0f, NPC.gfxOffY); - spriteBatch.Draw(texture, afterimageCenter, NPC.frame, afterimageColor, NPC.oldRot[i], vector, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture, afterimageCenter, new Rectangle(NPC.width * frameX, height_Phase2 * frameY, NPC.width, height_Phase2), afterimageColor, NPC.oldRot[i], vector, NPC.scale, spriteEffects, 0f); } } Vector2 center = NPC.Center - screenPos; - spriteBatch.Draw(texture, center, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, vector, NPC.scale, spriteEffects, 0f); + spriteBatch.Draw(texture, center, new Rectangle(NPC.width * frameX, height_Phase2 * frameY, NPC.width, height_Phase2), NPC.GetAlpha(drawColor), NPC.rotation, vector, NPC.scale, spriteEffects, 0f); return false; } @@ -358,12 +347,12 @@ namespace CalamityMod.NPCs.HiveMind while (NPC.AnyNPCs(type) && choice < 5); if (choice < 5) - NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + Main.rand.Next(NPC.width), (int)NPC.position.Y + Main.rand.Next(NPC.height), type); + NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + Main.rand.Next(NPC.width), (int)NPC.position.Y + Main.rand.Next(height_Phase2), type); } // Spawn a Hive Cyst if (Main.zenithWorld && NPC.CountNPCS(ModContent.NPCType()) < 3) - NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + Main.rand.Next(NPC.width), (int)NPC.position.Y + Main.rand.Next(NPC.height), ModContent.NPCType()); + NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + Main.rand.Next(NPC.width), (int)NPC.position.Y + Main.rand.Next(height_Phase2), ModContent.NPCType()); } private void ReelBack() @@ -787,7 +776,7 @@ namespace CalamityMod.NPCs.HiveMind if (Main.netMode != NetmodeID.MultiplayerClient && NPC.ai[1] != 0f && NPC.ai[2] != 0f) { NPC.position.X = NPC.ai[1] * 16 - NPC.width / 2; - NPC.position.Y = NPC.ai[2] * 16 - NPC.height / 2; + NPC.position.Y = NPC.ai[2] * 16 - height_Phase2 / 2; } phase2timer = minimumDriftTime + Main.rand.Next(121); @@ -1019,7 +1008,7 @@ namespace CalamityMod.NPCs.HiveMind { int type = ModContent.ProjectileType(); int damage = NPC.GetProjectileDamage(type); - Vector2 cloudSpawnPos = new Vector2(NPC.position.X + Main.rand.Next(NPC.width), NPC.position.Y + Main.rand.Next(NPC.height)); + Vector2 cloudSpawnPos = new Vector2(NPC.position.X + Main.rand.Next(NPC.width), NPC.position.Y + Main.rand.Next(height_Phase2)); Vector2 randomVelocity = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? Main.rand.NextVector2CircularEdge(4f, 4f) : Vector2.Zero; Projectile.NewProjectile(NPC.GetSource_FromAI(), cloudSpawnPos, randomVelocity, type, damage, 0, Main.myPlayer, 11f); } @@ -1099,17 +1088,17 @@ namespace CalamityMod.NPCs.HiveMind public override void HitEffect(NPC.HitInfo hit) { - for (int k = 0; k < hit.Damage / NPC.lifeMax * 100.0; k++) - Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Demonite, hit.HitDirection, -1f, 0, default, 1f); - // When Hive Mind starts flying around bool phase2 = NPC.life / (float)NPC.lifeMax < 0.8f; + for (int k = 0; k < hit.Damage / NPC.lifeMax * 100.0; k++) + Dust.NewDust(NPC.position, NPC.width, phase2 ? height_Phase2 : NPC.height, DustID.Demonite, hit.HitDirection, -1f, 0, default, 1f); + if (phase2) { if (Main.netMode != NetmodeID.MultiplayerClient && Main.zenithWorld ? NPC.CountNPCS(ModContent.NPCType()) < 10 : (Main.rand.NextBool(15) && NPC.CountNPCS(ModContent.NPCType()) < 2)) { - Vector2 spawnAt = NPC.Center + new Vector2(0f, NPC.height / 2f); + Vector2 spawnAt = NPC.Center + new Vector2(0f, height_Phase2 / 2f); NPC.NewNPC(NPC.GetSource_FromThis(), (int)spawnAt.X, (int)spawnAt.Y, ModContent.NPCType()); } } @@ -1141,14 +1130,14 @@ namespace CalamityMod.NPCs.HiveMind } NPC.position.X = NPC.position.X + (NPC.width / 2); - NPC.position.Y = NPC.position.Y + (NPC.height / 2); + NPC.position.Y = NPC.position.Y + (height_Phase2 / 2); NPC.width = 200; NPC.height = 150; NPC.position.X = NPC.position.X - (NPC.width / 2); - NPC.position.Y = NPC.position.Y - (NPC.height / 2); + NPC.position.Y = NPC.position.Y - (height_Phase2 / 2); for (int i = 0; i < 40; i++) { - int killDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Demonite, 0f, 0f, 100, default, 2f); + int killDust = Dust.NewDust(NPC.position, NPC.width, height_Phase2, DustID.Demonite, 0f, 0f, 100, default, 2f); Main.dust[killDust].velocity *= 3f; if (Main.rand.NextBool()) { @@ -1158,10 +1147,10 @@ namespace CalamityMod.NPCs.HiveMind } for (int j = 0; j < 70; j++) { - int killDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Demonite, 0f, 0f, 100, default, 3f); + int killDust2 = Dust.NewDust(NPC.position, NPC.width, height_Phase2, DustID.Demonite, 0f, 0f, 100, default, 3f); Main.dust[killDust2].noGravity = true; Main.dust[killDust2].velocity *= 5f; - killDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Demonite, 0f, 0f, 100, default, 2f); + killDust2 = Dust.NewDust(NPC.position, NPC.width, height_Phase2, DustID.Demonite, 0f, 0f, 100, default, 2f); Main.dust[killDust2].velocity *= 2f; } } diff --git a/NPCs/NormalNPCs/BloodlettingServant.cs b/NPCs/NormalNPCs/BloodlettingServant.cs index 3ec7e710f1..879a389f03 100644 --- a/NPCs/NormalNPCs/BloodlettingServant.cs +++ b/NPCs/NormalNPCs/BloodlettingServant.cs @@ -248,7 +248,7 @@ namespace CalamityMod.NPCs.NormalNPCs { Texture2D npcTexture = TextureAssets.Npc[NPC.type].Value; Color originalColor = NPC.GetAlpha(drawColor); - Color newColor = new Color(255, 128, 128, 255 - NPC.alpha); + Color newColor = new Color(255, 192, 192, 255 - NPC.alpha); Vector2 drawPosition = NPC.Center - screenPos + new Vector2(0, NPC.gfxOffY); Vector2 origin = NPC.frame.Size() / 2; @@ -284,7 +284,7 @@ namespace CalamityMod.NPCs.NormalNPCs return true; } - public override Color? GetAlpha(Color drawColor) => new Color(128, 0, 0, 255 - NPC.alpha); + public override Color? GetAlpha(Color drawColor) => new Color(192, 0, 0, 255 - NPC.alpha); public override void HitEffect(NPC.HitInfo hit) { diff --git a/NPCs/NormalNPCs/KingSlimeJewel3.cs b/NPCs/NormalNPCs/KingSlimeJewelEmerald.cs similarity index 99% rename from NPCs/NormalNPCs/KingSlimeJewel3.cs rename to NPCs/NormalNPCs/KingSlimeJewelEmerald.cs index 91668e6b70..5d5160792f 100644 --- a/NPCs/NormalNPCs/KingSlimeJewel3.cs +++ b/NPCs/NormalNPCs/KingSlimeJewelEmerald.cs @@ -10,7 +10,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.NormalNPCs { - public class KingSlimeJewel3 : ModNPC + public class KingSlimeJewelEmerald : ModNPC { public override string Texture => "CalamityMod/NPCs/NormalNPCs/KingSlimeJewel"; @@ -35,7 +35,7 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.defense = 15; NPC.DR_NERD(0.15f); - NPC.lifeMax = 280; + NPC.lifeMax = 240; double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; NPC.lifeMax += (int)(NPC.lifeMax * HPBoost); diff --git a/NPCs/NormalNPCs/KingSlimeJewel.cs b/NPCs/NormalNPCs/KingSlimeJewelRuby.cs similarity index 96% rename from NPCs/NormalNPCs/KingSlimeJewel.cs rename to NPCs/NormalNPCs/KingSlimeJewelRuby.cs index a6edbdf1f8..327d1d0054 100644 --- a/NPCs/NormalNPCs/KingSlimeJewel.cs +++ b/NPCs/NormalNPCs/KingSlimeJewelRuby.cs @@ -10,8 +10,10 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.NormalNPCs { - public class KingSlimeJewel : ModNPC + public class KingSlimeJewelRuby : ModNPC { + public override string Texture => "CalamityMod/NPCs/NormalNPCs/KingSlimeJewel"; + private const int BoltShootGateValue = 60; private const int BoltShootGateValue_Death = 75; private const int BoltShootGateValue_BossRush = 45; @@ -33,7 +35,7 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.defense = 10; NPC.DR_NERD(0.1f); - NPC.lifeMax = 140; + NPC.lifeMax = 120; double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; NPC.lifeMax += (int)(NPC.lifeMax * HPBoost); @@ -152,8 +154,8 @@ namespace CalamityMod.NPCs.NormalNPCs int damage = NPC.GetProjectileDamage(type); if (CalamityWorld.death || BossRushEvent.BossRushActive) { - int numProj = 5; - float rotation = MathHelper.ToRadians(12); + int numProj = Main.masterMode ? 5 : 4; + float rotation = MathHelper.ToRadians(18); for (int i = 0; i < numProj; i++) { Vector2 perturbedSpeed = projVector.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); diff --git a/NPCs/NormalNPCs/KingSlimeJewel2.cs b/NPCs/NormalNPCs/KingSlimeJewelSapphire.cs similarity index 90% rename from NPCs/NormalNPCs/KingSlimeJewel2.cs rename to NPCs/NormalNPCs/KingSlimeJewelSapphire.cs index d18df61e1d..a41db05782 100644 --- a/NPCs/NormalNPCs/KingSlimeJewel2.cs +++ b/NPCs/NormalNPCs/KingSlimeJewelSapphire.cs @@ -11,7 +11,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.NormalNPCs { - public class KingSlimeJewel2 : ModNPC + public class KingSlimeJewelSapphire : ModNPC { public override string Texture => "CalamityMod/NPCs/NormalNPCs/KingSlimeJewel"; @@ -34,7 +34,7 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.defense = 5; NPC.DR_NERD(0.05f); - NPC.lifeMax = 140; + NPC.lifeMax = 120; double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; NPC.lifeMax += (int)(NPC.lifeMax * HPBoost); @@ -71,7 +71,20 @@ namespace CalamityMod.NPCs.NormalNPCs float velocity = 5f; float acceleration = 0.1f; - if (NPC.position.Y > Main.player[NPC.target].position.Y - 300f) + int distanceFromKingSlime = 1; + Vector2 kingSlimeCenter = NPC.Center; + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].active && Main.npc[i].type == NPCID.KingSlime) + { + distanceFromKingSlime = (int)NPC.Distance(Main.npc[i].Center); + kingSlimeCenter = Main.npc[i].Center; + break; + } + } + + Vector2 movementTarget = kingSlimeCenter == NPC.Center ? Main.player[NPC.target].Center : kingSlimeCenter; + if (NPC.position.Y > movementTarget.Y - 200f) { if (NPC.velocity.Y > 0f) NPC.velocity.Y *= 0.98f; @@ -81,7 +94,7 @@ namespace CalamityMod.NPCs.NormalNPCs if (NPC.velocity.Y > velocity) NPC.velocity.Y = velocity; } - else if (NPC.position.Y < Main.player[NPC.target].position.Y - 400f) + else if (NPC.position.Y < movementTarget.Y - 250f) { if (NPC.velocity.Y < 0f) NPC.velocity.Y *= 0.98f; @@ -92,7 +105,7 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.velocity.Y = -velocity; } - if (NPC.Center.X > Main.player[NPC.target].Center.X + 300f) + if (NPC.Center.X > movementTarget.X + 100f) { if (NPC.velocity.X > 0f) NPC.velocity.X *= 0.98f; @@ -102,7 +115,7 @@ namespace CalamityMod.NPCs.NormalNPCs if (NPC.velocity.X > 8f) NPC.velocity.X = 8f; } - if (NPC.Center.X < Main.player[NPC.target].Center.X - 300f) + if (NPC.Center.X < movementTarget.X - 100f) { if (NPC.velocity.X < 0f) NPC.velocity.X *= 0.98f; @@ -121,18 +134,6 @@ namespace CalamityMod.NPCs.NormalNPCs SoundEngine.PlaySound(SoundID.Item8, NPC.Center); - int distanceFromKingSlime = 1; - Vector2 kingSlimeCenter = NPC.Center; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == NPCID.KingSlime) - { - distanceFromKingSlime = (int)NPC.Distance(Main.npc[i].Center); - kingSlimeCenter = Main.npc[i].Center; - break; - } - } - for (int dusty = 0; dusty < 10; dusty++) { Vector2 dustVel = (kingSlimeCenter - NPC.Center).SafeNormalize(Vector2.UnitY) * Main.rand.NextFloat(2f, 4f); diff --git a/NPCs/NormalNPCs/SkeletronPrime2.cs b/NPCs/NormalNPCs/SkeletronPrime2.cs index 6164daf879..d644a5d641 100644 --- a/NPCs/NormalNPCs/SkeletronPrime2.cs +++ b/NPCs/NormalNPCs/SkeletronPrime2.cs @@ -268,28 +268,32 @@ namespace CalamityMod.NPCs.NormalNPCs // Start other phases; if arms are dead, start with spin phase bool otherHeadChargingOrSpinning = Main.npc[(int)NPC.ai[0]].ai[1] == 5f || Main.npc[(int)NPC.ai[0]].ai[1] == 1f; - if (phase2 || CalamityWorld.LegendaryMode || allArmsDead) + + // Start spin phase after 1.875 seconds + NPC.ai[2] += phase3 ? 1.2f : 0.8f; + if (NPC.ai[2] >= (90f - (death ? 15f * (1f - lifeRatio) : 0f)) && (!otherHeadChargingOrSpinning || phase3) && canUseAttackInMaster) { - // Start spin phase after 1.875 seconds - NPC.ai[2] += phase3 ? 1.2f : 0.8f; - if (NPC.ai[2] >= (90f - (death ? 15f * (1f - lifeRatio) : 0f)) && (!otherHeadChargingOrSpinning || phase3) && canUseAttackInMaster) + bool shouldSpinAround = NPC.ai[1] == 4f && NPC.position.Y < Main.player[Main.npc[(int)NPC.ai[0]].target].position.Y - 400f && + Vector2.Distance(Main.player[Main.npc[(int)NPC.ai[0]].target].Center, NPC.Center) < 600f && Vector2.Distance(Main.player[Main.npc[(int)NPC.ai[0]].target].Center, NPC.Center) > 400f; + + bool shouldCharge = !phase2 && !allArmsDead && !CalamityWorld.LegendaryMode; + if (shouldCharge) { - bool shouldSpinAround = NPC.ai[1] == 4f && NPC.position.Y < Main.player[Main.npc[(int)NPC.ai[0]].target].position.Y - 400f && - Vector2.Distance(Main.player[Main.npc[(int)NPC.ai[0]].target].Center, NPC.Center) < 600f && Vector2.Distance(Main.player[Main.npc[(int)NPC.ai[0]].target].Center, NPC.Center) > 400f; - - if (shouldSpinAround || NPC.ai[1] != 4f) + NPC.ai[2] = 0f; + NPC.ai[1] = 1f; + NPC.netUpdate = true; + } + else if (shouldSpinAround || NPC.ai[1] != 4f) + { + if (shouldSpinAround) { - if (shouldSpinAround) - { - NPC.localAI[3] = 300f; - NPC.SyncVanillaLocalAI(); - } - - NPC.ai[2] = 0f; - NPC.ai[1] = shouldSpinAround ? 5f : 1f; - NPC.TargetClosest(); - NPC.netUpdate = true; + NPC.localAI[3] = 300f; + NPC.SyncVanillaLocalAI(); } + + NPC.ai[2] = 0f; + NPC.ai[1] = shouldSpinAround ? 5f : 1f; + NPC.netUpdate = true; } } @@ -432,7 +436,6 @@ namespace CalamityMod.NPCs.NormalNPCs if (NPC.ai[2] >= (phaseTimer - (death ? 60f * (1f - lifeRatio) : 0f))) { - NPC.TargetClosest(); NPC.ai[2] = 0f; NPC.ai[1] = 4f; NPC.localAI[0] = 0f; @@ -691,7 +694,6 @@ namespace CalamityMod.NPCs.NormalNPCs calamityGlobalNPC.newAI[0] = 0f; NPC.SyncVanillaLocalAI(); NPC.SyncExtraAI(); - NPC.TargetClosest(); NPC.netUpdate = true; } } @@ -769,7 +771,6 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.localAI[0] = 0f; NPC.SyncVanillaLocalAI(); NPC.SyncExtraAI(); - NPC.TargetClosest(); NPC.netUpdate = true; } } diff --git a/NPCs/ProfanedGuardians/ProfanedGuardianCommander.cs b/NPCs/ProfanedGuardians/ProfanedGuardianCommander.cs index d85a7326d6..a98ab63273 100644 --- a/NPCs/ProfanedGuardians/ProfanedGuardianCommander.cs +++ b/NPCs/ProfanedGuardians/ProfanedGuardianCommander.cs @@ -13,6 +13,7 @@ using CalamityMod.Items.Placeables.Furniture.Trophies; using CalamityMod.Items.SummonItems; using CalamityMod.Items.Weapons.Typeless; using CalamityMod.Projectiles.Boss; +using CalamityMod.UI.VanillaBossBars; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -33,7 +34,6 @@ namespace CalamityMod.NPCs.ProfanedGuardians { private int spearType = 0; private int healTimer = 0; - private int biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; private const float TimeForShieldDespawn = 120f; public static readonly SoundStyle HolyRaySound = new("CalamityMod/Sounds/Custom/ProfanedGuardians/GuardianRay") { Volume = 1.25f }; public static readonly SoundStyle DashSound = new("CalamityMod/Sounds/Custom/ProfanedGuardians/GuardianDash"); @@ -82,6 +82,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians NPC.noTileCollide = true; AIType = -1; NPC.boss = true; + NPC.BossBar = ModContent.GetInstance(); NPC.value = Item.buyPrice(1, 0, 0, 0); NPC.HitSound = SoundID.NPCHit52; NPC.DeathSound = SoundID.NPCDeath55; @@ -105,7 +106,6 @@ namespace CalamityMod.NPCs.ProfanedGuardians { writer.Write(spearType); writer.Write(healTimer); - writer.Write(biomeEnrageTimer); writer.Write(NPC.chaseable); writer.Write(NPC.localAI[0]); writer.Write(NPC.localAI[1]); @@ -119,7 +119,6 @@ namespace CalamityMod.NPCs.ProfanedGuardians { spearType = reader.ReadInt32(); healTimer = reader.ReadInt32(); - biomeEnrageTimer = reader.ReadInt32(); NPC.chaseable = reader.ReadBoolean(); NPC.localAI[0] = reader.ReadSingle(); NPC.localAI[1] = reader.ReadSingle(); @@ -297,11 +296,11 @@ namespace CalamityMod.NPCs.ProfanedGuardians Player player = Main.player[NPC.target]; - if ((!Main.dayTime && !Main.remixWorld) || !player.active || player.dead || Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) + if (!player.active || player.dead || Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) { NPC.TargetClosest(false); player = Main.player[NPC.target]; - if ((!Main.dayTime && !Main.remixWorld) || !player.active || player.dead || Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) + if (!player.active || player.dead || Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) { if (NPC.velocity.Y > 3f) NPC.velocity.Y = 3f; @@ -334,20 +333,13 @@ namespace CalamityMod.NPCs.ProfanedGuardians if (NPC.ai[3] < 0f) NPC.ai[3] = 0f; - // Become immune over time if target isn't in hell or hallow - bool isHoly = player.ZoneHallow; - bool isHell = player.ZoneUnderworldHeight; - if (!isHoly && !isHell && !bossRush) + // Enrage at nighttime + bool enraged = false; + if (!Main.dayTime && !Main.remixWorld) { - if (biomeEnrageTimer > 0) - biomeEnrageTimer--; - else - NPC.Calamity().CurrentlyEnraged = true; + enraged = true; + NPC.Calamity().CurrentlyEnraged = true; } - else - biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; - - bool biomeEnraged = biomeEnrageTimer <= 0; bool phase1 = healerAlive || defenderAlive; @@ -373,7 +365,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians float goLowOrHighDistance = 540f; // Side swap variables for Phase 2 - float defenderCommanderGuardPhase2Duration = (bossRush || biomeEnraged) ? 420f : death ? 480f : revenge ? 510f : expertMode ? 540f : 600f; + float defenderCommanderGuardPhase2Duration = (bossRush || enraged) ? 420f : death ? 480f : revenge ? 510f : expertMode ? 540f : 600f; float moveToOtherSideInPhase2GateValue = defenderCommanderGuardPhase2Duration - 120f; float timeBeforeMoveToOtherSideInPhase2Reset = moveToOtherSideInPhase2GateValue * 2f; float totalGoLowDurationPhase2 = 210f; @@ -381,13 +373,13 @@ namespace CalamityMod.NPCs.ProfanedGuardians // Charge variables float chargeVelocityMult = 0.25f; - float maxChargeVelocity = (bossRush || biomeEnraged) ? 32f : death ? 28f : revenge ? 26f : expertMode ? 24f : 20f; + float maxChargeVelocity = (bossRush || enraged) ? 32f : death ? 28f : revenge ? 26f : expertMode ? 24f : 20f; if (Main.getGoodWorld) maxChargeVelocity *= 1.15f; if (CalamityWorld.LegendaryMode && revenge) maxChargeVelocity *= 2f; - float inertia = (bossRush || biomeEnraged) ? 40f : death ? 45f : revenge ? 47f : expertMode ? 50f : 55f; + float inertia = (bossRush || enraged) ? 40f : death ? 45f : revenge ? 47f : expertMode ? 50f : 55f; if (lifeRatio < 0.5f) inertia *= 0.8f; if (!phase1) @@ -470,7 +462,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians if (!goLow && !goLowPhase2 && !goHigh) calamityGlobalNPC.newAI[0] = -NPC.direction; - float velocity = (bossRush || biomeEnraged) ? 18f : death ? 16f : revenge ? 15f : expertMode ? 14f : 12f; + float velocity = (bossRush || enraged) ? 18f : death ? 16f : revenge ? 15f : expertMode ? 14f : 12f; if (Main.getGoodWorld) velocity *= 1.25f; if (healerAlive) @@ -507,7 +499,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians Vector2 targetVector = destination - NPC.Center; Vector2 desiredVelocity = targetVector.SafeNormalize(new Vector2(NPC.direction, 0f)) * velocity; - float phaseGateValue = (bossRush || biomeEnraged) ? 50f : death ? 66f : revenge ? 75f : expertMode ? 83f : 100f; + float phaseGateValue = (bossRush || enraged) ? 50f : death ? 66f : revenge ? 75f : expertMode ? 83f : 100f; bool continueShootingProjectiles = phase1 || (NPC.ai[2] < (phaseGateValue * 5f)); if (continueShootingProjectiles) @@ -521,7 +513,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians // Alternate between firing profaned spears and holy fire // Shoot holy blasts in final phase NPC.ai[2] += 1f; - float projectileShootGateValue = (bossRush || biomeEnraged) ? 40f : death ? 60f : revenge ? 90f : expertMode ? 100f : 150f; + float projectileShootGateValue = (bossRush || enraged) ? 40f : death ? 60f : revenge ? 90f : expertMode ? 100f : 150f; if (NPC.ai[2] % projectileShootGateValue == 0f) { if (phase1) @@ -535,7 +527,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians } bool shootSpear = NPC.ai[2] % (projectileShootGateValue * 2f) == 0f; - float projectileVelocity = (bossRush || biomeEnraged) ? 18f : death ? 16f : revenge ? 15f : expertMode ? 14f : 12f; + float projectileVelocity = (bossRush || enraged) ? 18f : death ? 16f : revenge ? 15f : expertMode ? 14f : 12f; Vector2 finalProjectileVelocity = Vector2.Normalize(player.Center - shootFrom) * projectileVelocity; int type = shootSpear ? ModContent.ProjectileType() : ModContent.ProjectileType(); int damage = NPC.GetProjectileDamage(type); @@ -548,8 +540,8 @@ namespace CalamityMod.NPCs.ProfanedGuardians if (fireExtraProjectiles && shootSpear) { - int baseProjectileAmt = (bossRush || biomeEnraged) ? 4 : 2; - int spread = (bossRush || biomeEnraged) ? 18 : 10; + int baseProjectileAmt = (bossRush || enraged) ? 4 : 2; + int spread = (bossRush || enraged) ? 18 : 10; float rotation = MathHelper.ToRadians(spread); for (int i = 0; i < baseProjectileAmt; i++) { @@ -568,7 +560,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians else { // Shoot holy blasts - float holyBlastVelocity = (bossRush || biomeEnraged) ? 20f : death ? 18f : revenge ? 17f : expertMode ? 16f : 14f; + float holyBlastVelocity = (bossRush || enraged) ? 20f : death ? 18f : revenge ? 17f : expertMode ? 16f : 14f; int projTimeLeft = (int)(2000f / holyBlastVelocity); Vector2 finalHolyBlastVelocity = Vector2.Normalize(player.Center - shootFrom) * holyBlastVelocity; if (Main.netMode != NetmodeID.MultiplayerClient) @@ -681,7 +673,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians NPC.spriteDirection = Math.Sign(NPC.velocity.X); NPC.ai[1] += 1f; - float phaseGateValue = (bossRush || biomeEnraged) ? 90f : death ? 100f : revenge ? 110f : expertMode ? 120f : 135f; + float phaseGateValue = (bossRush || enraged) ? 90f : death ? 100f : revenge ? 110f : expertMode ? 120f : 135f; if (NPC.ai[1] >= phaseGateValue) { NPC.ai[0] = 3f; @@ -702,7 +694,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians // Accelerate if (NPC.velocity.Length() < maxChargeVelocity) { - float velocityMult = (bossRush || biomeEnraged) ? 1.053333f : death ? 1.05037f : revenge ? 1.047407f : expertMode ? 1.044444f : 1.04f; + float velocityMult = (bossRush || enraged) ? 1.053333f : death ? 1.05037f : revenge ? 1.047407f : expertMode ? 1.044444f : 1.04f; NPC.velocity = targetVector * (NPC.velocity.Length() * velocityMult); if (NPC.velocity.Length() > maxChargeVelocity) { @@ -790,7 +782,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians bool targetRanAwayAndWillNowBeFucked = NPC.ai[2] == 1f; bool boostVelocityToCatchUp = NPC.ai[1] == 0f || targetRanAwayAndWillNowBeFucked; - float velocity = (bossRush || biomeEnraged) ? 18f : death ? 16f : revenge ? 15f : expertMode ? 14f : 12f; + float velocity = (bossRush || enraged) ? 18f : death ? 16f : revenge ? 15f : expertMode ? 14f : 12f; if (Main.getGoodWorld) velocity *= 1.25f; if (boostVelocityToCatchUp) @@ -802,7 +794,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians Vector2 desiredVelocity = targetVector.SafeNormalize(new Vector2(NPC.direction, 0f)) * velocity; float totalSpears = 12f; - float shootDuration = (bossRush || biomeEnraged) ? 240f : death ? 280f : revenge ? 300f : expertMode ? 320f : 360f; + float shootDuration = (bossRush || enraged) ? 240f : death ? 280f : revenge ? 300f : expertMode ? 320f : 360f; float dontShootTime = shootDuration * 0.3f; float phaseGateValue = dontShootTime + shootDuration; @@ -847,7 +839,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians } else if (NPC.ai[1] % spearShootDivisor == 0f) { - float spearVelocity = (bossRush || biomeEnraged) ? 18f : death ? 16f : revenge ? 15f : expertMode ? 14f : 12f; + float spearVelocity = (bossRush || enraged) ? 18f : death ? 16f : revenge ? 15f : expertMode ? 14f : 12f; if (Main.getGoodWorld) spearVelocity *= 1.25f; if (boostVelocityToCatchUp) @@ -865,8 +857,8 @@ namespace CalamityMod.NPCs.ProfanedGuardians if (NPC.ai[1] % (spearShootDivisor * 3) == 0f || targetRanAwayAndWillNowBeFucked) { knockbackVelocity *= 2f; - int baseProjectileAmt = (bossRush || biomeEnraged) ? 8 : expertMode ? 6 : 4; - int spread = (bossRush || biomeEnraged) ? 60 : expertMode ? 50 : 40; + int baseProjectileAmt = (bossRush || enraged) ? 8 : expertMode ? 6 : 4; + int spread = (bossRush || enraged) ? 60 : expertMode ? 50 : 40; float rotation = MathHelper.ToRadians(spread); for (int i = 0; i < baseProjectileAmt; i++) { @@ -902,7 +894,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians } float laserGateValue = 120f; - float velocity = (bossRush || biomeEnraged) ? 4.5f : death ? 4f : revenge ? 3.75f : expertMode ? 3.5f : 3f; + float velocity = (bossRush || enraged) ? 4.5f : death ? 4f : revenge ? 3.75f : expertMode ? 3.5f : 3f; if (NPC.ai[1] < laserGateValue) velocity *= 6f; if (Main.getGoodWorld) @@ -958,7 +950,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians { if (NPC.ai[2] == laserGateValue) { - float rotation = (bossRush || biomeEnraged) ? 435f : death ? 445f : revenge ? 450f : expertMode ? 455f : 465f; + float rotation = (bossRush || enraged) ? 435f : death ? 445f : revenge ? 450f : expertMode ? 455f : 465f; if (Main.player[Main.myPlayer].active && !Main.player[Main.myPlayer].dead && Vector2.Distance(Main.player[Main.myPlayer].Center, NPC.Center) < 2800f) SoundEngine.PlaySound(HolyRaySound, Main.LocalPlayer.Center); @@ -1048,10 +1040,15 @@ namespace CalamityMod.NPCs.ProfanedGuardians texture2D15 = Texture_Glow.Value; Color timeBasedColorLerp = Color.Lerp(Color.White, Color.Yellow, 0.5f); - if (Main.remixWorld) + if (NPC.Calamity().CurrentlyEnraged) { texture2D15 = TextureNight_Glow.Value; - timeBasedColorLerp = Color.Cyan; + timeBasedColorLerp = Color.Lerp(Color.White, Color.Cyan, 0.75f); + } + if (Main.zenithWorld) + { + texture2D15 = TextureNight_Glow.Value; + timeBasedColorLerp = Main.DiscoColor; } if (colorOverride != null) timeBasedColorLerp = colorOverride.Value; @@ -1150,14 +1147,14 @@ namespace CalamityMod.NPCs.ProfanedGuardians Vector2 shieldDrawPos = NPC.Center - screenPos; shieldDrawPos -= new Vector2(shieldTexture.Width, shieldTexture.Height) * NPC.scale / 2f; shieldDrawPos += origin * NPC.scale + new Vector2(0f, NPC.gfxOffY); - float minHue = (defenderAlive && healerAlive) ? 0.18f : 0.06f; + float minHue = NPC.Calamity().CurrentlyEnraged ? 0.4f : (defenderAlive && healerAlive) ? 0.18f : 0.06f; float maxHue = minHue + 0.12f; float opacityScaleDuringShieldDespawn = (TimeForShieldDespawn - NPC.localAI[1]) / TimeForShieldDespawn; float scaleDuringShieldDespawnScale = 1.8f; float scaleDuringShieldDespawn = (1f - opacityScaleDuringShieldDespawn) * scaleDuringShieldDespawnScale; float colorScale = MathHelper.Lerp(0f, shieldOpacity, opacityScaleDuringShieldDespawn); - Color color = Main.hslToRgb(MathHelper.Lerp(maxHue - minHue, maxHue, ((float)Math.Sin(Main.GlobalTimeWrappedHourly * MathHelper.TwoPi) + 1f) * 0.5f), 1f, 0.5f) * colorScale; - Color color2 = Main.hslToRgb(MathHelper.Lerp(minHue, maxHue - minHue, ((float)Math.Sin(Main.GlobalTimeWrappedHourly * MathHelper.Pi * 3f) + 1f) * 0.5f), 1f, 0.5f) * colorScale; + Color color = Main.hslToRgb(MathHelper.Lerp(NPC.Calamity().CurrentlyEnraged ? minHue : maxHue - minHue, maxHue, ((float)Math.Sin(Main.GlobalTimeWrappedHourly * MathHelper.TwoPi) + 1f) * 0.5f), 1f, 0.5f) * colorScale; + Color color2 = Main.hslToRgb(MathHelper.Lerp(minHue, NPC.Calamity().CurrentlyEnraged ? maxHue : maxHue - minHue, ((float)Math.Sin(Main.GlobalTimeWrappedHourly * MathHelper.Pi * 3f) + 1f) * 0.5f), 1f, 0.5f) * colorScale; color2.A = 0; color *= 0.6f; color2 *= 0.6f; diff --git a/NPCs/ProfanedGuardians/ProfanedGuardianDefender.cs b/NPCs/ProfanedGuardians/ProfanedGuardianDefender.cs index dc0fba164b..b4033cedc5 100644 --- a/NPCs/ProfanedGuardians/ProfanedGuardianDefender.cs +++ b/NPCs/ProfanedGuardians/ProfanedGuardianDefender.cs @@ -24,7 +24,6 @@ namespace CalamityMod.NPCs.ProfanedGuardians public class ProfanedGuardianDefender : ModNPC { private int healTimer = 0; - private int biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; private const float TimeForShieldDespawn = 120f; public static readonly SoundStyle DashSound = new("CalamityMod/Sounds/Custom/ProfanedGuardians/GuardianDash"); public static readonly SoundStyle RockShieldSpawnSound = new("CalamityMod/Sounds/Custom/ProfanedGuardians/GuardianRockShieldActivate"); @@ -100,7 +99,6 @@ namespace CalamityMod.NPCs.ProfanedGuardians public override void SendExtraAI(BinaryWriter writer) { writer.Write(healTimer); - writer.Write(biomeEnrageTimer); writer.Write(NPC.chaseable); writer.Write(NPC.localAI[0]); writer.Write(NPC.localAI[1]); @@ -111,7 +109,6 @@ namespace CalamityMod.NPCs.ProfanedGuardians public override void ReceiveExtraAI(BinaryReader reader) { healTimer = reader.ReadInt32(); - biomeEnrageTimer = reader.ReadInt32(); NPC.chaseable = reader.ReadBoolean(); NPC.localAI[0] = reader.ReadSingle(); NPC.localAI[1] = reader.ReadSingle(); @@ -250,28 +247,21 @@ namespace CalamityMod.NPCs.ProfanedGuardians bool expertMode = Main.expertMode || bossRush; bool revenge = CalamityWorld.revenge || bossRush; bool death = CalamityWorld.death || bossRush; - bool isHoly = player.ZoneHallow; - bool isHell = player.ZoneUnderworldHeight; - // Become immune over time if target isn't in hell or hallow - if (!isHoly && !isHell && !bossRush) + // Enrage at nighttime + bool enraged = false; + if (!Main.dayTime && !Main.remixWorld) { - if (biomeEnrageTimer > 0) - biomeEnrageTimer--; - else - NPC.Calamity().CurrentlyEnraged = true; + enraged = true; + NPC.Calamity().CurrentlyEnraged = true; } - else - biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; - - bool biomeEnraged = biomeEnrageTimer <= 0; bool phase1 = healerAlive; NPC.chaseable = !phase1; // Phase durations - float commanderGuardPhase2Duration = (bossRush || biomeEnraged) ? 420f : death ? 480f : revenge ? 510f : expertMode ? 540f : 600f; + float commanderGuardPhase2Duration = (bossRush || enraged) ? 420f : death ? 480f : revenge ? 510f : expertMode ? 540f : 600f; float timeBeforeRocksRespawnInPhase2 = 90f; float throwRocksGateValue = 60f; @@ -280,7 +270,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians // Charge variables float chargeVelocityMult = 0.25f; - float maxChargeVelocity = (bossRush || biomeEnraged) ? 25f : death ? 22f : revenge ? 20.5f : expertMode ? 19f : 16f; + float maxChargeVelocity = (bossRush || enraged) ? 25f : death ? 22f : revenge ? 20.5f : expertMode ? 19f : 16f; if (Main.getGoodWorld) maxChargeVelocity *= 1.15f; @@ -400,7 +390,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians } } - float moveVelocity = (bossRush || biomeEnraged) ? 24f : death ? 22f : revenge ? 21f : expertMode ? 20f : 18f; + float moveVelocity = (bossRush || enraged) ? 24f : death ? 22f : revenge ? 21f : expertMode ? 20f : 18f; if (Main.getGoodWorld) moveVelocity *= 1.25f; if (healerAlive) @@ -450,7 +440,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians // Lay a holy bomb every once in a while in phase 1 and while not doing the laser attack if (!commanderUsingLaser) { - float projectileShootGateValue = (bossRush || biomeEnraged) ? 420f : death ? 480f : revenge ? 510f : expertMode ? 540f : 600f; + float projectileShootGateValue = (bossRush || enraged) ? 420f : death ? 480f : revenge ? 510f : expertMode ? 540f : 600f; NPC.ai[1] += 1f; if (NPC.ai[1] >= projectileShootGateValue) { @@ -520,7 +510,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians float shootMoltenBlastsGateValue = commanderGuardPhase2Duration / moltenBlastsDivisor; if (NPC.ai[1] % shootMoltenBlastsGateValue == 0f && !commanderGoingLowOrHighInPhase2) { - float moltenBlastVelocity = (bossRush || biomeEnraged) ? 18f : death ? 16f : revenge ? 15f : expertMode ? 14f : 12f; + float moltenBlastVelocity = (bossRush || enraged) ? 18f : death ? 16f : revenge ? 15f : expertMode ? 14f : 12f; int projTimeLeft = (int)(2400f / moltenBlastVelocity); Vector2 velocity = Vector2.Normalize(player.Center - shootFrom) * moltenBlastVelocity; if (Main.netMode != NetmodeID.MultiplayerClient) @@ -627,7 +617,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians NPC.spriteDirection = Math.Sign(NPC.velocity.X); NPC.ai[1] += 1f; - float phaseGateValue = (bossRush || biomeEnraged) ? 120f : death ? 140f : revenge ? 150f : expertMode ? 160f : 180f; + float phaseGateValue = (bossRush || enraged) ? 120f : death ? 140f : revenge ? 150f : expertMode ? 160f : 180f; if (NPC.ai[1] >= phaseGateValue) { NPC.ai[0] = 3f; @@ -648,7 +638,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians // Accelerate if (NPC.velocity.Length() < maxChargeVelocity) { - float velocityMult = (bossRush || biomeEnraged) ? 1.04f : death ? 1.036667f : revenge ? 1.035f : expertMode ? 1.033333f : 1.03f; + float velocityMult = (bossRush || enraged) ? 1.04f : death ? 1.036667f : revenge ? 1.035f : expertMode ? 1.033333f : 1.03f; NPC.velocity = targetVector * (NPC.velocity.Length() * velocityMult); if (NPC.velocity.Length() > maxChargeVelocity) { @@ -660,7 +650,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians else { // Charge towards target - float inertia = (bossRush || biomeEnraged) ? 57f : death ? 63f : revenge ? 66f : expertMode ? 69f : 75f; + float inertia = (bossRush || enraged) ? 57f : death ? 63f : revenge ? 66f : expertMode ? 69f : 75f; NPC.velocity = (NPC.velocity * (inertia - 1f) + targetVector * (NPC.velocity.Length() + (0.111111117f * inertia))) / inertia; } @@ -773,10 +763,15 @@ namespace CalamityMod.NPCs.ProfanedGuardians texture2D15 = Texture_Glow.Value; Color timeBasedGlowColor = Color.Lerp(Color.White, Color.Yellow, 0.5f); - if (Main.remixWorld) + if (NPC.Calamity().CurrentlyEnraged) { texture2D15 = TextureNight_Glow.Value; - timeBasedGlowColor = Color.Cyan; + timeBasedGlowColor = Color.Lerp(Color.White, Color.Cyan, 0.75f); + } + if (Main.zenithWorld) + { + texture2D15 = TextureNight_Glow.Value; + timeBasedGlowColor = Main.DiscoColor; } if (colorOverride != null) timeBasedGlowColor = colorOverride.Value; @@ -867,14 +862,14 @@ namespace CalamityMod.NPCs.ProfanedGuardians Vector2 shieldDrawPos = NPC.Center - screenPos; shieldDrawPos -= new Vector2(shieldTexture.Width, shieldTexture.Height) * NPC.scale / 2f; shieldDrawPos += origin * NPC.scale + new Vector2(0f, NPC.gfxOffY); - float minHue = 0.06f; - float maxHue = 0.18f; + float minHue = NPC.Calamity().CurrentlyEnraged ? 0.4f : 0.06f; + float maxHue = minHue + 0.12f; float opacityScaleDuringShieldDespawn = (TimeForShieldDespawn - NPC.localAI[1]) / TimeForShieldDespawn; float scaleDuringShieldDespawnScale = 1.8f; float scaleDuringShieldDespawn = (1f - opacityScaleDuringShieldDespawn) * scaleDuringShieldDespawnScale; float colorScale = MathHelper.Lerp(0f, shieldOpacity, opacityScaleDuringShieldDespawn); - Color color = Main.hslToRgb(MathHelper.Lerp(maxHue - minHue, maxHue, ((float)Math.Sin(Main.GlobalTimeWrappedHourly * MathHelper.TwoPi) + 1f) * 0.5f), 1f, 0.5f) * colorScale; - Color color2 = Main.hslToRgb(MathHelper.Lerp(minHue, maxHue - minHue, ((float)Math.Sin(Main.GlobalTimeWrappedHourly * MathHelper.Pi * 3f) + 1f) * 0.5f), 1f, 0.5f) * colorScale; + Color color = Main.hslToRgb(MathHelper.Lerp(NPC.Calamity().CurrentlyEnraged ? minHue : maxHue - minHue, maxHue, ((float)Math.Sin(Main.GlobalTimeWrappedHourly * MathHelper.TwoPi) + 1f) * 0.5f), 1f, 0.5f) * colorScale; + Color color2 = Main.hslToRgb(MathHelper.Lerp(minHue, NPC.Calamity().CurrentlyEnraged ? maxHue : maxHue - minHue, ((float)Math.Sin(Main.GlobalTimeWrappedHourly * MathHelper.Pi * 3f) + 1f) * 0.5f), 1f, 0.5f) * colorScale; color2.A = 0; color *= 0.6f; color2 *= 0.6f; diff --git a/NPCs/ProfanedGuardians/ProfanedGuardianHealer.cs b/NPCs/ProfanedGuardians/ProfanedGuardianHealer.cs index cfc275078d..03ed34ed59 100644 --- a/NPCs/ProfanedGuardians/ProfanedGuardianHealer.cs +++ b/NPCs/ProfanedGuardians/ProfanedGuardianHealer.cs @@ -39,7 +39,6 @@ namespace CalamityMod.NPCs.ProfanedGuardians set => NPC.ai[3] = value; } - private int biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; public static Asset Texture_Glow; public static Asset Texture_Glow2; @@ -116,13 +115,11 @@ namespace CalamityMod.NPCs.ProfanedGuardians public override void SendExtraAI(BinaryWriter writer) { - writer.Write(biomeEnrageTimer); writer.Write(NPC.localAI[0]); } public override void ReceiveExtraAI(BinaryReader reader) { - biomeEnrageTimer = reader.ReadInt32(); NPC.localAI[0] = reader.ReadSingle(); } @@ -172,8 +169,6 @@ namespace CalamityMod.NPCs.ProfanedGuardians bool expertMode = Main.expertMode || bossRush; bool revenge = CalamityWorld.revenge || bossRush; bool death = CalamityWorld.death || bossRush; - bool isHoly = player.ZoneHallow; - bool isHell = player.ZoneUnderworldHeight; // Percent life remaining float lifeRatio = NPC.life / (float)NPC.lifeMax; @@ -183,18 +178,13 @@ namespace CalamityMod.NPCs.ProfanedGuardians if (NPC.ai[0] >= 300f) NPC.ai[1] = 1f; - // Become immune over time if target isn't in hell or hallow - if (!isHoly && !isHell && !BossRushEvent.BossRushActive) + // Enrage at nighttime + bool enraged = false; + if (!Main.dayTime && !Main.remixWorld) { - if (biomeEnrageTimer > 0) - biomeEnrageTimer--; - else - NPC.Calamity().CurrentlyEnraged = true; + enraged = true; + NPC.Calamity().CurrentlyEnraged = true; } - else - biomeEnrageTimer = CalamityGlobalNPC.biomeEnrageTimerMax; - - bool biomeEnraged = biomeEnrageTimer <= 0; // Direction if (Math.Abs(NPC.Center.X - player.Center.X) > 10f) @@ -235,7 +225,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians } bool useCrystalShards = AIState == (float)Phase.CrystalShards; - float velocity = useCrystalShards ? ((bossRush || biomeEnraged) ? 18f : death ? 16f : revenge ? 15f : expertMode ? 14f : 12f) : (Main.npc[CalamityGlobalNPC.doughnutBoss].velocity.Length() + 5f); + float velocity = useCrystalShards ? ((bossRush || enraged) ? 18f : death ? 16f : revenge ? 15f : expertMode ? 14f : 12f) : (Main.npc[CalamityGlobalNPC.doughnutBoss].velocity.Length() + 5f); if (Main.getGoodWorld) velocity *= 1.25f; @@ -323,7 +313,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians { int type = ModContent.ProjectileType(); int damage = NPC.GetProjectileDamage(type); - int totalProjectiles = biomeEnraged ? 18 : death ? 16 : revenge ? 14 : expertMode ? 12 : 10; + int totalProjectiles = (bossRush || enraged) ? 18 : death ? 16 : revenge ? 14 : expertMode ? 12 : 10; float speedX = -12f; float speedAdjustment = Math.Abs(speedX * 2f / (totalProjectiles - 1)); float speedY = -4f; @@ -362,7 +352,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians { SoundEngine.PlaySound(SoundID.DD2_BetsyFireballImpact, shootFrom); - int totalFlameProjectiles = biomeEnraged ? 20 : 16; + int totalFlameProjectiles = (bossRush || enraged) ? 20 : 16; int totalRings = revenge ? 3 : 2; int healingStarChance = revenge ? 8 : expertMode ? 6 : 4; double radians = MathHelper.TwoPi / totalFlameProjectiles; @@ -380,7 +370,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians int type = ModContent.ProjectileType(); int dmgAmt = NPC.GetProjectileDamage(type); - if (Main.rand.NextBool(healingStarChance) && !death) + if (Main.rand.NextBool(healingStarChance) && !enraged && !death) { type = ModContent.ProjectileType(); dmgAmt = NPC.GetProjectileDamageNoScaling(type); @@ -423,7 +413,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians // Move towards a location above the player if (distanceFromDestination.Length() > idealDistanceFromDestination) { - float inertia = (bossRush || biomeEnraged) ? 28f : death ? 32f : revenge ? 34f : expertMode ? 36f : 40f; + float inertia = (bossRush || enraged) ? 28f : death ? 32f : revenge ? 34f : expertMode ? 36f : 40f; if (lifeRatio < 0.5f) inertia *= 0.8f; if (Main.getGoodWorld) @@ -478,10 +468,15 @@ namespace CalamityMod.NPCs.ProfanedGuardians texture2D15 = Texture_Glow.Value; Color timeBasedDrawColor = Color.Lerp(Color.White, Color.Yellow, 0.5f); - if (Main.remixWorld) + if (NPC.Calamity().CurrentlyEnraged) { texture2D15 = TextureNight_Glow.Value; - timeBasedDrawColor = Color.Cyan; + timeBasedDrawColor = Color.Lerp(Color.White, Color.Cyan, 0.75f); + } + if (Main.zenithWorld) + { + texture2D15 = TextureNight_Glow.Value; + timeBasedDrawColor = Main.DiscoColor; } Color overrideColor = Color.Lerp(Color.White, Color.Violet, 0.5f); if (colorOverride != null) diff --git a/NPCs/Providence/Providence.cs b/NPCs/Providence/Providence.cs index 7f0bbfabc3..aeb2b7d136 100644 --- a/NPCs/Providence/Providence.cs +++ b/NPCs/Providence/Providence.cs @@ -366,7 +366,7 @@ namespace CalamityMod.NPCs.Providence colorShiftTimer = 0; } } - else if (!Main.IsItDay() || bossRush) //Normal Night time activity + else if ((!Main.dayTime && !Main.remixWorld) || bossRush) //Normal Night time activity NPC.localAI[1] = (float)BossMode.Night; else NPC.localAI[1] = (float)BossMode.Day; diff --git a/NPCs/SlimeGod/CrimulanPaladin.cs b/NPCs/SlimeGod/CrimulanPaladin.cs index 2efc4de6b7..8d7147dc4d 100644 --- a/NPCs/SlimeGod/CrimulanPaladin.cs +++ b/NPCs/SlimeGod/CrimulanPaladin.cs @@ -105,22 +105,25 @@ namespace CalamityMod.NPCs.SlimeGod Player player = Main.player[NPC.target]; - if (NPC.ai[0] != 3f && (player.dead || !player.active)) + if (NPC.ai[0] != 3f) { - NPC.TargetClosest(); - player = Main.player[NPC.target]; if (player.dead || !player.active) { - NPC.ai[0] = 3f; - NPC.ai[1] = 0f; - NPC.ai[2] = 0f; - NPC.ai[3] = 0f; - calamityGlobalNPC.newAI[0] = 0f; - NPC.netUpdate = true; + NPC.TargetClosest(); + player = Main.player[NPC.target]; + if (player.dead || !player.active) + { + NPC.ai[0] = 3f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + calamityGlobalNPC.newAI[0] = 0f; + NPC.netUpdate = true; + } } + else if (NPC.timeLeft < 1800) + NPC.timeLeft = 1800; } - else if (NPC.timeLeft < 1800) - NPC.timeLeft = 1800; if (lifeRatio <= 0.5f && Main.netMode != NetmodeID.MultiplayerClient && expertMode) { @@ -562,6 +565,8 @@ namespace CalamityMod.NPCs.SlimeGod NPC.netUpdate = true; } } + + // Despawn else if (NPC.ai[0] == 3f) { // Avoid cheap bullshit @@ -578,6 +583,7 @@ namespace CalamityMod.NPCs.SlimeGod NPC.velocity.X *= 0.98f; } + else if (NPC.ai[0] == 4f) { // Avoid cheap bullshit @@ -736,8 +742,6 @@ namespace CalamityMod.NPCs.SlimeGod return newColor * NPC.Opacity; } - public override bool CheckActive() => false; - public override void HitEffect(NPC.HitInfo hit) { Color dustColor = Color.Crimson; diff --git a/NPCs/SlimeGod/EbonianPaladin.cs b/NPCs/SlimeGod/EbonianPaladin.cs index f8c225f0cb..fe2ae3f8a7 100644 --- a/NPCs/SlimeGod/EbonianPaladin.cs +++ b/NPCs/SlimeGod/EbonianPaladin.cs @@ -102,22 +102,25 @@ namespace CalamityMod.NPCs.SlimeGod Player player = Main.player[NPC.target]; - if (NPC.ai[0] != 4f && (player.dead || !player.active)) + if (NPC.ai[0] != 4f) { - NPC.TargetClosest(); - player = Main.player[NPC.target]; if (player.dead || !player.active) { - NPC.ai[0] = 4f; - NPC.ai[1] = 0f; - NPC.ai[2] = 0f; - NPC.ai[3] = 0f; - calamityGlobalNPC.newAI[0] = 0f; - NPC.netUpdate = true; + NPC.TargetClosest(); + player = Main.player[NPC.target]; + if (player.dead || !player.active) + { + NPC.ai[0] = 4f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + calamityGlobalNPC.newAI[0] = 0f; + NPC.netUpdate = true; + } } + else if (NPC.timeLeft < 1800) + NPC.timeLeft = 1800; } - else if (NPC.timeLeft < 1800) - NPC.timeLeft = 1800; if (lifeRatio <= 0.5f && Main.netMode != NetmodeID.MultiplayerClient && expertMode) { @@ -606,6 +609,8 @@ namespace CalamityMod.NPCs.SlimeGod NPC.netUpdate = true; } } + + // Despawn else if (NPC.ai[0] == 4f) { // Avoid cheap bullshit @@ -622,6 +627,7 @@ namespace CalamityMod.NPCs.SlimeGod NPC.velocity.X *= 0.98f; } + else if (NPC.ai[0] == 5f) { // Set damage @@ -781,8 +787,6 @@ namespace CalamityMod.NPCs.SlimeGod return newColor * NPC.Opacity; } - public override bool CheckActive() => false; - public override void HitEffect(NPC.HitInfo hit) { Color dustColor = Color.Lavender; diff --git a/NPCs/SlimeGod/SlimeGodCore.cs b/NPCs/SlimeGod/SlimeGodCore.cs index c0bdd4c2f6..d2f4e0bb7c 100644 --- a/NPCs/SlimeGod/SlimeGodCore.cs +++ b/NPCs/SlimeGod/SlimeGodCore.cs @@ -100,6 +100,7 @@ namespace CalamityMod.NPCs.SlimeGod public override void SendExtraAI(BinaryWriter writer) { + writer.Write(slimesSpawned); writer.Write(buffedSlime); writer.Write(NPC.Opacity); for (int i = 0; i < 4; i++) @@ -108,6 +109,7 @@ namespace CalamityMod.NPCs.SlimeGod public override void ReceiveExtraAI(BinaryReader reader) { + slimesSpawned = reader.ReadBoolean(); buffedSlime = reader.ReadInt32(); NPC.Opacity = reader.ReadSingle(); for (int i = 0; i < 4; i++) @@ -135,11 +137,14 @@ namespace CalamityMod.NPCs.SlimeGod Player player = Main.player[NPC.target]; - if (Main.netMode != NetmodeID.MultiplayerClient && !slimesSpawned) + if (!slimesSpawned) { slimesSpawned = true; - NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, ModContent.NPCType()); - NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, ModContent.NPCType()); + if (Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, ModContent.NPCType()); + NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, ModContent.NPCType()); + } } // Enrage based on large slimes @@ -158,6 +163,9 @@ namespace CalamityMod.NPCs.SlimeGod calamityGlobalNPC.newAI[0] = Main.npc[CalamityGlobalNPC.slimeGodPurple].Center.X; calamityGlobalNPC.newAI[1] = Main.npc[CalamityGlobalNPC.slimeGodPurple].Center.Y; + // Despawn check + calamityGlobalNPC.newAI[3] = Main.npc[CalamityGlobalNPC.slimeGodPurple].ai[0] == 4f ? 1f : 0f; + purpleSlimeAlive = true; } } @@ -173,6 +181,9 @@ namespace CalamityMod.NPCs.SlimeGod NPC.ai[1] = Main.npc[CalamityGlobalNPC.slimeGodRed].Center.X; NPC.ai[2] = Main.npc[CalamityGlobalNPC.slimeGodRed].Center.Y; + + // Despawn check + calamityGlobalNPC.newAI[3] = Main.npc[CalamityGlobalNPC.slimeGodRed].ai[0] == 3f ? 1f : 0f; redSlimeAlive = true; } @@ -182,7 +193,7 @@ namespace CalamityMod.NPCs.SlimeGod bool phase2 = !purpleSlimeAlive || !redSlimeAlive; // Vanish phase - if (!purpleSlimeAlive && !redSlimeAlive) + if ((!purpleSlimeAlive && !redSlimeAlive) || calamityGlobalNPC.newAI[3] == 1f || NPC.ai[3] == 1f) { // Avoid cheap bullshit NPC.damage = 0; @@ -251,24 +262,42 @@ namespace CalamityMod.NPCs.SlimeGod Main.dust[slimyDust2].velocity *= 2f; } - // Let the player know that the Slime God isn't dead fr - if (!DownedBossSystem.downedSlimeGod) + if (calamityGlobalNPC.newAI[3] != 1f) { - string key = "Mods.CalamityMod.Status.Boss.SlimeGodRun"; - Color messageColor = Color.Magenta; + // Let the player know that the Slime God isn't dead fr + if (!DownedBossSystem.downedSlimeGod) + { + string key = "Mods.CalamityMod.Status.Boss.SlimeGodRun"; + Color messageColor = Color.Magenta; - CalamityUtils.DisplayLocalizedText(key, messageColor); + CalamityUtils.DisplayLocalizedText(key, messageColor); + } + + // Set Slime God to have interacted with all players + for (int i = Main.maxPlayers - 1; i >= 0; i--) + NPC.ApplyInteraction(i); + + NPC.active = false; + NPC.HitEffect(); + NPC.NPCLoot(); + NPC.netUpdate = true; } - - // Set Slime God to have interacted with all players - for (int i = Main.maxPlayers - 1; i >= 0; i--) + else { - NPC.ApplyInteraction(i); + for (int x = 0; x < Main.maxNPCs; x++) + { + if (Main.npc[x].type == ModContent.NPCType() || Main.npc[x].type == ModContent.NPCType() || + Main.npc[x].type == ModContent.NPCType() || Main.npc[x].type == ModContent.NPCType()) + { + Main.npc[x].active = false; + Main.npc[x].netUpdate = true; + } + } + + NPC.active = false; + NPC.HitEffect(); + NPC.netUpdate = true; } - NPC.active = false; - NPC.HitEffect(); - NPC.NPCLoot(); - NPC.netUpdate = true; } return; diff --git a/NPCs/SlimeGod/SplitCrimulanPaladin.cs b/NPCs/SlimeGod/SplitCrimulanPaladin.cs index d00c921ae9..a51706798a 100644 --- a/NPCs/SlimeGod/SplitCrimulanPaladin.cs +++ b/NPCs/SlimeGod/SplitCrimulanPaladin.cs @@ -120,21 +120,24 @@ namespace CalamityMod.NPCs.SlimeGod Player player = Main.player[NPC.target]; - if (NPC.ai[0] != 3f && (player.dead || !player.active)) + if (NPC.ai[0] != 3f) { - NPC.TargetClosest(); - player = Main.player[NPC.target]; if (player.dead || !player.active) { - NPC.ai[0] = 3f; - NPC.ai[1] = 0f; - NPC.ai[2] = 0f; - NPC.ai[3] = 0f; - NPC.netUpdate = true; + NPC.TargetClosest(); + player = Main.player[NPC.target]; + if (player.dead || !player.active) + { + NPC.ai[0] = 3f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + NPC.netUpdate = true; + } } + else if (NPC.timeLeft < 1800) + NPC.timeLeft = 1800; } - else if (NPC.timeLeft < 1800) - NPC.timeLeft = 1800; bool enraged = true; if (CalamityGlobalNPC.slimeGodPurple != -1) @@ -544,6 +547,8 @@ namespace CalamityMod.NPCs.SlimeGod NPC.netUpdate = true; } } + + // Despawn else if (NPC.ai[0] == 3f) { // Avoid cheap bullshit @@ -560,6 +565,7 @@ namespace CalamityMod.NPCs.SlimeGod NPC.velocity.X *= 0.98f; } + else if (NPC.ai[0] == 4f) { // Set damage @@ -730,8 +736,6 @@ namespace CalamityMod.NPCs.SlimeGod npcLoot.Add(ItemID.Gel, 1, 32, 48); } - public override bool CheckActive() => false; - public override void HitEffect(NPC.HitInfo hit) { Color dustColor = Color.Crimson; diff --git a/NPCs/SlimeGod/SplitEbonianPaladin.cs b/NPCs/SlimeGod/SplitEbonianPaladin.cs index 91036c6d16..fad784a39e 100644 --- a/NPCs/SlimeGod/SplitEbonianPaladin.cs +++ b/NPCs/SlimeGod/SplitEbonianPaladin.cs @@ -120,21 +120,24 @@ namespace CalamityMod.NPCs.SlimeGod Player player = Main.player[NPC.target]; - if (NPC.ai[0] != 4f && (player.dead || !player.active)) + if (NPC.ai[0] != 4f) { - NPC.TargetClosest(); - player = Main.player[NPC.target]; if (player.dead || !player.active) { - NPC.ai[0] = 4f; - NPC.ai[1] = 0f; - NPC.ai[2] = 0f; - NPC.ai[3] = 0f; - NPC.netUpdate = true; + NPC.TargetClosest(); + player = Main.player[NPC.target]; + if (player.dead || !player.active) + { + NPC.ai[0] = 4f; + NPC.ai[1] = 0f; + NPC.ai[2] = 0f; + NPC.ai[3] = 0f; + NPC.netUpdate = true; + } } + else if (NPC.timeLeft < 1800) + NPC.timeLeft = 1800; } - else if (NPC.timeLeft < 1800) - NPC.timeLeft = 1800; bool enraged = true; bool hyperMode = NPC.localAI[1] == 1f; @@ -591,6 +594,8 @@ namespace CalamityMod.NPCs.SlimeGod NPC.netUpdate = true; } } + + // Despawn else if (NPC.ai[0] == 4f) { // Avoid cheap bullshit @@ -607,6 +612,7 @@ namespace CalamityMod.NPCs.SlimeGod NPC.velocity.X *= 0.98f; } + else if (NPC.ai[0] == 5f) { // Set damage @@ -774,8 +780,6 @@ namespace CalamityMod.NPCs.SlimeGod npcLoot.Add(ItemID.Gel, 1, 32, 48); } - public override bool CheckActive() => false; - public override void HitEffect(NPC.HitInfo hit) { Color dustColor = Color.Lavender; diff --git a/NPCs/SunkenSea/GiantClam.cs b/NPCs/SunkenSea/GiantClam.cs index fec26d9caa..6e520e527b 100644 --- a/NPCs/SunkenSea/GiantClam.cs +++ b/NPCs/SunkenSea/GiantClam.cs @@ -150,6 +150,8 @@ namespace CalamityMod.NPCs.SunkenSea // Avoid cheap bullshit NPC.damage = 0; + NPC.defense = Main.hardMode ? 35 : 10; + NPC.ai[0] += 1f; hide = false; } diff --git a/NPCs/SunkenSea/SeaSerpent1.cs b/NPCs/SunkenSea/SeaSerpent1.cs index 7a678cddb8..2cb2cdab19 100644 --- a/NPCs/SunkenSea/SeaSerpent1.cs +++ b/NPCs/SunkenSea/SeaSerpent1.cs @@ -84,15 +84,14 @@ namespace CalamityMod.NPCs.SunkenSea } } - Lighting.AddLight(NPC.Center, (255 - NPC.alpha) * 0f / 255f, (255 - NPC.alpha) * 0.30f / 255f, (255 - NPC.alpha) * 0.30f / 255f); + Lighting.AddLight(NPC.Center, 0f, (255 - NPC.alpha) * 0.3f / 255f, (255 - NPC.alpha) * 0.3f / 255f); + if (NPC.ai[2] > 0f) - { NPC.realLife = (int)NPC.ai[2]; - } + if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead) - { NPC.TargetClosest(true); - } + if (Main.netMode != NetmodeID.MultiplayerClient) { if (!TailSpawned && NPC.ai[0] == 0f) @@ -102,21 +101,14 @@ namespace CalamityMod.NPCs.SunkenSea { int lol = 0; if (segment == 0 || segment == 1 || segment == 4 || segment == 5) - { lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType(), NPC.whoAmI); - } else if (segment == 2 || segment == 3 || segment == 6) - { lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType(), NPC.whoAmI); - } else if (segment == 7) - { lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType(), NPC.whoAmI); - } else if (segment == 8) - { lol = NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.position.X + (NPC.width / 2), (int)NPC.position.Y + (NPC.height / 2), ModContent.NPCType(), NPC.whoAmI); - } + Main.npc[lol].realLife = NPC.whoAmI; Main.npc[lol].ai[2] = (float)NPC.whoAmI; Main.npc[lol].ai[1] = (float)Previous; @@ -124,30 +116,30 @@ namespace CalamityMod.NPCs.SunkenSea NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, lol, 0f, 0f, 0f, 0); Previous = lol; } + TailSpawned = true; } } + if (NPC.velocity.X < 0f) - { NPC.spriteDirection = -1; - } else if (NPC.velocity.X > 0f) - { NPC.spriteDirection = 1; - } + if (Main.player[NPC.target].dead) - { NPC.TargetClosest(false); - } + NPC.alpha -= 42; if (NPC.alpha < 0) - { NPC.alpha = 0; - } + if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > 5600f) { - NPC.active = false; + NPC.TargetClosest(false); + if (Vector2.Distance(Main.player[NPC.target].Center, NPC.Center) > 5600f) + NPC.active = false; } + float currentSpeed = speed; float currentTurnSpeed = turnSpeed; Vector2 segmentPosition = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhuAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhuAI.cs index ebfd7f20ae..e8c7ecd7a2 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhuAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhuAI.cs @@ -29,10 +29,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - bool enrage = true; int targetTileX = (int)Main.player[npc.target].Center.X / 16; int targetTileY = (int)Main.player[npc.target].Center.Y / 16; @@ -517,7 +513,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[1] = 0f; npc.ai[2] = 0f; npc.ai[3] = 0f; - npc.TargetClosest(); npc.netUpdate = true; } } @@ -879,11 +874,15 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(); - float enrageScale = bossRush ? 1.5f : masterMode ? 0.5f : 0f; - if ((npc.position.Y / 16f) < Main.worldSurface || bossRush) + float enrageScaleMax = 2f; + float enrageScale = bossRush ? enrageScaleMax : masterMode ? 0.5f : 0f; + if ((npc.position.Y / 16f) < Main.worldSurface) enrageScale += 0.5f; - if (!Main.player[npc.target].ZoneCrimson || bossRush) - enrageScale += 2f; + if (!Main.player[npc.target].ZoneCrimson) + enrageScale += 1f; + + if (enrageScale > enrageScaleMax) + enrageScale = enrageScaleMax; bool brainIsNotTeleportingOrCharging = Main.npc[NPC.crimsonBoss].ai[0] == 0f || Main.npc[NPC.crimsonBoss].ai[0] == -1f || Main.npc[NPC.crimsonBoss].ai[0] == -6f; bool brainIsInPhase2 = Main.npc[NPC.crimsonBoss].ai[0] < 0f; @@ -906,7 +905,9 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses creeperRatio = creeperCount / (float)GetBrainOfCthuluCreepersCountRevDeath(); // Scale the aggressiveness of the charges with amount of Creepers remaining - float chargeAggressionScale = creeperRatio <= 0.1f ? 3.5f : creeperRatio <= 0.2f ? 2.5f : creeperRatio <= 0.4f ? 1.75f : creeperRatio <= 0.6f ? 1f : creeperRatio <= 0.8f ? 0.5f : 0f; + float chargeAggressionScale = creeperRatio <= 0.1f ? 1.75f : creeperRatio <= 0.2f ? 1.25f : creeperRatio <= 0.4f ? 0.875f : creeperRatio <= 0.6f ? 0.5f : creeperRatio <= 0.8f ? 0.25f : 0f; + if (enrageScale > 0f) + chargeAggressionScale *= 1f + enrageScale; if (death) chargeAggressionScale *= 1.25f; diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/CultistAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/CultistAI.cs index cc7f023757..c3fe7ce175 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/CultistAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/CultistAI.cs @@ -96,23 +96,15 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses idleTime = 20; } - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(false); - // Center and target Player player = Main.player[npc.target]; - if (npc.target < 0 || npc.target == Main.maxPlayers || player.dead || !player.active) + if (npc.target < 0 || npc.target == Main.maxPlayers || player.dead || !player.active || Vector2.Distance(player.Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance350Tiles) { npc.TargetClosest(false); player = Main.player[npc.target]; npc.netUpdate = true; } - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(player.Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(false); - // Enrage if (!Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height) || CalamityWorld.LegendaryMode) { @@ -157,6 +149,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[1] = 0f; npc.ai[3] += 1f; npc.velocity = Vector2.Zero; + npc.TargetClosest(false); npc.netUpdate = true; if (Main.netMode != NetmodeID.MultiplayerClient) @@ -170,7 +163,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } // Despawn - if (player.dead || Vector2.Distance(player.Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance350Tiles) + if (player.dead || !player.active || Vector2.Distance(player.Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance350Tiles) { npc.life = 0; npc.HitEffect(0, 10.0); @@ -803,6 +796,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[1] = 0f; npc.ai[3] += 1f; npc.velocity = Vector2.Zero; + npc.TargetClosest(false); npc.netUpdate = true; } } @@ -1309,6 +1303,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[1] = 0f; npc.ai[3] += 1f; npc.velocity = Vector2.Zero; + npc.TargetClosest(false); npc.netUpdate = true; List list = new List(); for (int i = 0; i < Main.maxNPCs; i++) @@ -2030,6 +2025,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[1] = 0f; npc.ai[3] += 1f; npc.velocity = Vector2.Zero; + npc.TargetClosest(false); npc.netUpdate = true; } } diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/DestroyerAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/DestroyerAI.cs index 7582745b63..1308fee41f 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/DestroyerAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/DestroyerAI.cs @@ -92,10 +92,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Return to ground phase, with less time spent in later phases if (calamityGlobalNPC.newAI[3] >= FlightPhaseResetGateValue) - { calamityGlobalNPC.newAI[3] = flightPhaseTimerSetValue; - npc.TargetClosest(); - } // Spawn DR check bool hasSpawnDR = calamityGlobalNPC.newAI[1] < DRIncreaseTime && calamityGlobalNPC.newAI[1] > 60f; @@ -124,10 +121,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses bool increaseSpeed = Vector2.Distance(player.Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles; bool increaseSpeedMore = Vector2.Distance(player.Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance350Tiles; - // Get a new target if current target is too far away - if (increaseSpeedMore && npc.type == NPCID.TheDestroyer) - npc.TargetClosest(); - float enrageScale = bossRush ? 1f : 0f; if (Main.IsItDay() || bossRush) { @@ -343,85 +336,88 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } - if (Main.netMode != NetmodeID.MultiplayerClient) + if (npc.type == NPCID.TheDestroyer) { - if (npc.type == NPCID.TheDestroyer) + // Spawn segments from head + if (npc.ai[0] == 0f) { - // Spawn segments from head - if (npc.ai[0] == 0f) + npc.ai[3] = npc.whoAmI; + npc.realLife = npc.whoAmI; + int index = npc.whoAmI; + for (int j = 0; j <= totalSegments; j++) { - npc.ai[3] = npc.whoAmI; - npc.realLife = npc.whoAmI; - int index = npc.whoAmI; - for (int j = 0; j <= totalSegments; j++) - { - int type = NPCID.TheDestroyerBody; - if (j == totalSegments) - type = NPCID.TheDestroyerTail; + int type = NPCID.TheDestroyerBody; + if (j == totalSegments) + type = NPCID.TheDestroyerTail; - int segment = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X), (int)(npc.position.Y + npc.height), type, npc.whoAmI); - Main.npc[segment].ai[3] = npc.whoAmI; - Main.npc[segment].realLife = npc.whoAmI; - Main.npc[segment].ai[1] = index; - Main.npc[index].ai[0] = segment; - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, segment); - index = segment; - } + int segment = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X), (int)(npc.position.Y + npc.height), type, npc.whoAmI); + Main.npc[segment].ai[3] = npc.whoAmI; + Main.npc[segment].realLife = npc.whoAmI; + Main.npc[segment].ai[1] = index; + Main.npc[index].ai[0] = segment; + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, segment); + index = segment; + } + } + + // Laser breath in Death Mode + if (spitLaserSpreads) + { + // Set laser color and type + if (calamityGlobalNPC.destroyerLaserColor == -1) + { + calamityGlobalNPC.destroyerLaserColor = phase3 ? 3 : phase2 ? 2 : 1; + npc.SyncDestroyerLaserColor(); } - // Laser breath in Death Mode - if (spitLaserSpreads) + float laserBreathGateValue = DeathModeLaserBreathGateValue; + if (calamityGlobalNPC.newAI[0] < laserBreathGateValue) + calamityGlobalNPC.newAI[0] += 1f; + + if (Main.netMode != NetmodeID.MultiplayerClient) { - // Set laser color and type - if (calamityGlobalNPC.destroyerLaserColor == -1) - { - calamityGlobalNPC.destroyerLaserColor = phase3 ? 3 : phase2 ? 2 : 1; - npc.SyncDestroyerLaserColor(); - } - - float laserBreathGateValue = DeathModeLaserBreathGateValue; - if (calamityGlobalNPC.newAI[0] < laserBreathGateValue) - calamityGlobalNPC.newAI[0] += 1f; - // Sync newAI every 20 frames for the new telegraph - if (calamityGlobalNPC.newAI[0] % 20f == 0f) + if (calamityGlobalNPC.newAI[0] % 20f == 10f) npc.SyncExtraAI(); + } - if ((player.Center - npc.Center).SafeNormalize(Vector2.UnitY).ToRotation().AngleTowards(npc.velocity.ToRotation(), MathHelper.PiOver4) == npc.velocity.ToRotation() && - calamityGlobalNPC.newAI[0] >= laserBreathGateValue && Vector2.Distance(npc.Center, player.Center) > 480f && - Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) + if ((player.Center - npc.Center).SafeNormalize(Vector2.UnitY).ToRotation().AngleTowards(npc.velocity.ToRotation(), MathHelper.PiOver4) == npc.velocity.ToRotation() && + calamityGlobalNPC.newAI[0] >= laserBreathGateValue && Vector2.Distance(npc.Center, player.Center) > 480f && + Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) + { + if (calamityGlobalNPC.newAI[0] % 30f == 0f) { - if (calamityGlobalNPC.newAI[0] % 30f == 0f) + float velocity = bossRush ? 6f : death ? 5.333f : 5f; + int type = ProjectileID.DeathLaser; + switch (calamityGlobalNPC.destroyerLaserColor) { - float velocity = bossRush ? 6f : death ? 5.333f : 5f; - int type = ProjectileID.DeathLaser; - switch (calamityGlobalNPC.destroyerLaserColor) - { - default: - case 0: - break; + default: + case 0: + break; - case 1: - type = ModContent.ProjectileType(); - break; + case 1: + type = ModContent.ProjectileType(); + break; - case 2: - type = ModContent.ProjectileType(); - break; - } - int damage = npc.GetProjectileDamage(type); + case 2: + type = ModContent.ProjectileType(); + break; + } + int damage = npc.GetProjectileDamage(type); - // Reduce mech boss projectile damage depending on the new ore progression changes - if (CalamityConfig.Instance.EarlyHardmodeProgressionRework && !BossRushEvent.BossRushActive) - { - double firstMechMultiplier = CalamityGlobalNPC.EarlyHardmodeProgressionReworkFirstMechStatMultiplier_Expert; - double secondMechMultiplier = CalamityGlobalNPC.EarlyHardmodeProgressionReworkSecondMechStatMultiplier_Expert; - if (!NPC.downedMechBossAny) - damage = (int)(damage * firstMechMultiplier); - else if ((!NPC.downedMechBoss1 && !NPC.downedMechBoss2) || (!NPC.downedMechBoss2 && !NPC.downedMechBoss3) || (!NPC.downedMechBoss3 && !NPC.downedMechBoss1)) - damage = (int)(damage * secondMechMultiplier); - } + // Reduce mech boss projectile damage depending on the new ore progression changes + if (CalamityConfig.Instance.EarlyHardmodeProgressionRework && !BossRushEvent.BossRushActive) + { + double firstMechMultiplier = CalamityGlobalNPC.EarlyHardmodeProgressionReworkFirstMechStatMultiplier_Expert; + double secondMechMultiplier = CalamityGlobalNPC.EarlyHardmodeProgressionReworkSecondMechStatMultiplier_Expert; + if (!NPC.downedMechBossAny) + damage = (int)(damage * firstMechMultiplier); + else if ((!NPC.downedMechBoss1 && !NPC.downedMechBoss2) || (!NPC.downedMechBoss2 && !NPC.downedMechBoss3) || (!NPC.downedMechBoss3 && !NPC.downedMechBoss1)) + damage = (int)(damage * secondMechMultiplier); + } + if (Main.netMode != NetmodeID.MultiplayerClient) + { Vector2 projectileVelocity = (player.Center - npc.Center).SafeNormalize(Vector2.UnitY) * velocity; int numProj = calamityGlobalNPC.newAI[0] % 60f == 0f ? (masterMode ? 9 : 7) : (masterMode ? 6 : 4); int spread = masterMode ? 38 : 26; @@ -433,111 +429,132 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses Main.projectile[proj].timeLeft = 1200; } } + } - calamityGlobalNPC.newAI[0] += 1f; - if (calamityGlobalNPC.newAI[0] > laserBreathGateValue + 60f) - { - calamityGlobalNPC.newAI[0] = 0f; - calamityGlobalNPC.destroyerLaserColor = -1; - npc.SyncDestroyerLaserColor(); - npc.SyncExtraAI(); - } + calamityGlobalNPC.newAI[0] += 1f; + if (calamityGlobalNPC.newAI[0] > laserBreathGateValue + 60f) + { + calamityGlobalNPC.newAI[0] = 0f; + calamityGlobalNPC.destroyerLaserColor = -1; + npc.SyncDestroyerLaserColor(); + npc.SyncExtraAI(); } } } + } - // Fire lasers - if (npc.type == NPCID.TheDestroyerBody) + // Fire lasers + if (npc.type == NPCID.TheDestroyerBody) + { + bool ableToFireLaser = calamityGlobalNPC.destroyerLaserColor != -1; + + // Set laser color and type + if (calamityGlobalNPC.destroyerLaserColor == -1 && !probeLaunched) { - bool ableToFireLaser = calamityGlobalNPC.destroyerLaserColor != -1; - - // Set laser color and type - if (calamityGlobalNPC.destroyerLaserColor == -1 && !probeLaunched) + if (Main.rand.NextBool(masterMode ? OneInXChanceToFireLaser / (phase5 ? 4 : phase4 ? 3 : 2) : OneInXChanceToFireLaser)) { - if (Main.rand.NextBool(masterMode ? OneInXChanceToFireLaser / (phase5 ? 4 : phase4 ? 3 : 2) : OneInXChanceToFireLaser)) + int random = phase3 ? 4 : phase2 ? 3 : 2; + switch (Main.rand.Next(random)) { - int random = phase3 ? 4 : phase2 ? 3 : 2; - switch (Main.rand.Next(random)) - { - case 0: - case 1: - calamityGlobalNPC.destroyerLaserColor = 0; - break; - case 2: - calamityGlobalNPC.destroyerLaserColor = 1; - break; - case 3: - calamityGlobalNPC.destroyerLaserColor = 2; - break; - } - - if (calamityGlobalNPC.newAI[2] > 0f || bossRush) + case 0: + case 1: + calamityGlobalNPC.destroyerLaserColor = 0; + break; + case 2: + calamityGlobalNPC.destroyerLaserColor = 1; + break; + case 3: calamityGlobalNPC.destroyerLaserColor = 2; - - npc.SyncDestroyerLaserColor(); + break; } - } - if (probeLaunched && ableToFireLaser) - { - calamityGlobalNPC.destroyerLaserColor = -1; + if (calamityGlobalNPC.newAI[2] > 0f || bossRush) + calamityGlobalNPC.destroyerLaserColor = 2; + npc.SyncDestroyerLaserColor(); } + } - // Laser rate of fire - float shootProjectileTime = death ? (masterMode ? (phase5 ? 120f : phase4 ? 150f : 180f) : 270f) : (masterMode ? (phase5 ? 150f : phase4 ? 210f : 270f) : 450f); - float bodySegmentTime = npc.ai[0] * (masterMode ? 20f : 30f); - float shootProjectileGateValue = bodySegmentTime + shootProjectileTime; - float laserTimerIncrement = (calamityGlobalNPC.newAI[0] > shootProjectileGateValue - LaserTelegraphTime) ? 1f : 2f; - if (ableToFireLaser) - calamityGlobalNPC.newAI[0] += laserTimerIncrement; + if (probeLaunched && ableToFireLaser) + { + calamityGlobalNPC.destroyerLaserColor = -1; + npc.SyncDestroyerLaserColor(); + } + // Laser rate of fire + float shootProjectileTime = death ? (masterMode ? (phase5 ? 120f : phase4 ? 150f : 180f) : 270f) : (masterMode ? (phase5 ? 150f : phase4 ? 210f : 270f) : 450f); + float bodySegmentTime = npc.ai[0] * (masterMode ? 20f : 30f); + float shootProjectileGateValue = bodySegmentTime + shootProjectileTime; + float laserTimerIncrement = (calamityGlobalNPC.newAI[0] > shootProjectileGateValue - LaserTelegraphTime) ? 1f : 2f; + if (ableToFireLaser) + calamityGlobalNPC.newAI[0] += laserTimerIncrement; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { // Sync newAI every 20 frames for the new telegraph - if (calamityGlobalNPC.newAI[0] % 20f == 0f && ableToFireLaser) + if (calamityGlobalNPC.newAI[0] % 20f == 10f && ableToFireLaser) npc.SyncExtraAI(); + } - Color telegraphColor = Color.Transparent; - switch (calamityGlobalNPC.destroyerLaserColor) + Color telegraphColor = Color.Transparent; + switch (calamityGlobalNPC.destroyerLaserColor) + { + case 0: + telegraphColor = Color.Red; + break; + case 1: + telegraphColor = Color.Green; + break; + case 2: + telegraphColor = Color.Cyan; + break; + } + + if (calamityGlobalNPC.newAI[0] == shootProjectileGateValue - LaserTelegraphTime) + { + Particle telegraph = new DestroyerReticleTelegraph( + npc, + telegraphColor, + 1.5f, + 0.15f, + (int)LaserTelegraphTime); + GeneralParticleHandler.SpawnParticle(telegraph); + } + + if (calamityGlobalNPC.newAI[0] == shootProjectileGateValue - SparkTelegraphTime) + { + Particle spark = new DestroyerSparkTelegraph( + npc, + telegraphColor * 2f, + Color.White, + 3f, + 30, + Main.rand.NextFloat(MathHelper.ToRadians(3f)) * Main.rand.NextBool().ToDirectionInt()); + GeneralParticleHandler.SpawnParticle(spark); + } + + // Shoot lasers + // Shoot nothing if probe has been launched + if (calamityGlobalNPC.newAI[0] >= shootProjectileGateValue && ableToFireLaser) + { + if (!masterMode) { - case 0: - telegraphColor = Color.Red; - break; - case 1: - telegraphColor = Color.Green; - break; - case 2: - telegraphColor = Color.Cyan; - break; + int numProbeSegments = 0; + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].active && Main.npc[i].type == npc.type && Main.npc[i].ai[2] == 0f) + numProbeSegments++; + } + float lerpAmount = MathHelper.Clamp(numProbeSegments / (float)totalSegments, 0f, 1f); + float laserShootTimeBonus = (int)MathHelper.Lerp(0f, (shootProjectileTime + bodySegmentTime * lerpAmount) - LaserTelegraphTime, 1f - lerpAmount); + calamityGlobalNPC.newAI[0] = laserShootTimeBonus; + npc.SyncExtraAI(); + npc.TargetClosest(); } - if (calamityGlobalNPC.newAI[0] == shootProjectileGateValue - LaserTelegraphTime) + if (Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) { - Particle telegraph = new DestroyerReticleTelegraph( - npc, - telegraphColor, - 1.5f, - 0.15f, - (int)LaserTelegraphTime); - GeneralParticleHandler.SpawnParticle(telegraph); - } - - if (calamityGlobalNPC.newAI[0] == shootProjectileGateValue - SparkTelegraphTime) - { - Particle spark = new DestroyerSparkTelegraph( - npc, - telegraphColor * 2f, - Color.White, - 3f, - 30, - Main.rand.NextFloat(MathHelper.ToRadians(3f)) * Main.rand.NextBool().ToDirectionInt()); - GeneralParticleHandler.SpawnParticle(spark); - } - - // Shoot lasers - // Shoot nothing if probe has been launched - if (calamityGlobalNPC.newAI[0] >= shootProjectileGateValue && ableToFireLaser) - { - if (!masterMode) + if (masterMode) { int numProbeSegments = 0; for (int i = 0; i < Main.maxNPCs; i++) @@ -552,80 +569,65 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.TargetClosest(); } - if (Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) + // Laser speed + float projectileSpeed = (masterMode ? 4.5f : 3.5f) + Main.rand.NextFloat() * 1.5f; + projectileSpeed += enrageScale; + + // Set projectile damage and type + int projectileType = ProjectileID.DeathLaser; + switch (calamityGlobalNPC.destroyerLaserColor) { - if (masterMode) - { - int numProbeSegments = 0; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].active && Main.npc[i].type == npc.type && Main.npc[i].ai[2] == 0f) - numProbeSegments++; - } - float lerpAmount = MathHelper.Clamp(numProbeSegments / (float)totalSegments, 0f, 1f); - float laserShootTimeBonus = (int)MathHelper.Lerp(0f, (shootProjectileTime + bodySegmentTime * lerpAmount) - LaserTelegraphTime, 1f - lerpAmount); - calamityGlobalNPC.newAI[0] = laserShootTimeBonus; - npc.SyncExtraAI(); - npc.TargetClosest(); - } + default: + case 0: + break; - // Laser speed - float projectileSpeed = (masterMode ? 4.5f : 3.5f) + Main.rand.NextFloat() * 1.5f; - projectileSpeed += enrageScale; + case 1: + projectileType = ModContent.ProjectileType(); + break; - // Set projectile damage and type - int projectileType = ProjectileID.DeathLaser; - switch (calamityGlobalNPC.destroyerLaserColor) - { - default: - case 0: - break; - - case 1: - projectileType = ModContent.ProjectileType(); - break; - - case 2: - projectileType = ModContent.ProjectileType(); - break; - } - - // Get target vector - Vector2 projectileVelocity = (player.Center - npc.Center).SafeNormalize(Vector2.UnitY) * projectileSpeed; - Vector2 projectileSpawn = npc.Center + projectileVelocity.SafeNormalize(Vector2.UnitY) * 100f; - - // Shoot projectile - int damage = npc.GetProjectileDamage(projectileType); - - // Reduce mech boss projectile damage depending on the new ore progression changes - if (CalamityConfig.Instance.EarlyHardmodeProgressionRework && !BossRushEvent.BossRushActive) - { - double firstMechMultiplier = CalamityGlobalNPC.EarlyHardmodeProgressionReworkFirstMechStatMultiplier_Expert; - double secondMechMultiplier = CalamityGlobalNPC.EarlyHardmodeProgressionReworkSecondMechStatMultiplier_Expert; - if (!NPC.downedMechBossAny) - damage = (int)(damage * firstMechMultiplier); - else if ((!NPC.downedMechBoss1 && !NPC.downedMechBoss2) || (!NPC.downedMechBoss2 && !NPC.downedMechBoss3) || (!NPC.downedMechBoss3 && !NPC.downedMechBoss1)) - damage = (int)(damage * secondMechMultiplier); - } - - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), projectileSpawn, projectileVelocity, projectileType, damage, 0f, Main.myPlayer, 1f, 0f); - Main.projectile[proj].timeLeft = 1200; - - npc.netUpdate = true; - - if (masterMode) - { - calamityGlobalNPC.destroyerLaserColor = -1; - npc.SyncDestroyerLaserColor(); - } + case 2: + projectileType = ModContent.ProjectileType(); + break; } - if (!masterMode) + // Get target vector + Vector2 projectileVelocity = (player.Center - npc.Center).SafeNormalize(Vector2.UnitY) * projectileSpeed; + Vector2 projectileSpawn = npc.Center + projectileVelocity.SafeNormalize(Vector2.UnitY) * 100f; + + // Shoot projectile + int damage = npc.GetProjectileDamage(projectileType); + + // Reduce mech boss projectile damage depending on the new ore progression changes + if (CalamityConfig.Instance.EarlyHardmodeProgressionRework && !BossRushEvent.BossRushActive) + { + double firstMechMultiplier = CalamityGlobalNPC.EarlyHardmodeProgressionReworkFirstMechStatMultiplier_Expert; + double secondMechMultiplier = CalamityGlobalNPC.EarlyHardmodeProgressionReworkSecondMechStatMultiplier_Expert; + if (!NPC.downedMechBossAny) + damage = (int)(damage * firstMechMultiplier); + else if ((!NPC.downedMechBoss1 && !NPC.downedMechBoss2) || (!NPC.downedMechBoss2 && !NPC.downedMechBoss3) || (!NPC.downedMechBoss3 && !NPC.downedMechBoss1)) + damage = (int)(damage * secondMechMultiplier); + } + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), projectileSpawn, projectileVelocity, projectileType, damage, 0f, Main.myPlayer, 1f, 0f); + Main.projectile[proj].timeLeft = 1200; + } + + npc.netUpdate = true; + + if (masterMode) { calamityGlobalNPC.destroyerLaserColor = -1; npc.SyncDestroyerLaserColor(); } } + + if (!masterMode) + { + calamityGlobalNPC.destroyerLaserColor = -1; + npc.SyncDestroyerLaserColor(); + } } } @@ -714,82 +716,67 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.type != NPCID.TheDestroyerBody || !probeLaunched) { Vector3 lightColor = Color.Red.ToVector3(); - int x = (int)((npc.position.X - 8f) / 16f); - int x2 = (int)((npc.position.X + npc.width + 8f) / 16f); - int y = (int)((npc.position.Y - 8f) / 16f); - int y2 = (int)((npc.position.Y + npc.height + 8f) / 16f); - for (int l = x; l <= x2; l++) + + // Light colors + Vector3 groundColor = new Vector3(0.3f, 0.1f, 0.05f); + Vector3 flightColor = new Vector3(0.05f, 0.1f, 0.3f); + Vector3 segmentColor = Vector3.Lerp(groundColor, flightColor, phaseTransitionColorAmount); + Vector3 telegraphColor = groundColor; + + // Telegraph for the laser breath and body lasers + float telegraphProgress = 0f; + if (calamityGlobalNPC.destroyerLaserColor != -1) { - for (int m = y; m <= y2; m++) + if (npc.type == NPCID.TheDestroyer && spitLaserSpreads) { - if (Lighting.Brightness(l, m) == 0f) - lightColor = Color.Black.ToVector3(); + float telegraphGateValue = DeathModeLaserBreathGateValue - LaserTelegraphTime; + if (calamityGlobalNPC.newAI[0] > telegraphGateValue) + { + switch (calamityGlobalNPC.destroyerLaserColor) + { + default: + case 0: + break; + + case 1: + telegraphColor = new Vector3(0.1f, 0.3f, 0.05f); + break; + + case 2: + telegraphColor = new Vector3(0.05f, 0.2f, 0.2f); + break; + } + telegraphProgress = MathHelper.Clamp((calamityGlobalNPC.newAI[0] - telegraphGateValue) / LaserTelegraphTime, 0f, 1f); + } + } + else if (npc.type == NPCID.TheDestroyerBody) + { + float shootProjectileTime = (CalamityWorld.death || BossRushEvent.BossRushActive) ? 270f : 450f; + float bodySegmentTime = npc.ai[0] * 30f; + float shootProjectileGateValue = bodySegmentTime + shootProjectileTime; + float telegraphGateValue = shootProjectileGateValue - LaserTelegraphTime; + if (calamityGlobalNPC.newAI[0] > telegraphGateValue) + { + switch (calamityGlobalNPC.destroyerLaserColor) + { + default: + case 0: + break; + + case 1: + telegraphColor = new Vector3(0.1f, 0.3f, 0.05f); + break; + + case 2: + telegraphColor = new Vector3(0.05f, 0.2f, 0.2f); + break; + } + telegraphProgress = MathHelper.Clamp((calamityGlobalNPC.newAI[0] - telegraphGateValue) / LaserTelegraphTime, 0f, 1f); + } } } - if (lightColor != Color.Black.ToVector3()) - { - // Light colors - Vector3 groundColor = new Vector3(0.3f, 0.1f, 0.05f); - Vector3 flightColor = new Vector3(0.05f, 0.1f, 0.3f); - Vector3 segmentColor = Vector3.Lerp(groundColor, flightColor, phaseTransitionColorAmount); - Vector3 telegraphColor = groundColor; - - // Telegraph for the laser breath and body lasers - float telegraphProgress = 0f; - if (calamityGlobalNPC.destroyerLaserColor != -1) - { - if (npc.type == NPCID.TheDestroyer && spitLaserSpreads) - { - float telegraphGateValue = DeathModeLaserBreathGateValue - LaserTelegraphTime; - if (calamityGlobalNPC.newAI[0] > telegraphGateValue) - { - switch (calamityGlobalNPC.destroyerLaserColor) - { - default: - case 0: - break; - - case 1: - telegraphColor = new Vector3(0.1f, 0.3f, 0.05f); - break; - - case 2: - telegraphColor = new Vector3(0.05f, 0.2f, 0.2f); - break; - } - telegraphProgress = MathHelper.Clamp((calamityGlobalNPC.newAI[0] - telegraphGateValue) / LaserTelegraphTime, 0f, 1f); - } - } - else if (npc.type == NPCID.TheDestroyerBody) - { - float shootProjectileTime = (CalamityWorld.death || BossRushEvent.BossRushActive) ? 270f : 450f; - float bodySegmentTime = npc.ai[0] * 30f; - float shootProjectileGateValue = bodySegmentTime + shootProjectileTime; - float telegraphGateValue = shootProjectileGateValue - LaserTelegraphTime; - if (calamityGlobalNPC.newAI[0] > telegraphGateValue) - { - switch (calamityGlobalNPC.destroyerLaserColor) - { - default: - case 0: - break; - - case 1: - telegraphColor = new Vector3(0.1f, 0.3f, 0.05f); - break; - - case 2: - telegraphColor = new Vector3(0.05f, 0.2f, 0.2f); - break; - } - telegraphProgress = MathHelper.Clamp((calamityGlobalNPC.newAI[0] - telegraphGateValue) / LaserTelegraphTime, 0f, 1f); - } - } - } - - Lighting.AddLight(npc.Center, Vector3.Lerp(segmentColor, telegraphColor * 2f, telegraphProgress)); - } + Lighting.AddLight(npc.Center, Vector3.Lerp(segmentColor, telegraphColor * 2f, telegraphProgress)); } // Despawn @@ -1150,7 +1137,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.ai[3] > 0f) npc.realLife = (int)npc.ai[3]; - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead) + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(); if (npc.type >= NPCID.TheDestroyer && npc.type <= NPCID.TheDestroyerTail) @@ -1240,9 +1227,12 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (ableToFireLaser) npc.localAI[0] += laserTimerIncrement; - // Sync newAI every 20 frames for the new telegraph - if (npc.localAI[0] % 20f == 0f && ableToFireLaser) - npc.SyncVanillaLocalAI(); + if (Main.netMode != NetmodeID.MultiplayerClient) + { + // Sync newAI every 20 frames for the new telegraph + if (npc.localAI[0] % 20f == 10f && ableToFireLaser) + npc.SyncVanillaLocalAI(); + } Color telegraphColor = Color.Transparent; switch (npc.Calamity().destroyerLaserColor) @@ -1403,43 +1393,28 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.type != NPCID.TheDestroyerBody || npc.ai[2] != 1f) { Vector3 lightColor = Color.Red.ToVector3(); - int x = (int)((npc.position.X - 8f) / 16f); - int x2 = (int)((npc.position.X + npc.width + 8f) / 16f); - int y = (int)((npc.position.Y - 8f) / 16f); - int y2 = (int)((npc.position.Y + npc.height + 8f) / 16f); - for (int l = x; l <= x2; l++) + + // Light colors + Vector3 groundColor = new Vector3(0.3f, 0.1f, 0.05f); + Vector3 segmentColor = groundColor; + Vector3 telegraphColor = groundColor; + + // Telegraph for the laser breath and body lasers + float telegraphProgress = 0f; + if (npc.Calamity().destroyerLaserColor != -1) { - for (int m = y; m <= y2; m++) + if (npc.type == NPCID.TheDestroyerBody) { - if (Lighting.Brightness(l, m) == 0f) - lightColor = Color.Black.ToVector3(); + float shootProjectileTime = Main.masterMode ? 500f : Main.expertMode ? 700f : 900f; + float bodySegmentTime = npc.ai[0] * 30f; + float shootProjectileGateValue = bodySegmentTime + shootProjectileTime; + float telegraphGateValue = shootProjectileGateValue - LaserTelegraphTime; + if (npc.localAI[0] > telegraphGateValue) + telegraphProgress = MathHelper.Clamp((npc.localAI[0] - telegraphGateValue) / LaserTelegraphTime, 0f, 1f); } } - if (lightColor != Color.Black.ToVector3()) - { - // Light colors - Vector3 groundColor = new Vector3(0.3f, 0.1f, 0.05f); - Vector3 segmentColor = groundColor; - Vector3 telegraphColor = groundColor; - - // Telegraph for the laser breath and body lasers - float telegraphProgress = 0f; - if (npc.Calamity().destroyerLaserColor != -1) - { - if (npc.type == NPCID.TheDestroyerBody) - { - float shootProjectileTime = Main.masterMode ? 500f : Main.expertMode ? 700f : 900f; - float bodySegmentTime = npc.ai[0] * 30f; - float shootProjectileGateValue = bodySegmentTime + shootProjectileTime; - float telegraphGateValue = shootProjectileGateValue - LaserTelegraphTime; - if (npc.localAI[0] > telegraphGateValue) - telegraphProgress = MathHelper.Clamp((npc.localAI[0] - telegraphGateValue) / LaserTelegraphTime, 0f, 1f); - } - } - - Lighting.AddLight(npc.Center, Vector3.Lerp(segmentColor, telegraphColor * 2f, telegraphProgress)); - } + Lighting.AddLight(npc.Center, Vector3.Lerp(segmentColor, telegraphColor * 2f, telegraphProgress)); } npc.localAI[1] = 1f; @@ -1564,7 +1539,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { if (!flag2) { - npc.TargetClosest(); npc.velocity.Y += 0.15f; if (Main.masterMode && npc.velocity.Y > 0f) npc.velocity.Y += 0.05f; diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/DukeFishronAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/DukeFishronAI.cs index b351e11655..c50a12c01b 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/DukeFishronAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/DukeFishronAI.cs @@ -121,22 +121,16 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses Player player = Main.player[npc.target]; // Get target - if (npc.target < 0 || npc.target == Main.maxPlayers || player.dead || !player.active) + if (npc.target < 0 || npc.target == Main.maxPlayers || player.dead || !player.active || Vector2.Distance(player.Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance350Tiles) { npc.TargetClosest(); player = Main.player[npc.target]; npc.netUpdate = true; } - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(player.Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - // Despawn if (player.dead || Vector2.Distance(player.Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance350Tiles) { - npc.TargetClosest(); - npc.velocity.Y -= 0.4f; if (npc.timeLeft > 10) @@ -477,7 +471,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[1] = 0f; npc.ai[2] = 0f; npc.ai[3] += 2f; - npc.TargetClosest(); npc.netUpdate = true; } } @@ -526,7 +519,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[0] = 0f; npc.ai[1] = 0f; npc.ai[2] = 0f; - npc.TargetClosest(); npc.netUpdate = true; } } @@ -566,7 +558,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[0] = 0f; npc.ai[1] = 0f; npc.ai[2] = 0f; - npc.TargetClosest(); npc.netUpdate = true; } } @@ -592,7 +583,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[1] = 0f; npc.ai[2] = 0f; npc.ai[3] = 0f; - npc.TargetClosest(); npc.netUpdate = true; } } @@ -751,7 +741,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[1] = 0f; npc.ai[2] = 0f; npc.ai[3] += 2f; - npc.TargetClosest(); npc.netUpdate = true; } } @@ -797,7 +786,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[0] = 5f; npc.ai[1] = 0f; npc.ai[2] = 0f; - npc.TargetClosest(); npc.netUpdate = true; } } @@ -825,7 +813,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[0] = 5f; npc.ai[1] = 0f; npc.ai[2] = 0f; - npc.TargetClosest(); npc.netUpdate = true; } } @@ -871,7 +858,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[1] = 0f; npc.ai[2] = 0f; npc.ai[3] = 0f; - npc.TargetClosest(); npc.netUpdate = true; } } @@ -1062,7 +1048,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (!phase4 || !death) npc.ai[3] += 1f; - npc.TargetClosest(); npc.netUpdate = true; } } @@ -1163,7 +1148,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses Vector2 velocityVector = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY); float inertia = 30f; - float velocity = 25f; + float velocity = 24f; npc.velocity = (npc.velocity * inertia + velocityVector * velocity) / (inertia + 1f); npc.scale = npc.ai[3]; diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/EaterOfWorldsAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/EaterOfWorldsAI.cs index 22922a5ce6..7e10b43aef 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/EaterOfWorldsAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/EaterOfWorldsAI.cs @@ -37,10 +37,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles && npc.type == NPCID.EaterofWorldsHead) - npc.TargetClosest(); - bool enrage = true; int targetTileX = (int)Main.player[npc.target].Center.X / 16; int targetTileY = (int)Main.player[npc.target].Center.Y / 16; @@ -785,7 +781,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.realLife = -1; - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead) + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(); if (Main.player[npc.target].dead) @@ -998,7 +994,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { if (!flag2) { - npc.TargetClosest(); npc.velocity.Y += 0.11f; if (Main.masterMode && npc.velocity.Y > 0f) npc.velocity.Y += 0.07f; diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/EyeOfCthulhuAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/EyeOfCthulhuAI.cs index 8bf28b1f87..3c41eb2737 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/EyeOfCthulhuAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/EyeOfCthulhuAI.cs @@ -55,10 +55,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - bool dead = Main.player[npc.target].dead; float targetXDistance = npc.Center.X - Main.player[npc.target].position.X - (Main.player[npc.target].width / 2); float targetYDistance = npc.position.Y + npc.height - 59f - Main.player[npc.target].position.Y - (Main.player[npc.target].height / 2); @@ -277,7 +273,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { npc.ai[3] += 1f; npc.ai[2] = 0f; - npc.TargetClosest(); npc.rotation = eyeRotation; float numCharges = death ? 4f : 3f; @@ -486,13 +481,14 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (Main.netMode != NetmodeID.MultiplayerClient) { int type = ProjectileID.BloodNautilusShot; + int damage = npc.GetProjectileDamage(type); int numProj = masterMode ? Main.rand.Next(4, 6) : 3; int spread = masterMode ? numProj * 3 : 10; float rotation = MathHelper.ToRadians(spread); for (int i = 0; i < numProj; i++) { Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * ProjectileOffset, perturbedSpeed, type, 15, 0f, Main.myPlayer); + int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * ProjectileOffset, perturbedSpeed, type, damage, 0f, Main.myPlayer); Main.projectile[proj].timeLeft = 600; } } @@ -503,7 +499,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[1] = 1f; npc.ai[2] = 0f; npc.ai[3] = 0f; - npc.TargetClosest(); npc.netUpdate = true; } } @@ -570,7 +565,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { npc.ai[3] += 1f; npc.ai[2] = 0f; - npc.TargetClosest(); npc.rotation = eyeRotation; float numCharges = death ? 4f : 3f; @@ -598,7 +592,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Deal less damage overall while not charging npc.damage = reducedSetDamage; - npc.TargetClosest(); npc.ai[1] = 0f; npc.ai[2] = 0f; npc.ai[3] = 0f; @@ -744,6 +737,16 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float accelerationBoost = death ? 0.425f * (phase3LifeRatio - lifeRatio) : 0.125f * (phase3LifeRatio - lifeRatio); float hoverSpeed = 8f + speedBoost; float hoverAcceleration = 0.25f + accelerationBoost; + + bool horizontalCharge = calamityGlobalNPC.newAI[0] == 1f || calamityGlobalNPC.newAI[0] == 3f; + float timeGateValue = horizontalCharge ? (100f - (death ? 80f * (phase3LifeRatio - lifeRatio) : 0f)) : (85f - (death ? 70f * (phase3LifeRatio - lifeRatio) : 0f)); + if (npc.ai[2] > timeGateValue) + { + float velocityScalar = npc.ai[2] - timeGateValue; + hoverSpeed += velocityScalar * 0.05f; + hoverAcceleration += velocityScalar * 0.0025f; + } + hoverSpeed += enrageScale * 4f; hoverAcceleration += enrageScale * 0.125f; @@ -752,7 +755,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float lineUpChargeTargetY = Main.player[npc.target].Center.Y + offset - eyeLineUpChargeDirection.Y; Vector2 hoverDestination = Main.player[npc.target].Center + Vector2.UnitY * offset; - bool horizontalCharge = calamityGlobalNPC.newAI[0] == 1f || calamityGlobalNPC.newAI[0] == 3f; if (horizontalCharge) { float horizontalChargeOffset = death ? 450f : 500f; @@ -765,7 +767,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses Vector2 idealHoverVelocity = npc.SafeDirectionTo(hoverDestination) * hoverSpeed; npc.SimpleFlyMovement(idealHoverVelocity, hoverAcceleration); - float timeGateValue = horizontalCharge ? (100f - (death ? 80f * (phase3LifeRatio - lifeRatio) : 0f)) : (85f - (death ? 70f * (phase3LifeRatio - lifeRatio) : 0f)); float servantSpawnGateValue = horizontalCharge ? (death ? 23f : 35f) : (death ? 17f : 27f); float maxServantSpawnsPerAttack = 2f; @@ -845,7 +846,8 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } - if (npc.ai[2] >= timeGateValue) + float requiredDistanceForHorizontalCharge = 160f; + if (npc.ai[2] >= timeGateValue && (npc.Distance(hoverDestination) < requiredDistanceForHorizontalCharge || !horizontalCharge)) { switch ((int)calamityGlobalNPC.newAI[0]) { @@ -874,7 +876,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses break; } - npc.TargetClosest(); calamityGlobalNPC.newAI[0] += ((masterMode && calamityGlobalNPC.newAI[0] % 2f != 0f) ? Main.rand.Next(2) + 1f : 1f); if (calamityGlobalNPC.newAI[0] > 3f) calamityGlobalNPC.newAI[0] = masterMode ? Main.rand.Next(2) : 0f; @@ -1114,7 +1115,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[1] = 1f; npc.ai[2] = 0f; npc.ai[3] = 0f; - npc.target = Main.maxPlayers; + npc.TargetClosest(); npc.netUpdate = true; } else if ((npc.position.Y + (float)npc.height < Main.player[npc.target].position.Y && num15 < 500f) || (Main.expertMode && num15 < (Main.masterMode ? 750f : 500f))) @@ -1233,7 +1234,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { npc.ai[3] += 1f; npc.ai[2] = 0f; - npc.target = Main.maxPlayers; npc.rotation = num7; if (npc.ai[3] >= (Main.masterMode ? 4f : 3f)) { @@ -1263,6 +1263,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[1] = 0f; npc.ai[2] = 0f; npc.ai[3] = 0f; + npc.TargetClosest(); npc.netUpdate = true; if (npc.netSpam > 10) npc.netSpam = 10; @@ -1464,13 +1465,11 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (Main.expertMode && (double)npc.life < (double)npc.lifeMax * (Main.masterMode ? 0.45 : 0.35)) npc.ai[1] = 3f; - npc.target = Main.maxPlayers; npc.netUpdate = true; } if (Main.expertMode && flag3) { - npc.TargetClosest(); npc.netUpdate = true; npc.ai[1] = 3f; npc.ai[2] = 0f; @@ -1542,7 +1541,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { npc.ai[3] += 1f; npc.ai[2] = 0f; - npc.target = Main.maxPlayers; npc.rotation = num7; if (npc.ai[3] >= 3f) { @@ -1572,7 +1570,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Deal less damage while not charging npc.damage = reducedSetDamage; - npc.TargetClosest(); npc.ai[1] = 0f; npc.ai[2] = 0f; npc.ai[3] = 0f; @@ -1582,7 +1579,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } else if (Main.netMode != NetmodeID.MultiplayerClient) { - npc.TargetClosest(); float num50 = Main.masterMode ? 24f : 20f; Vector2 vector10 = npc.Center; float num51 = Main.player[npc.target].Center.X - vector10.X; @@ -1775,7 +1771,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[2] += 1f; if (npc.ai[2] >= (Main.masterMode ? 40f : 70f)) { - npc.TargetClosest(); npc.ai[1] = 3f; npc.ai[2] = -1f; npc.ai[3] = Main.rand.Next(-3, 1); diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/GolemAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/GolemAI.cs index df15000bff..4ade8b50a9 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/GolemAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/GolemAI.cs @@ -43,14 +43,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X - 3, (int)npc.Center.Y - 57, NPCID.GolemHead); } - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) - npc.TargetClosest(); - - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - // Despawn if (npc.target >= 0 && Main.player[npc.target].dead) { @@ -265,7 +257,8 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses else if (npc.ai[1] == -1f) { // Set jump velocity - npc.TargetClosest(); + if (!headAlive) + npc.TargetClosest(); // Set damage npc.damage = npc.defDamage; @@ -412,8 +405,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Avoid cheap bullshit npc.damage = 0; - npc.TargetClosest(); - // Play sound SoundEngine.PlaySound(SoundID.Item14, npc.Center); @@ -602,6 +593,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.velocity.Y = maxFallSpeed; } + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); + // Despawn if (Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) + Math.Abs(npc.Center.Y - Main.player[npc.target].Center.Y) > despawnDistance) { @@ -705,8 +700,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float fistPunchGateValue = masterMode ? 120f : 40f; if (npc.ai[1] >= fistPunchGateValue) { - npc.TargetClosest(); - if (canPunch) { npc.ai[1] = 0f; @@ -950,10 +943,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - // Die if body is gone if (NPC.golemBoss < 0) { @@ -1021,8 +1010,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[1] >= shootFireballGateValue) { - npc.TargetClosest(); - npc.ai[1] = 0f; Vector2 headCent = new Vector2(npc.Center.X, npc.Center.Y + 10f * npc.scale); @@ -1076,8 +1063,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[1] >= shootFireballGateValue) { - npc.TargetClosest(); - npc.ai[1] = 0f; float fireballSpeedFistsDed = turboEnrage ? 32f : enrage ? 24f : 12f; @@ -1111,8 +1096,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.ai[2] >= 300f) { - npc.TargetClosest(); - npc.ai[2] = 0f; int projType = ProjectileID.EyeBeam; @@ -1199,10 +1182,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - // Die if body is gone if (NPC.golemBoss < 0) { @@ -1393,8 +1372,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[1] >= shootFireballGateValue) { - npc.TargetClosest(); - npc.ai[1] = 0f; Vector2 freeHeadCenter = new Vector2(npc.Center.X, npc.Center.Y + 20f * npc.scale); @@ -1434,8 +1411,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float laserGateValue = 300f - (death ? 240f * (1f - combinedLifeRatio) : 180f * (1f - combinedLifeRatio)); if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] >= laserGateValue) { - npc.TargetClosest(); - npc.ai[2] = 0f; int numLasers = 2; @@ -1676,7 +1651,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.damage = npc.defDamage; npc.noTileCollide = true; - npc.TargetClosest(); + + if (!flag) + npc.TargetClosest(); + npc.velocity.X = 4 * npc.direction; if (npc.life < npc.lifeMax) { @@ -1718,7 +1696,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Set damage npc.damage = npc.defDamage; - npc.TargetClosest(); if (npc.position.X < Main.player[npc.target].position.X && npc.position.X + (float)npc.width > Main.player[npc.target].position.X + (float)Main.player[npc.target].width) { npc.velocity.X *= 0.9f; @@ -1752,7 +1729,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } - if (npc.target <= 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead) + if (npc.target <= 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(); int num8 = 3000; @@ -1776,6 +1753,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (Main.getGoodWorld) enrageScale += 3f; + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); + if ((!Main.player[npc.target].ZoneLihzhardTemple && !Main.player[npc.target].ZoneJungle) || (double)Main.player[npc.target].Center.Y < Main.worldSurface * 16.0) enrageScale *= 2f; @@ -1843,7 +1824,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.ai[1] >= 60f) { - npc.TargetClosest(); if ((npc.type == NPCID.GolemFistLeft && npc.Center.X + 100f > Main.player[npc.target].Center.X) || (npc.type == NPCID.GolemFistRight && npc.Center.X - 100f < Main.player[npc.target].Center.X)) { npc.ai[1] = 0f; @@ -2044,6 +2024,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (Main.getGoodWorld) enrageScale += 3f; + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); + if ((!Main.player[npc.target].ZoneLihzhardTemple && !Main.player[npc.target].ZoneJungle) || (double)Main.player[npc.target].Center.Y < Main.worldSurface * 16.0) enrageScale *= 2f; @@ -2103,7 +2087,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.ai[1] >= (float)num711) { - npc.TargetClosest(); npc.ai[1] = 0f; Vector2 vector90 = new Vector2(npc.Center.X, npc.Center.Y + 10f * npc.scale); float num712 = 8f; @@ -2122,7 +2105,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } else if (npc.ai[0] == 1f) { - npc.TargetClosest(); Vector2 vector91 = new Vector2(npc.Center.X, npc.Center.Y + 10f * npc.scale); if (Main.player[npc.target].Center.X < npc.Center.X - (float)npc.width) { @@ -2153,7 +2135,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.ai[1] >= (float)num720) { - npc.TargetClosest(); npc.ai[1] = 0f; float num721 = 8f; float num722 = Main.player[npc.target].Center.X - vector91.X; @@ -2257,6 +2238,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (Main.getGoodWorld) enrageScale += 3f; + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); + if ((!Main.player[npc.target].ZoneLihzhardTemple && !Main.player[npc.target].ZoneJungle) || (double)Main.player[npc.target].Center.Y < Main.worldSurface * 16.0) enrageScale *= 2f; @@ -2276,7 +2261,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses return false; } - npc.TargetClosest(); float num742 = 7f; float num743 = 0.05f; Vector2 vector92 = npc.Center; @@ -2337,7 +2321,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.ai[1] >= (float)num748) { - npc.TargetClosest(); npc.ai[1] = 0f; Vector2 vector93 = new Vector2(npc.Center.X, npc.Center.Y + 20f * npc.scale); float num749 = 8f; diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/KingSlimeAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/KingSlimeAI.cs index 54060f5524..3e40e48be0 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/KingSlimeAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/KingSlimeAI.cs @@ -39,30 +39,38 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - // Phases based on life percentage // Higher velocity jumps phase bool phase2 = lifeRatio < 0.75f; - // Spawn Crystal phase + // Spawn Emerald Crystal phase + bool spawnGreenCrystal = lifeRatio < 0.7f; + + // Spawn Ruby Crystal phase bool phase3 = lifeRatio < 0.5f; + // Spawn Sapphire Crystal phase + bool spawnBlueCrystal = lifeRatio < 0.3f; + // Check if the crystals are alive bool crystalAlive = true; bool blueCrystalAlive = false; bool greenCrystalAlive = true; - if (phase3) + + if (spawnGreenCrystal) { - crystalAlive = NPC.AnyNPCs(ModContent.NPCType()); if (masterMode) - { - blueCrystalAlive = NPC.AnyNPCs(ModContent.NPCType()); - greenCrystalAlive = NPC.AnyNPCs(ModContent.NPCType()); - } + greenCrystalAlive = NPC.AnyNPCs(ModContent.NPCType()); + } + + if (phase3) + crystalAlive = NPC.AnyNPCs(ModContent.NPCType()); + + if (spawnBlueCrystal) + { + if (masterMode) + blueCrystalAlive = NPC.AnyNPCs(ModContent.NPCType()); } // Sapphire Crystal buffs @@ -77,27 +85,63 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Dust color when the blue crystal is alive Color dustColor = Color.Lerp(new Color(0, 0, 150, npc.alpha), new Color(125, 125, 255, npc.alpha), (float)Math.Sin(Main.GlobalTimeWrappedHourly) / 2f + 0.5f); - // Spawn crystal in phase 2 - if (phase3 && npc.Calamity().newAI[0] == 0f) + // Master Mode Crystal spawning + if (masterMode) { - npc.Calamity().newAI[0] = 1f; - npc.SyncExtraAI(); - Vector2 vector = npc.Center + new Vector2(-40f, -(float)npc.height / 2) * npc.scale; - int totalDustPerCrystalSpawn = 20; - for (int i = 0; i < totalDustPerCrystalSpawn; i++) + if (spawnGreenCrystal && npc.Calamity().newAI[0] == 0f) { - int rubyDust = Dust.NewDust(vector, npc.width / 2, npc.height / 2, DustID.GemRuby, 0f, 0f, 100, default, 2f); - Main.dust[rubyDust].velocity *= 2f; - Main.dust[rubyDust].noGravity = true; - if (Main.rand.NextBool()) + npc.Calamity().newAI[0] = 1f; + npc.SyncExtraAI(); + Vector2 vector = npc.Center + new Vector2(-40f, -(float)npc.height / 2) * npc.scale; + int totalDustPerCrystalSpawn = 20; + for (int i = 0; i < totalDustPerCrystalSpawn; i++) { - Main.dust[rubyDust].scale = 0.5f; - Main.dust[rubyDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + int emeraldDust = Dust.NewDust(vector, npc.width / 2, npc.height / 2, DustID.GemEmerald, 0f, 0f, 100, default, 2f); + Main.dust[emeraldDust].velocity *= 2f; + Main.dust[emeraldDust].noGravity = true; + if (Main.rand.NextBool()) + { + Main.dust[emeraldDust].scale = 0.5f; + Main.dust[emeraldDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } } + + SoundEngine.PlaySound(SoundID.Item38, vector); + + if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.NewNPC(npc.GetSource_FromAI(), (int)vector.X, (int)vector.Y, ModContent.NPCType()); } - if (masterMode) + if (phase3 && npc.Calamity().newAI[0] == 1f) { + npc.Calamity().newAI[0] = 2f; + npc.SyncExtraAI(); + Vector2 vector = npc.Center + new Vector2(-40f, -(float)npc.height / 2) * npc.scale; + int totalDustPerCrystalSpawn = 20; + for (int i = 0; i < totalDustPerCrystalSpawn; i++) + { + int rubyDust = Dust.NewDust(vector, npc.width / 2, npc.height / 2, DustID.GemRuby, 0f, 0f, 100, default, 2f); + Main.dust[rubyDust].velocity *= 2f; + Main.dust[rubyDust].noGravity = true; + if (Main.rand.NextBool()) + { + Main.dust[rubyDust].scale = 0.5f; + Main.dust[rubyDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } + } + + SoundEngine.PlaySound(SoundID.Item38, vector); + + if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.NewNPC(npc.GetSource_FromAI(), (int)vector.X, (int)vector.Y, ModContent.NPCType()); + } + + if (spawnBlueCrystal && npc.Calamity().newAI[0] == 2f) + { + npc.Calamity().newAI[0] = 3f; + npc.SyncExtraAI(); + Vector2 vector = npc.Center + new Vector2(-40f, -(float)npc.height / 2) * npc.scale; + int totalDustPerCrystalSpawn = 20; for (int i = 0; i < totalDustPerCrystalSpawn; i++) { int sapphireDust = Dust.NewDust(vector, npc.width / 2, npc.height / 2, DustID.GemSapphire, 0f, 0f, 100, default, 2f); @@ -110,29 +154,37 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } + SoundEngine.PlaySound(SoundID.Item38, vector); + + if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.NewNPC(npc.GetSource_FromAI(), (int)vector.X, (int)vector.Y, ModContent.NPCType()); + } + } + else + { + // Spawn crystal in phase 2 + if (phase3 && npc.Calamity().newAI[0] == 0f) + { + npc.Calamity().newAI[0] = 1f; + npc.SyncExtraAI(); + Vector2 vector = npc.Center + new Vector2(-40f, -(float)npc.height / 2) * npc.scale; + int totalDustPerCrystalSpawn = 20; for (int i = 0; i < totalDustPerCrystalSpawn; i++) { - int emeraldDust = Dust.NewDust(vector, npc.width / 2, npc.height / 2, DustID.GemEmerald, 0f, 0f, 100, default, 2f); - Main.dust[emeraldDust].velocity *= 2f; - Main.dust[emeraldDust].noGravity = true; + int rubyDust = Dust.NewDust(vector, npc.width / 2, npc.height / 2, DustID.GemRuby, 0f, 0f, 100, default, 2f); + Main.dust[rubyDust].velocity *= 2f; + Main.dust[rubyDust].noGravity = true; if (Main.rand.NextBool()) { - Main.dust[emeraldDust].scale = 0.5f; - Main.dust[emeraldDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + Main.dust[rubyDust].scale = 0.5f; + Main.dust[rubyDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - } - SoundEngine.PlaySound(SoundID.Item38, vector); + SoundEngine.PlaySound(SoundID.Item38, vector); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - NPC.NewNPC(npc.GetSource_FromAI(), (int)vector.X, (int)vector.Y, ModContent.NPCType()); - if (masterMode) - { - NPC.NewNPC(npc.GetSource_FromAI(), (int)vector.X, (int)vector.Y, ModContent.NPCType()); - NPC.NewNPC(npc.GetSource_FromAI(), (int)vector.X, (int)vector.Y, ModContent.NPCType()); - } + if (Main.netMode != NetmodeID.MultiplayerClient) + NPC.NewNPC(npc.GetSource_FromAI(), (int)vector.X, (int)vector.Y, ModContent.NPCType()); } } @@ -280,6 +332,38 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (masterMode) teleportRate *= 2f; + if (npc.ai[0] == 0f) + { + // Move Blue Crystal + if (blueCrystalAlive) + { + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC blueCrystal = Main.npc[i]; + if (blueCrystal.active && blueCrystal.type == ModContent.NPCType()) + { + blueCrystal.position.X = npc.position.X; + blueCrystal.position.Y = npc.position.Y - 200f; + + for (int dusty = 0; dusty < 10; dusty++) + { + Vector2 dustVel = Main.rand.NextVector2CircularEdge(5f, 5f); + int sapphire = Dust.NewDust(blueCrystal.Center, blueCrystal.width, blueCrystal.height, DustID.GemSapphire, 0f, 0f, 100, default, 2f); + Main.dust[sapphire].velocity = dustVel * Main.rand.NextFloat(1f, 2f); + Main.dust[sapphire].noGravity = true; + if (Main.rand.NextBool()) + { + Main.dust[sapphire].scale = 0.5f; + Main.dust[sapphire].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } + } + + break; + } + } + } + } + npc.ai[0] += teleportRate; teleportScale = MathHelper.Clamp(npc.ai[0] / 30f, 0f, 1f); teleportScale = 0.5f + teleportScale * 0.5f; @@ -330,7 +414,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.damage = setDamage; npc.netUpdate = true; - npc.TargetClosest(); float distanceBelowTarget = npc.position.Y - (Main.player[npc.target].position.Y + 80f); float speedMult = 1f; @@ -603,7 +686,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[1] = 5f; if (Main.netMode != NetmodeID.MultiplayerClient) { - npc.TargetClosest(faceTarget: false); Point point3 = npc.Center.ToTileCoordinates(); Point point4 = Main.player[npc.target].Center.ToTileCoordinates(); Vector2 vector30 = Main.player[npc.target].Center - npc.Center; @@ -790,7 +872,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.damage = npc.defDamage; npc.netUpdate = true; - npc.TargetClosest(); if (npc.ai[1] == 3f) { npc.velocity.Y = -13f; @@ -890,11 +971,19 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses public static void GetPlaceToTeleportTo(NPC npc) { - npc.TargetClosest(false); float distanceAhead = 800f; Vector2 randomDefault = Main.rand.NextBool() ? Vector2.UnitX : -Vector2.UnitX; Vector2 vectorAimedAheadOfTarget = Main.player[npc.target].Center + new Vector2((float)Math.Round(Main.player[npc.target].velocity.X), 0f).SafeNormalize(randomDefault) * distanceAhead; Point predictiveTeleportPoint = vectorAimedAheadOfTarget.ToTileCoordinates(); + if (predictiveTeleportPoint.X < 10) + predictiveTeleportPoint.X = 10; + if (predictiveTeleportPoint.X > Main.maxTilesX - 10) + predictiveTeleportPoint.X = Main.maxTilesX - 10; + if (predictiveTeleportPoint.Y < 10) + predictiveTeleportPoint.Y = 10; + if (predictiveTeleportPoint.Y > Main.maxTilesY - 10) + predictiveTeleportPoint.Y = Main.maxTilesY - 10; + int randomPredictiveTeleportOffset = 5; int teleportTries = 0; while (teleportTries < 100) @@ -918,10 +1007,22 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses break; } else + { predictiveTeleportPoint.X += predictiveTeleportPoint.X < 0f ? 1 : -1; + if (predictiveTeleportPoint.X < 10) + predictiveTeleportPoint.X = 10; + if (predictiveTeleportPoint.X > Main.maxTilesX - 10) + predictiveTeleportPoint.X = Main.maxTilesX - 10; + } } else + { predictiveTeleportPoint.X += predictiveTeleportPoint.X < 0f ? 1 : -1; + if (predictiveTeleportPoint.X < 10) + predictiveTeleportPoint.X = 10; + if (predictiveTeleportPoint.X > Main.maxTilesX - 10) + predictiveTeleportPoint.X = Main.maxTilesX - 10; + } } // Default teleport if the above conditions aren't met in 100 iterations diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/PlanteraAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/PlanteraAI.cs index a7c993715b..04d87dc3be 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/PlanteraAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/PlanteraAI.cs @@ -39,10 +39,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - // Percent life remaining float lifeRatio = npc.life / (float)npc.lifeMax; @@ -301,6 +297,8 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } + npc.TargetClosest(); + npc.ai[1] = -SeedGatlingDuration; } } @@ -622,7 +620,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.localAI[1] >= shootProjectileGateValue) { npc.localAI[1] = 0f; - npc.TargetClosest(); bool shootPoisonSeed = CalamityWorld.LegendaryMode || Main.rand.NextBool(masterMode ? 2 : 4); int projectileType = shootPoisonSeed ? ProjectileID.PoisonSeedPlantera : ProjectileID.SeedPlantera; float projectileSpeed = masterMode ? 16f : 14f; @@ -1208,7 +1205,11 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { bool flag39 = false; bool flag40 = false; - npc.TargetClosest(); + + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); + if (Main.player[npc.target].dead) { flag40 = true; diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/QueenBeeAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/QueenBeeAI.cs index 95257c3031..e8bb17fb34 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/QueenBeeAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/QueenBeeAI.cs @@ -23,10 +23,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - bool bossRush = BossRushEvent.BossRushActive; bool masterMode = Main.masterMode || bossRush; bool death = CalamityWorld.death || bossRush; @@ -1031,6 +1027,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } while ((float)num647 == num646); + npc.TargetClosest(); npc.ai[0] = num647; npc.ai[1] = 0f; npc.ai[2] = 0f; @@ -1081,8 +1078,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { // Avoid cheap bullshit npc.damage = 0; - - npc.TargetClosest(); float chargeDistanceY = 20f; chargeDistanceY += 20f * num644; @@ -1239,8 +1234,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Avoid cheap bullshit npc.damage = 0; - npc.TargetClosest(); - float playerLocation = npc.Center.X - Main.player[npc.target].Center.X; npc.direction = playerLocation < 0 ? 1 : -1; npc.spriteDirection = npc.direction; @@ -1290,8 +1283,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Avoid cheap bullshit npc.damage = 0; - npc.TargetClosest(); - float playerLocation = npc.Center.X - Main.player[npc.target].Center.X; npc.direction = playerLocation < 0 ? 1 : -1; npc.spriteDirection = npc.direction; @@ -1322,7 +1313,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.damage = 0; npc.localAI[0] = 0f; - npc.TargetClosest(); float num672 = Main.masterMode ? 16f : 14f; float num673 = Main.masterMode ? 0.15f : 0.1f; diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/QueenSlimeAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/QueenSlimeAI.cs index 40b7d577b3..1ce6e0c5c6 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/QueenSlimeAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/QueenSlimeAI.cs @@ -68,7 +68,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (Main.netMode != NetmodeID.MultiplayerClient) { npc.netUpdate = true; - npc.TargetClosest(faceTarget: false); Vector2 vectorAimedAheadOfTarget = Main.player[npc.target].Center + new Vector2((float)Math.Round(Main.player[npc.target].velocity.X), 0f).SafeNormalize(Vector2.Zero) * 800f; Point predictiveTeleportPoint = vectorAimedAheadOfTarget.ToTileCoordinates(); int randomTeleportOffset = 5; @@ -403,7 +402,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses speedMult = 2f; npc.netUpdate = true; - npc.TargetClosest(); if (npc.ai[2] == 3f) { npc.velocity.Y = -13f * speedMult; @@ -931,7 +929,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (Main.netMode != NetmodeID.MultiplayerClient) { npc.netUpdate = true; - npc.TargetClosest(false); Point point = npc.Center.ToTileCoordinates(); Point point2 = Main.player[npc.target].Center.ToTileCoordinates(); Vector2 vector = Main.player[npc.target].Center - npc.Center; @@ -1251,7 +1248,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.damage = npc.defDamage; npc.netUpdate = true; - npc.TargetClosest(); if (npc.ai[2] == 3f) { npc.velocity.Y = -13f; @@ -1629,8 +1625,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float flyAcceleration = bossRush ? 0.3f : death ? (masterMode ? 0.18f : 0.14f) : (masterMode ? 0.16f : 0.12f); float flyDistanceY = masterMode ? 350f : 450f; - npc.TargetClosest(); - Vector2 desiredVelocity = npc.Center; if (npc.timeLeft > 10) @@ -1698,7 +1692,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float num = Main.masterMode ? 18f : Main.expertMode ? 15f : 12f; float num2 = Main.masterMode ? 0.12f : Main.expertMode ? 0.1f : 0.085f; float num3 = 250f; - npc.TargetClosest(); Vector2 desiredVelocity = npc.Center; if (npc.timeLeft > 10) { diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronAI.cs index 0eb710efcb..d8e4856b6b 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronAI.cs @@ -34,6 +34,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float phase3LifeRatio = masterMode ? 0.9f : 0.7f; float respawnHandsLifeRatio = 0.5f; float phase4LifeRatio = masterMode ? 0.4f : 0.3f; + float useSkullSpreadsAfterChargeLifeRatio = masterMode ? 0.3f : 0.2f; float phase5LifeRatio = masterMode ? 0.2f : 0.1f; // Begin firing spreads of skulls phase @@ -48,6 +49,9 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Fire giant cursed skull projectiles (yes, these curse you if you get hit) during charge attack and hands fire skulls phase bool phase4 = lifeRatio < phase4LifeRatio; + // Self-explanatory + bool useSkullSpreadsAfterCharge = lifeRatio < useSkullSpreadsAfterChargeLifeRatio; + // Rapid teleport and charge, stop using idle phase bool phase5 = lifeRatio < phase5LifeRatio; @@ -60,10 +64,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - // Spawn hands if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -125,16 +125,18 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } - // Distance from target - float distance = Vector2.Distance(Main.player[npc.target].Center, npc.Center); - // Despawn - int despawnDistanceInTiles = 500; - if (Main.player[npc.target].dead || Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) / 16f > despawnDistanceInTiles) + if (npc.ai[1] != 3f) { - npc.TargetClosest(); + int despawnDistanceInTiles = 500; if (Main.player[npc.target].dead || Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) / 16f > despawnDistanceInTiles) - npc.ai[1] = 3f; + { + npc.TargetClosest(); + if (Main.player[npc.target].dead || Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) / 16f > despawnDistanceInTiles) + npc.ai[1] = 3f; + } + else if (npc.timeLeft < 1800) + npc.timeLeft = 1800; } // Daytime enrage @@ -203,6 +205,11 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (death) headSpinVelocityMult *= 1.2f; + // Velocity used to move Skeletron away from the target before charging + float moveAwayVelocity = headSpinVelocityMult; + if (!phase3) + moveAwayVelocity *= (bossRush ? 1.5f : 2f); + // Hand DR, scale DR up if the hands are still alive as Skeletron's HP lowers npc.chaseable = handsDead; float minDR = 0.05f; @@ -458,7 +465,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.localAI[2] = 0f; calamityGlobalNPC.newAI[1] = 0f; - npc.TargetClosest(); npc.SyncExtraAI(); npc.SyncVanillaLocalAI(); npc.netUpdate = true; @@ -483,23 +489,18 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { if (!canCharge || !hasMovedForcedDistance) { - float maxAcceleration = headXAcceleration + headYAcceleration + (npc.ai[2] - moveAwayGateValue) * (phase5 ? 0.006f : 0.004f); - float maxAccelerationCap = (headXAcceleration + headYAcceleration) * 5f; - if (maxAcceleration > maxAccelerationCap) - maxAcceleration = maxAccelerationCap; + float phase5Multiplier = 1.5f; + float maxVelocity = (npc.ai[2] - moveAwayGateValue) * (moveAwayVelocity * 0.008f); + if (phase5) + maxVelocity *= phase5Multiplier; - npc.velocity += (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY) * -maxAcceleration; - - float maxVelocity = headSpinVelocityMult + (npc.ai[2] - moveAwayGateValue) * (phase5 ? 0.12f : 0.08f); - float maxVelocityCap = headSpinVelocityMult * 2.5f; + float maxVelocityCap = moveAwayVelocity; + if (phase5) + maxVelocityCap *= phase5Multiplier; if (maxVelocity > maxVelocityCap) maxVelocity = maxVelocityCap; - if (npc.velocity.Length() > maxVelocity) - { - npc.velocity = npc.velocity.SafeNormalize(Vector2.UnitY); - npc.velocity *= maxVelocity; - } + npc.velocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY) * -maxVelocity; } // New charge attack @@ -694,7 +695,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } - if (respawnHands && !disableSkullsAfterCharge && Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) + if (useSkullSpreadsAfterCharge && !disableSkullsAfterCharge && Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) { // Spawn projectiles if (Main.netMode != NetmodeID.MultiplayerClient) @@ -702,7 +703,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses int chargeSkullAmt = death ? 5 : 3; int chargeSkullSpread = death ? 80 : 60; float rotation = MathHelper.ToRadians(chargeSkullSpread); - float skullProjSpeed = phase4 ? (6f + (death ? 2f * ((phase4LifeRatio - lifeRatio) / phase4LifeRatio) : 0f)) : 4f; + float skullProjSpeed = phase5 ? (6f + (death ? 2f * ((phase5LifeRatio - lifeRatio) / phase5LifeRatio) : 0f)) : 4f; Vector2 initialProjectileVelocity = npc.Center.DirectionTo(Main.player[npc.target].Center) * skullProjSpeed; int type = ProjectileID.Skull; int damage = npc.GetProjectileDamage(type); @@ -861,10 +862,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - float yMultiplier = 1f; if (calamityGlobalNPC.newAI[0] != 0f) yMultiplier = calamityGlobalNPC.newAI[0]; @@ -1009,6 +1006,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[3] += slapTimerIncrement; if (npc.ai[3] >= slapGateValue) { + npc.target = Main.npc[(int)npc.ai[1]].target; npc.ai[2] += 1f; npc.ai[3] = calamityGlobalNPC.newAI[2] = slapGateValue; calamityGlobalNPC.newAI[3] = 0f; @@ -1098,7 +1096,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Set damage npc.damage = npc.defDamage; - npc.TargetClosest(); npc.ai[2] = 2f; npc.ai[3] = 0f; npc.velocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY) * handSwipeVelocity; @@ -1158,7 +1155,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Set damage npc.damage = npc.defDamage; - npc.TargetClosest(); npc.ai[2] = 5f; npc.ai[3] = 0f; npc.velocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY) * handSwipeVelocity; @@ -1245,9 +1241,13 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { npc.reflectsProjectiles = false; npc.defense = npc.defDefense; + + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); + if (npc.ai[0] == 0f && Main.netMode != NetmodeID.MultiplayerClient) { - npc.TargetClosest(); npc.ai[0] = 1f; int num148 = NPC.NewNPC(npc.GetSource_FromAI(), (int)(npc.Center.X), (int)npc.Center.Y, NPCID.SkeletronHand, npc.whoAmI); Main.npc[num148].ai[0] = -1f; @@ -1346,7 +1346,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { npc.ai[2] = 0f; npc.ai[1] = 1f; - npc.TargetClosest(); npc.netUpdate = true; } @@ -1442,6 +1441,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { npc.ai[2] = 0f; npc.ai[1] = 0f; + npc.TargetClosest(); } npc.rotation += (float)npc.direction * 0.3f; @@ -1566,6 +1566,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); + if (npc.ai[2] == 0f || npc.ai[2] == 3f) { // Avoid cheap bullshit @@ -1631,6 +1635,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.ai[3] >= 300f) { + npc.target = Main.npc[(int)npc.ai[1]].target; npc.ai[2] += 1f; npc.ai[3] = 0f; npc.netUpdate = true; @@ -1756,7 +1761,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Set damage npc.damage = npc.defDamage; - npc.TargetClosest(); npc.ai[2] = 2f; vector23 = npc.Center; num184 = Main.player[npc.target].Center.X - vector23.X; @@ -1811,7 +1815,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Set damage npc.damage = npc.defDamage; - npc.TargetClosest(); npc.ai[2] = 5f; vector24 = npc.Center; num187 = Main.player[npc.target].Center.X - vector24.X; diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronPrimeAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronPrimeAI.cs index 96febd4b2a..a7f40acc14 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronPrimeAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronPrimeAI.cs @@ -26,10 +26,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - // Percent life remaining float lifeRatio = npc.life / (float)npc.lifeMax; @@ -208,11 +204,17 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } // Despawn - if (Main.player[npc.target].dead || Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) > 6000f || Math.Abs(npc.Center.Y - Main.player[npc.target].Center.Y) > 6000f) + if (npc.ai[1] != 3f) { - npc.TargetClosest(); - if (Main.player[npc.target].dead || Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) > 6000f || Math.Abs(npc.Center.Y - Main.player[npc.target].Center.Y) > 6000f) - npc.ai[1] = 3f; + int despawnDistanceInTiles = 500; + if (Main.player[npc.target].dead || Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) / 16f > despawnDistanceInTiles) + { + npc.TargetClosest(); + if (Main.player[npc.target].dead || Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) / 16f > despawnDistanceInTiles) + npc.ai[1] = 3f; + } + else if (npc.timeLeft < 1800) + npc.timeLeft = 1800; } // Activate daytime enrage @@ -260,7 +262,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Start other phases; if arms are dead, start with spin phase bool otherHeadChargingOrSpinning = Main.npc[(int)npc.ai[0]].ai[1] == 5f || Main.npc[(int)npc.ai[0]].ai[1] == 1f; - if (phase2 || CalamityWorld.LegendaryMode || allArmsDead) + if (phase2 || CalamityWorld.LegendaryMode || allArmsDead || masterMode) { // Start spin phase after 1.5 seconds npc.ai[2] += phase3 ? 1.5f : 1f; @@ -269,7 +271,14 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses bool shouldSpinAround = npc.ai[1] == 4f && npc.position.Y < Main.player[npc.target].position.Y - 400f && Vector2.Distance(Main.player[npc.target].Center, npc.Center) < 600f && Vector2.Distance(Main.player[npc.target].Center, npc.Center) > 400f; - if (shouldSpinAround || npc.ai[1] != 4f) + bool shouldCharge = masterMode && !phase2 && !allArmsDead && !CalamityWorld.LegendaryMode; + if (shouldCharge) + { + npc.ai[2] = 0f; + npc.ai[1] = 1f; + npc.netUpdate = true; + } + else if (shouldSpinAround || npc.ai[1] != 4f) { if (shouldSpinAround) { @@ -279,7 +288,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[2] = 0f; npc.ai[1] = shouldSpinAround ? 5f : 1f; - npc.TargetClosest(); npc.netUpdate = true; } } @@ -780,10 +788,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - // Set direction npc.spriteDirection = -(int)npc.ai[0]; @@ -914,10 +918,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.ai[3] >= (masterMode ? 200f : 800f)) { + npc.target = Main.npc[(int)npc.ai[1]].target; npc.localAI[0] = 0f; npc.ai[2] = 1f; npc.ai[3] = 0f; - npc.TargetClosest(); npc.netUpdate = true; } @@ -941,7 +945,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.localAI[0] >= 48f) { npc.localAI[0] = 0f; - npc.TargetClosest(); float laserSpeed = bossRush ? 5f : 4f; int type = ProjectileID.DeathLaser; int damage = npc.GetProjectileDamage(type); @@ -983,10 +986,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.ai[3] >= timeLimit) { + npc.target = Main.npc[(int)npc.ai[1]].target; npc.localAI[0] = 0f; npc.ai[2] = 0f; npc.ai[3] = 0f; - npc.TargetClosest(); npc.netUpdate = true; } @@ -1009,7 +1012,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.localAI[0] >= 120f) { npc.localAI[0] = 0f; - npc.TargetClosest(); int totalProjectiles = bossRush ? 32 : (masterMode ? 24 : 16); float radians = MathHelper.TwoPi / totalProjectiles; int type = ProjectileID.DeathLaser; @@ -1055,10 +1057,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - npc.spriteDirection = -(int)npc.ai[0]; if (!Main.npc[(int)npc.ai[1]].active || Main.npc[(int)npc.ai[1]].aiStyle != NPCAIStyleID.SkeletronPrimeHead) @@ -1131,11 +1129,11 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.ai[3] >= (masterMode ? 200f : 800f)) { + npc.target = Main.npc[(int)npc.ai[1]].target; npc.localAI[0] = 0f; npc.ai[2] = 1f; fireSlower = false; npc.ai[3] = 0f; - npc.TargetClosest(); npc.netUpdate = true; } } @@ -1155,11 +1153,11 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.ai[3] >= timeLimit) { + npc.target = Main.npc[(int)npc.ai[1]].target; npc.localAI[0] = 0f; npc.ai[2] = 0f; fireSlower = true; npc.ai[3] = 0f; - npc.TargetClosest(); npc.netUpdate = true; } } @@ -1251,7 +1249,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { SoundEngine.PlaySound(SoundID.Item62, npc.Center); npc.localAI[0] = 0f; - npc.TargetClosest(); int type = ProjectileID.RocketSkeleton; int damage = npc.GetProjectileDamage(type); @@ -1299,7 +1296,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { SoundEngine.PlaySound(SoundID.Item62, npc.Center); npc.localAI[0] = 0f; - npc.TargetClosest(); int type = ProjectileID.RocketSkeleton; int damage = npc.GetProjectileDamage(type); @@ -1341,10 +1337,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - // Direction npc.spriteDirection = -(int)npc.ai[0]; @@ -1487,9 +1479,9 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.ai[3] >= (masterMode ? 150f : 600f)) { + npc.target = Main.npc[(int)npc.ai[1]].target; npc.ai[2] += 1f; npc.ai[3] = 0f; - npc.TargetClosest(); npc.netUpdate = true; } @@ -1595,7 +1587,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses chargeVelocity += 1.5f; npc.ai[2] = 2f; - npc.TargetClosest(); viceArmChargePosition = npc.Center; viceArmChargeTargetX = Main.player[npc.target].Center.X - viceArmChargePosition.X; viceArmChargeTargetY = Main.player[npc.target].Center.Y - viceArmChargePosition.Y; @@ -1628,7 +1619,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Return to head npc.ai[2] = 3f; npc.ai[3] = 0f; - npc.TargetClosest(); return false; } @@ -1665,7 +1655,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses chargeVelocity += 1.15f; npc.ai[2] = 5f; - npc.TargetClosest(); viceArmOtherChargePosition = npc.Center; viceArmOtherChargeTargetX = Main.player[npc.target].Center.X - viceArmOtherChargePosition.X; viceArmOtherChargeTargetY = Main.player[npc.target].Center.Y - viceArmOtherChargePosition.Y; @@ -1696,7 +1685,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Return to head npc.ai[2] = 0f; npc.ai[3] = 0f; - npc.TargetClosest(); return false; } @@ -1718,10 +1706,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - Vector2 sawArmLocation = npc.Center; float sawArmIdleXPos = Main.npc[(int)npc.ai[1]].Center.X - 200f * npc.ai[0] - sawArmLocation.X; float sawArmIdleYPos = Main.npc[(int)npc.ai[1]].position.Y + 230f - sawArmLocation.Y; @@ -1858,9 +1842,9 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.ai[3] >= (masterMode ? 90f : 180f)) { + npc.target = Main.npc[(int)npc.ai[1]].target; npc.ai[2] += 1f; npc.ai[3] = 0f; - npc.TargetClosest(); npc.netUpdate = true; } @@ -1960,7 +1944,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses chargeVelocity += 1.5f; npc.ai[2] = 2f; - npc.TargetClosest(); sawArmChargePos = npc.Center; sawArmChargeTargetX = Main.player[npc.target].Center.X - sawArmChargePos.X; sawArmChargeTargetY = Main.player[npc.target].Center.Y - sawArmChargePos.Y; @@ -2049,7 +2032,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { npc.ai[2] = 0f; npc.ai[3] = 0f; - npc.TargetClosest(); npc.netUpdate = true; } @@ -2125,7 +2107,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { npc.ai[2] = 0f; npc.ai[1] = 1f; - npc.TargetClosest(); npc.netUpdate = true; } @@ -2212,6 +2193,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { npc.ai[2] = 0f; npc.ai[1] = 0f; + npc.TargetClosest(); } if (NPC.IsMechQueenUp) @@ -2367,6 +2349,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); + npc.damage = 0; if (npc.ai[2] == 0f || npc.ai[2] == 3f) @@ -2435,6 +2421,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[3] += 1f; if (npc.ai[3] >= (Main.masterMode ? 400f : Main.expertMode ? 600f : 800f)) { + npc.target = Main.npc[(int)npc.ai[1]].target; npc.ai[2] += 1f; npc.ai[3] = 0f; npc.netUpdate = true; @@ -2494,7 +2481,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } - npc.TargetClosest(); Vector2 vector68 = npc.Center; float num559 = Main.player[npc.target].Center.X - vector68.X; float num560 = Main.player[npc.target].Center.Y - vector68.Y; @@ -2538,6 +2524,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[3] += 1f; if (npc.ai[3] >= (Main.masterMode ? 150f : Main.expertMode ? 175f : 200f)) { + npc.target = Main.npc[(int)npc.ai[1]].target; npc.localAI[0] = 0f; npc.ai[2] = 0f; npc.ai[3] = 0f; @@ -2594,7 +2581,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.velocity.Y += num498; } - npc.TargetClosest(); vector69 = npc.Center; num566 = Main.player[npc.target].Center.X - vector69.X; num567 = Main.player[npc.target].Center.Y - vector69.Y; @@ -2648,6 +2634,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); + npc.damage = 0; if (npc.ai[2] == 0f) @@ -2716,6 +2706,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[3] += 1f; if (npc.ai[3] >= (Main.masterMode ? 700f : Main.expertMode ? 900f : 1100f)) { + npc.target = Main.npc[(int)npc.ai[1]].target; npc.localAI[0] = 0f; npc.ai[2] = 1f; npc.ai[3] = 0f; @@ -2807,6 +2798,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[3] += 1f; if (npc.ai[3] >= (Main.masterMode ? 180f : Main.expertMode ? 240f : 300f)) { + npc.target = Main.npc[(int)npc.ai[1]].target; npc.localAI[0] = 0f; npc.ai[2] = 0f; npc.ai[3] = 0f; @@ -2864,7 +2856,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.velocity.Y += num498; } - npc.TargetClosest(); vector67 = npc.Center; num552 = Main.player[npc.target].Center.X - vector67.X; num553 = Main.player[npc.target].Center.Y - vector67.Y; @@ -2918,6 +2909,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); + // Avoid cheap bullshit npc.damage = 0; @@ -2983,7 +2978,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (Main.npc[(int)npc.ai[1]].ai[1] != 0f) { - npc.TargetClosest(); if (Main.player[npc.target].dead) { npc.velocity.Y += 0.1f; @@ -3025,6 +3019,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[3] += 1f; if (npc.ai[3] >= (Main.masterMode ? 400f : Main.expertMode ? 500f : 600f)) { + npc.target = Main.npc[(int)npc.ai[1]].target; npc.ai[2] += 1f; npc.ai[3] = 0f; npc.netUpdate = true; @@ -3112,7 +3107,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Set damage npc.damage = npc.defDamage; - npc.TargetClosest(); npc.ai[2] = 2f; vector64 = npc.Center; num539 = Main.player[npc.target].Center.X - vector64.X; @@ -3161,7 +3155,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Set damage npc.damage = npc.defDamage; - npc.TargetClosest(); npc.ai[2] = 5f; vector65 = npc.Center; num542 = Main.player[npc.target].Center.X - vector65.X; @@ -3220,6 +3213,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); + // Min saw damage int reducedSetDamage = (int)Math.Round(npc.defDamage * 0.5); @@ -3288,7 +3285,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (Main.npc[(int)npc.ai[1]].ai[1] != 0f) { - npc.TargetClosest(); if (Main.player[npc.target].dead) { npc.velocity.Y += 0.1f; @@ -3354,6 +3350,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[3] += 1f; if (npc.ai[3] >= (Main.masterMode ? 180f : Main.expertMode ? 240f : 300f)) { + npc.target = Main.npc[(int)npc.ai[1]].target; npc.ai[2] += 1f; npc.ai[3] = 0f; npc.netUpdate = true; @@ -3438,7 +3435,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Set damage npc.damage = npc.defDamage; - npc.TargetClosest(); npc.ai[2] = 2f; vector59 = npc.Center; num524 = Main.player[npc.target].Center.X - vector59.X; @@ -3463,7 +3459,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Set damage npc.damage = npc.defDamage; - npc.TargetClosest(); Vector2 vector60 = npc.Center; float num527 = Main.player[npc.target].Center.X - vector60.X; float num528 = Main.player[npc.target].Center.Y - vector60.Y; diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/TwinsAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/TwinsAI.cs index 7f270bebca..1647c03d42 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/TwinsAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/TwinsAI.cs @@ -25,10 +25,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - float enrageScale = bossRush ? 0.5f : masterMode ? 0.4f : 0f; if (Main.IsItDay() || bossRush) { @@ -382,13 +378,13 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { npc.ai[3] += 1f; npc.ai[2] = 0f; - npc.TargetClosest(); npc.rotation = retinazerHoverRotation; float totalCharges = death ? 6f : 5f; if (npc.ai[3] >= totalCharges) { npc.ai[1] = 0f; npc.ai[3] = 0f; + npc.TargetClosest(); } else npc.ai[1] = 1f; @@ -895,13 +891,13 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[3] += chargeIncrement; - npc.TargetClosest(); npc.rotation = retinazerHoverRotation; float maxChargeAmt = spazAlive ? 2f : 4f; if (npc.ai[3] >= maxChargeAmt) { npc.ai[1] = 0f; npc.ai[3] = 0f; + npc.TargetClosest(); } else npc.ai[1] = 4f; @@ -974,7 +970,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[2] += 1f; if (npc.ai[2] >= (spazAlive ? 75f : 60f) - (death ? 20f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f)) { - npc.TargetClosest(); npc.ai[1] = 2f; npc.ai[2] = 0f; npc.netUpdate = true; @@ -998,10 +993,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) - npc.TargetClosest(); - float enrageScale = bossRush ? 0.5f : masterMode ? 0.4f : 0f; if (Main.IsItDay() || bossRush) { @@ -1261,7 +1252,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[1] = 1f; npc.ai[2] = 0f; npc.ai[3] = 0f; - npc.TargetClosest(); npc.netUpdate = true; } else @@ -1367,7 +1357,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Reset AI array and go to cursed fireball phase npc.ai[3] += 1f; npc.ai[2] = 0f; - npc.TargetClosest(); npc.rotation = spazmatismRotation; float totalCharges = 8f; if (death) @@ -1584,7 +1573,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[1] = (!retAlive || finalPhase) ? 5f : 1f; npc.ai[2] = 0f; npc.ai[3] = 0f; - npc.TargetClosest(); npc.netUpdate = true; } @@ -1744,7 +1732,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { npc.ai[3] += 1f; npc.ai[2] = 0f; - npc.TargetClosest(); npc.rotation = spazmatismRotation; if (npc.ai[3] >= 5f) { @@ -1766,7 +1753,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float secondFastCharge = 4f; if (npc.ai[3] >= (retAlive ? secondFastCharge : secondFastCharge + 1f)) { - npc.TargetClosest(); npc.ai[1] = retAlive ? 0f : 5f; npc.ai[2] = 0f; npc.ai[3] = 0f; @@ -1996,7 +1982,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Take 3 seconds to get in position, then charge if (npc.ai[2] >= (retAlive ? 180f : 135f) - (death ? 45f * ((phase2LifeRatio - lifeRatio) / phase2LifeRatio) : 0f)) { - npc.TargetClosest(); npc.ai[1] = 3f; npc.ai[2] = -1f; npc.ai[3] = 0f; @@ -2196,7 +2181,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[1] = 1f; npc.ai[2] = 0f; npc.ai[3] = 0f; - npc.target = Main.maxPlayers; + npc.TargetClosest(); npc.netUpdate = true; } else if (npc.position.Y + (float)npc.height < Main.player[npc.target].position.Y && num425 < (Main.masterMode ? 720f : Main.expertMode ? 560f : 400f)) @@ -2299,11 +2284,11 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { npc.ai[3] += 1f; npc.ai[2] = 0f; - npc.target = Main.maxPlayers; npc.rotation = num414; float numCharges = Main.masterMode ? 6f : Main.expertMode ? 5f : 4f; if (npc.ai[3] >= numCharges) { + npc.TargetClosest(); npc.ai[1] = 0f; npc.ai[3] = 0f; } @@ -2318,6 +2303,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[1] = 0f; npc.ai[2] = 0f; npc.ai[3] = 0f; + npc.TargetClosest(); npc.netUpdate = true; } @@ -2748,7 +2734,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Avoid cheap bullshit npc.damage = 0; - npc.TargetClosest(); float num463 = 12f; float num464 = 0.4f; if (Main.expertMode) @@ -2838,7 +2823,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[1] = 1f; npc.ai[2] = 0f; npc.ai[3] = 0f; - npc.target = Main.maxPlayers; npc.netUpdate = true; } else @@ -2942,7 +2926,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { npc.ai[3] += 1f; npc.ai[2] = 0f; - npc.target = Main.maxPlayers; npc.rotation = num458; float numCharges = Main.masterMode ? 6f : Main.expertMode ? 8f : 10f; if (npc.ai[3] >= numCharges) @@ -3130,7 +3113,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[1] = 1f; npc.ai[2] = 0f; npc.ai[3] = 0f; - npc.target = Main.maxPlayers; npc.netUpdate = true; } @@ -3274,7 +3256,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { npc.ai[3] += 1f; npc.ai[2] = 0f; - npc.target = Main.maxPlayers; npc.rotation = num458; float numCharges = Main.masterMode ? Main.rand.Next(4, 7) : 6f; if (npc.ai[3] >= numCharges) diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/WallOfFleshAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/WallOfFleshAI.cs index 8ece6740c8..b9facd07ba 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/WallOfFleshAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/WallOfFleshAI.cs @@ -872,7 +872,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { npc.localAI[2] = 1f; npc.localAI[1] = 0f; - npc.TargetClosest(); } } else if (npc.localAI[1] > 45f && (canHit || masterModeDetach) && !charging) @@ -880,7 +879,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.localAI[1] = 0f; npc.localAI[2] += 1f; if (npc.localAI[2] >= TotalLasersPerBarrage + 1f) + { npc.localAI[2] = 0f; + npc.TargetClosest(); + } if (shouldFireLasers) { @@ -1348,10 +1350,13 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (Main.npc[Main.wofNPCIndex].life > 0) npc.life = Main.npc[Main.wofNPCIndex].life; + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.target = Main.npc[Main.wofNPCIndex].target; + // Avoid cheap bullshit npc.damage = 0; - npc.TargetClosest(); npc.position.X = Main.npc[Main.wofNPCIndex].position.X; npc.direction = Main.npc[Main.wofNPCIndex].direction; npc.spriteDirection = npc.direction; @@ -1464,7 +1469,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.localAI[1] = 0f; npc.localAI[2] += 1f; if (npc.localAI[2] >= (float)num396) + { npc.localAI[2] = 0f; + npc.TargetClosest(); + } if (flag27) { diff --git a/Projectiles/BaseProjectiles/BaseGunHoldoutProjectile.cs b/Projectiles/BaseProjectiles/BaseGunHoldoutProjectile.cs index f231b4f8d2..48e3be1879 100644 --- a/Projectiles/BaseProjectiles/BaseGunHoldoutProjectile.cs +++ b/Projectiles/BaseProjectiles/BaseGunHoldoutProjectile.cs @@ -1,6 +1,8 @@ using System; +using System.IO; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.DataStructures; using Terraria.GameContent; @@ -125,6 +127,8 @@ namespace CalamityMod.Projectiles.BaseProjectiles private Type AssociatedItemType => ItemLoader.GetItem(AssociatedItemID).GetType(); + private Asset ItemTexture => TextureAssets.Item[AssociatedItemID]; + #endregion #region Overridden Members @@ -137,18 +141,12 @@ namespace CalamityMod.Projectiles.BaseProjectiles public override void SetDefaults() { - Projectile.width = Projectile.height = TextureAssets.Item[AssociatedItemID].Width(); + Projectile.width = Projectile.height = ItemTexture is null ? 1 : ItemTexture.Width(); Projectile.tileCollide = false; Projectile.netImportant = true; } - public override void OnSpawn(IEntitySource source) - { - Owner = Main.player[Projectile.owner]; - OffsetLengthFromArm = MaxOffsetLengthFromArm; - HeldItem = Owner.ActiveItem(); - Projectile.velocity = Owner.Calamity().mouseWorld - Owner.RotatedRelativePoint(Owner.MountedCenter); - } + public override void OnSpawn(IEntitySource source) => OffsetLengthFromArm = MaxOffsetLengthFromArm; public override bool ShouldUpdatePosition() => false; @@ -160,6 +158,10 @@ namespace CalamityMod.Projectiles.BaseProjectiles public override void AI() { + // Multiplayer null-checking. + Owner ??= Main.player[Projectile.owner]; + HeldItem ??= Owner.ActiveItem(); + KillHoldoutLogic(); ManageHoldout(); HoldoutAI(); @@ -167,15 +169,12 @@ namespace CalamityMod.Projectiles.BaseProjectiles /// /// Here goes the code for when the holdout needs to despawn.
- /// Defaults to despawning when the owner isn't holding or isn't using the correspondent weapon. + /// Defaults to despawning when the owner isn't using the correspondent weapon. ///
public virtual void KillHoldoutLogic() { if (Owner.CantUseHoldout()) - { - Projectile.netUpdate = true; Projectile.Kill(); - } } /// @@ -221,6 +220,9 @@ namespace CalamityMod.Projectiles.BaseProjectiles if (OffsetLengthFromArm != MaxOffsetLengthFromArm) OffsetLengthFromArm = MathHelper.Lerp(OffsetLengthFromArm, MaxOffsetLengthFromArm, RecoilResolveSpeed); + + Projectile.netUpdate = true; + Projectile.netSpam = 0; } /// @@ -246,5 +248,41 @@ namespace CalamityMod.Projectiles.BaseProjectiles } #endregion + + #region Syncing + + public sealed override void SendExtraAI(BinaryWriter writer) + { + writer.Write(Projectile.rotation); + writer.Write(KeepRefreshingLifetime); + writer.Write(OffsetLengthFromArm); + writer.Write7BitEncodedInt(Projectile.spriteDirection); + SendExtraAIHoldout(writer); + } + + public sealed override void ReceiveExtraAI(BinaryReader reader) + { + Projectile.rotation = reader.ReadSingle(); + KeepRefreshingLifetime = reader.ReadBoolean(); + OffsetLengthFromArm = reader.ReadSingle(); + Projectile.spriteDirection = reader.Read7BitEncodedInt(); + ReceiveExtraAIHoldout(reader); + } + + /// + /// The common is sealed to avoid deleting syncing of other properties without noticing.
+ /// Use this method instead, which uses the same . + ///
+ /// + public virtual void SendExtraAIHoldout(BinaryWriter writer) { } + + /// + /// The common is sealed to avoid deleting syncing of other properties without noticing.
+ /// Use this method instead, which uses the same . + ///
+ /// + public virtual void ReceiveExtraAIHoldout(BinaryReader reader) { } + + #endregion } } diff --git a/Projectiles/Boss/BrimstoneRay.cs b/Projectiles/Boss/BrimstoneRay.cs index 4630d227b5..7e18a2f859 100644 --- a/Projectiles/Boss/BrimstoneRay.cs +++ b/Projectiles/Boss/BrimstoneRay.cs @@ -124,7 +124,7 @@ namespace CalamityMod.Projectiles.Boss Vector2 fireFrom = new Vector2(Main.npc[(int)Projectile.ai[1]].Center.X + (Main.npc[(int)Projectile.ai[1]].spriteDirection > 0 ? 34f : -34f), Main.npc[(int)Projectile.ai[1]].Center.Y - 74f) + velocity * distanceBetweenProjectiles; int projectileAmt = (int)(Projectile.localAI[1] / distanceBetweenProjectiles); int type = ModContent.ProjectileType(); - int damage = Projectile.GetProjectileDamage(ModContent.NPCType()); + int damage = (int)Math.Round(Projectile.damage * 0.6); float projectileVelocityToPass = 12f; for (int i = 0; i < projectileAmt; i++) diff --git a/Projectiles/Boss/HolyBlast.cs b/Projectiles/Boss/HolyBlast.cs index 6736fc4ea1..d6e09c41fd 100644 --- a/Projectiles/Boss/HolyBlast.cs +++ b/Projectiles/Boss/HolyBlast.cs @@ -58,6 +58,16 @@ namespace CalamityMod.Projectiles.Boss if (Main.npc[CalamityGlobalNPC.holyBoss].active) Projectile.maxPenetrate = (int)Main.npc[CalamityGlobalNPC.holyBoss].localAI[1]; } + else if (CalamityGlobalNPC.doughnutBoss != -1) + { + if (Main.npc[CalamityGlobalNPC.doughnutBoss].active) + { + if (Main.npc[CalamityGlobalNPC.doughnutBoss].Calamity().CurrentlyEnraged) + Projectile.maxPenetrate = (int)Providence.BossMode.Night; + else + Projectile.maxPenetrate = (int)Providence.BossMode.Day; + } + } else Projectile.maxPenetrate = (int)Providence.BossMode.Day; diff --git a/Projectiles/Boss/HolyBomb.cs b/Projectiles/Boss/HolyBomb.cs index 7bdb4af478..15ff7a1b48 100644 --- a/Projectiles/Boss/HolyBomb.cs +++ b/Projectiles/Boss/HolyBomb.cs @@ -47,6 +47,16 @@ namespace CalamityMod.Projectiles.Boss if (Main.npc[CalamityGlobalNPC.holyBoss].active) Projectile.maxPenetrate = (int)Main.npc[CalamityGlobalNPC.holyBoss].localAI[1]; } + else if (CalamityGlobalNPC.doughnutBoss != -1) + { + if (Main.npc[CalamityGlobalNPC.doughnutBoss].active) + { + if (Main.npc[CalamityGlobalNPC.doughnutBoss].Calamity().CurrentlyEnraged) + Projectile.maxPenetrate = (int)Providence.BossMode.Night; + else + Projectile.maxPenetrate = (int)Providence.BossMode.Day; + } + } else Projectile.maxPenetrate = (int)Providence.BossMode.Day; diff --git a/Projectiles/Boss/HolyBurnOrb.cs b/Projectiles/Boss/HolyBurnOrb.cs index 7509889518..b7bdb2c51b 100644 --- a/Projectiles/Boss/HolyBurnOrb.cs +++ b/Projectiles/Boss/HolyBurnOrb.cs @@ -41,6 +41,16 @@ namespace CalamityMod.Projectiles.Boss if (Main.npc[CalamityGlobalNPC.holyBoss].active) Projectile.maxPenetrate = (int)Main.npc[CalamityGlobalNPC.holyBoss].localAI[1]; } + else if (CalamityGlobalNPC.doughnutBoss != -1) + { + if (Main.npc[CalamityGlobalNPC.doughnutBoss].active) + { + if (Main.npc[CalamityGlobalNPC.doughnutBoss].Calamity().CurrentlyEnraged) + Projectile.maxPenetrate = (int)Providence.BossMode.Night; + else + Projectile.maxPenetrate = (int)Providence.BossMode.Day; + } + } else Projectile.maxPenetrate = (int)Providence.BossMode.Day; diff --git a/Projectiles/Boss/HolyFire.cs b/Projectiles/Boss/HolyFire.cs index 72a76cb870..0a19097430 100644 --- a/Projectiles/Boss/HolyFire.cs +++ b/Projectiles/Boss/HolyFire.cs @@ -42,6 +42,16 @@ namespace CalamityMod.Projectiles.Boss if (Main.npc[CalamityGlobalNPC.holyBoss].active) Projectile.maxPenetrate = (int)Main.npc[CalamityGlobalNPC.holyBoss].localAI[1]; } + else if (CalamityGlobalNPC.doughnutBoss != -1) + { + if (Main.npc[CalamityGlobalNPC.doughnutBoss].active) + { + if (Main.npc[CalamityGlobalNPC.doughnutBoss].Calamity().CurrentlyEnraged) + Projectile.maxPenetrate = (int)Providence.BossMode.Night; + else + Projectile.maxPenetrate = (int)Providence.BossMode.Day; + } + } else Projectile.maxPenetrate = (int)Providence.BossMode.Day; diff --git a/Projectiles/Boss/HolyFire2.cs b/Projectiles/Boss/HolyFire2.cs index d694d1753f..8e8c50642e 100644 --- a/Projectiles/Boss/HolyFire2.cs +++ b/Projectiles/Boss/HolyFire2.cs @@ -42,6 +42,16 @@ namespace CalamityMod.Projectiles.Boss if (Main.npc[CalamityGlobalNPC.holyBoss].active) Projectile.maxPenetrate = (int)Main.npc[CalamityGlobalNPC.holyBoss].localAI[1]; } + else if (CalamityGlobalNPC.doughnutBoss != -1) + { + if (Main.npc[CalamityGlobalNPC.doughnutBoss].active) + { + if (Main.npc[CalamityGlobalNPC.doughnutBoss].Calamity().CurrentlyEnraged) + Projectile.maxPenetrate = (int)Providence.BossMode.Night; + else + Projectile.maxPenetrate = (int)Providence.BossMode.Day; + } + } else Projectile.maxPenetrate = (int)Providence.BossMode.Day; diff --git a/Projectiles/Boss/HolyFlare.cs b/Projectiles/Boss/HolyFlare.cs index ce8b652245..1208b849ad 100644 --- a/Projectiles/Boss/HolyFlare.cs +++ b/Projectiles/Boss/HolyFlare.cs @@ -42,6 +42,16 @@ namespace CalamityMod.Projectiles.Boss if (Main.npc[CalamityGlobalNPC.holyBoss].active) Projectile.maxPenetrate = (int)Main.npc[CalamityGlobalNPC.holyBoss].localAI[1]; } + else if (CalamityGlobalNPC.doughnutBoss != -1) + { + if (Main.npc[CalamityGlobalNPC.doughnutBoss].active) + { + if (Main.npc[CalamityGlobalNPC.doughnutBoss].Calamity().CurrentlyEnraged) + Projectile.maxPenetrate = (int)Providence.BossMode.Night; + else + Projectile.maxPenetrate = (int)Providence.BossMode.Day; + } + } else Projectile.maxPenetrate = (int)Providence.BossMode.Day; diff --git a/Projectiles/Boss/HolySpear.cs b/Projectiles/Boss/HolySpear.cs index 03116c57ea..697dfa6c2a 100644 --- a/Projectiles/Boss/HolySpear.cs +++ b/Projectiles/Boss/HolySpear.cs @@ -61,6 +61,16 @@ namespace CalamityMod.Projectiles.Boss if (Main.npc[CalamityGlobalNPC.holyBoss].active) Projectile.maxPenetrate = (int)Main.npc[CalamityGlobalNPC.holyBoss].localAI[1]; } + else if (CalamityGlobalNPC.doughnutBoss != -1) + { + if (Main.npc[CalamityGlobalNPC.doughnutBoss].active) + { + if (Main.npc[CalamityGlobalNPC.doughnutBoss].Calamity().CurrentlyEnraged) + Projectile.maxPenetrate = (int)Providence.BossMode.Night; + else + Projectile.maxPenetrate = (int)Providence.BossMode.Day; + } + } else Projectile.maxPenetrate = (int)Providence.BossMode.Day; diff --git a/Projectiles/Boss/InfernadoRevenge.cs b/Projectiles/Boss/InfernadoRevenge.cs index dfb8a4e429..bfc028fc5b 100644 --- a/Projectiles/Boss/InfernadoRevenge.cs +++ b/Projectiles/Boss/InfernadoRevenge.cs @@ -72,6 +72,8 @@ namespace CalamityMod.Projectiles.Boss public override bool PreDraw(ref Color lightColor) { + Main.spriteBatch.EnterShaderRegion(); + GameShaders.Misc["CalamityMod:Bordernado"].UseSaturation(-0.2f); GameShaders.Misc["CalamityMod:Bordernado"].SetShaderTexture(ModContent.Request("Terraria/Images/Misc/Perlin")); Vector2[] drawPoints = new Vector2[5]; @@ -86,6 +88,8 @@ namespace CalamityMod.Projectiles.Boss drawPoints[drawPoints.Length - 1] = bottom; PrimitiveRenderer.RenderTrail(drawPoints, new((_) => Projectile.width * 0.5f + 16f, ColorFunction, shader: GameShaders.Misc["CalamityMod:Bordernado"]), 85); + Main.spriteBatch.ExitShaderRegion(); + Texture2D vortexTexture = ModContent.Request("CalamityMod/Projectiles/Boss/OldDukeVortex").Value; for (int i = 0; i < 110; i++) { diff --git a/Projectiles/Boss/MoltenBlast.cs b/Projectiles/Boss/MoltenBlast.cs index f80225ae09..18ee564f3b 100644 --- a/Projectiles/Boss/MoltenBlast.cs +++ b/Projectiles/Boss/MoltenBlast.cs @@ -58,6 +58,16 @@ namespace CalamityMod.Projectiles.Boss if (Main.npc[CalamityGlobalNPC.holyBoss].active) Projectile.maxPenetrate = (int)Main.npc[CalamityGlobalNPC.holyBoss].localAI[1]; } + else if (CalamityGlobalNPC.doughnutBoss != -1) + { + if (Main.npc[CalamityGlobalNPC.doughnutBoss].active) + { + if (Main.npc[CalamityGlobalNPC.doughnutBoss].Calamity().CurrentlyEnraged) + Projectile.maxPenetrate = (int)Providence.BossMode.Night; + else + Projectile.maxPenetrate = (int)Providence.BossMode.Day; + } + } else Projectile.maxPenetrate = (int)Providence.BossMode.Day; diff --git a/Projectiles/Boss/MoltenBlob.cs b/Projectiles/Boss/MoltenBlob.cs index 2ff2619640..f0516d1376 100644 --- a/Projectiles/Boss/MoltenBlob.cs +++ b/Projectiles/Boss/MoltenBlob.cs @@ -39,6 +39,16 @@ namespace CalamityMod.Projectiles.Boss if (Main.npc[CalamityGlobalNPC.holyBoss].active) Projectile.maxPenetrate = (int)Main.npc[CalamityGlobalNPC.holyBoss].localAI[1]; } + else if (CalamityGlobalNPC.doughnutBoss != -1) + { + if (Main.npc[CalamityGlobalNPC.doughnutBoss].active) + { + if (Main.npc[CalamityGlobalNPC.doughnutBoss].Calamity().CurrentlyEnraged) + Projectile.maxPenetrate = (int)Providence.BossMode.Night; + else + Projectile.maxPenetrate = (int)Providence.BossMode.Day; + } + } else Projectile.maxPenetrate = (int)Providence.BossMode.Day; diff --git a/Projectiles/Boss/ProfanedSpear.cs b/Projectiles/Boss/ProfanedSpear.cs index 7187932d5e..f716020d87 100644 --- a/Projectiles/Boss/ProfanedSpear.cs +++ b/Projectiles/Boss/ProfanedSpear.cs @@ -1,6 +1,9 @@ using System; using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.NPCs; +using CalamityMod.NPCs.Providence; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -32,6 +35,17 @@ namespace CalamityMod.Projectiles.Boss { Lighting.AddLight(Projectile.Center, 0.45f, 0.35f, 0f); + if (CalamityGlobalNPC.doughnutBoss != -1) + { + if (Main.npc[CalamityGlobalNPC.doughnutBoss].active) + { + if (Main.npc[CalamityGlobalNPC.doughnutBoss].Calamity().CurrentlyEnraged) + Projectile.maxPenetrate = (int)Providence.BossMode.Night; + else + Projectile.maxPenetrate = (int)Providence.BossMode.Day; + } + } + if (Projectile.timeLeft < 510) Projectile.tileCollide = true; @@ -56,11 +70,14 @@ namespace CalamityMod.Projectiles.Boss public override Color? GetAlpha(Color lightColor) { - return new Color(250, 150, 0, Projectile.alpha); + return ProvUtils.GetProjectileColor(Projectile.maxPenetrate, Projectile.alpha); } public override bool PreDraw(ref Color lightColor) { + Texture2D texture = (Projectile.maxPenetrate == (int)Providence.BossMode.Day) ? Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value : ModContent.Request("CalamityMod/Projectiles/Boss/ProfanedSpearNight").Value; + Projectile.DrawBackglow(ProvUtils.GetProjectileColor(Projectile.maxPenetrate, Projectile.alpha, true), 4f, texture); + Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, 0, texture.Width, texture.Height)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2(texture.Width / 2f, texture.Height / 2f), Projectile.scale, SpriteEffects.None, 0); CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1); return false; } diff --git a/Projectiles/Boss/ProfanedSpearNight.png b/Projectiles/Boss/ProfanedSpearNight.png new file mode 100644 index 0000000000..712ed5b89d Binary files /dev/null and b/Projectiles/Boss/ProfanedSpearNight.png differ diff --git a/Projectiles/Boss/ProvidenceHolyRay.cs b/Projectiles/Boss/ProvidenceHolyRay.cs index 0a5609302b..fff9c36e64 100644 --- a/Projectiles/Boss/ProvidenceHolyRay.cs +++ b/Projectiles/Boss/ProvidenceHolyRay.cs @@ -55,6 +55,16 @@ namespace CalamityMod.Projectiles.Boss if (Main.npc[CalamityGlobalNPC.holyBoss].active) Projectile.maxPenetrate = (int)Main.npc[CalamityGlobalNPC.holyBoss].localAI[1]; } + else if (CalamityGlobalNPC.doughnutBoss != -1) + { + if (Main.npc[CalamityGlobalNPC.doughnutBoss].active) + { + if (Main.npc[CalamityGlobalNPC.doughnutBoss].Calamity().CurrentlyEnraged) + Projectile.maxPenetrate = (int)Providence.BossMode.Night; + else + Projectile.maxPenetrate = (int)Providence.BossMode.Day; + } + } else Projectile.maxPenetrate = (int)Providence.BossMode.Day; diff --git a/Projectiles/Boss/ThornBallSpike.cs b/Projectiles/Boss/ThornBallSpike.cs index f3db9317e9..86d5b8d957 100644 --- a/Projectiles/Boss/ThornBallSpike.cs +++ b/Projectiles/Boss/ThornBallSpike.cs @@ -36,7 +36,7 @@ namespace CalamityMod.Projectiles.Boss { if (Projectile.velocity.Length() < MaxVelocity) { - Projectile.velocity *= 1.05f; + Projectile.velocity *= 1.045f; if (Projectile.velocity.Length() > MaxVelocity) { Projectile.velocity.Normalize(); @@ -58,6 +58,8 @@ namespace CalamityMod.Projectiles.Boss public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(BuffID.Venom, 90); + public override Color? GetAlpha(Color lightColor) => new Color(200, 200, 200, Projectile.alpha); + public override bool PreDraw(ref Color lightColor) { if (Projectile.timeLeft > TimeLeft - 5) diff --git a/Projectiles/Boss/ThornBallSpike.png b/Projectiles/Boss/ThornBallSpike.png index a1be17ccd9..9253275e89 100644 Binary files a/Projectiles/Boss/ThornBallSpike.png and b/Projectiles/Boss/ThornBallSpike.png differ diff --git a/Projectiles/CalamityGlobalProjectile.cs b/Projectiles/CalamityGlobalProjectile.cs index 83f8b28779..27d65eacbf 100644 --- a/Projectiles/CalamityGlobalProjectile.cs +++ b/Projectiles/CalamityGlobalProjectile.cs @@ -603,7 +603,8 @@ namespace CalamityMod.Projectiles blood2.scale = 1.2f; blood2.position = projectile.Center + Main.rand.NextFloat() * projectile.velocity * 2f; - for (int j = 1; j < projectile.oldPos.Length && !(projectile.oldPos[j] == Vector2.Zero); j++) + int trailLength = projectile.oldPos.Length / 2; + for (int j = 1; j < trailLength && !(projectile.oldPos[j] == Vector2.Zero); j++) { if (Main.rand.NextBool(3)) { @@ -2153,8 +2154,8 @@ namespace CalamityMod.Projectiles int numDust = 5; int numDust2 = 5; int fadeInTime = 10; - int fadeOutGateValue = masterMode ? 80 : death ? 50 : 10; - float killGateValue = masterMode ? 90f : death ? 60f : 20f; + int fadeOutGateValue = masterMode ? 80 : death ? 50 : 25; + float killGateValue = masterMode ? 90f : death ? 60f : 35f; int maxFrames = 5; bool fadeIn = projectile.ai[0] < (float)fadeInTime; @@ -4280,7 +4281,7 @@ namespace CalamityMod.Projectiles if (CalamityWorld.revenge || BossRushEvent.BossRushActive) { float fadeInTime = 10f; - float fadeOutGateValue = masterMode ? 80f : death ? 50f : 10f; + float fadeOutGateValue = masterMode ? 80f : death ? 50f : 25f; return (projectile.ai[0] >= fadeInTime && projectile.ai[0] < fadeOutGateValue); } break; @@ -4390,15 +4391,15 @@ namespace CalamityMod.Projectiles if (projectile.type == ProjectileID.ThornBall) { - float startTurningBrownGateValue = 420f; - float timeToReachFullBrown = 180f; - float timeToReachThornExplosion = startTurningBrownGateValue + timeToReachFullBrown; + float startWarningColorGateValue = 420f; + float timeToReachFullIntensity = 180f; + float timeToReachThornExplosion = startWarningColorGateValue + timeToReachFullIntensity; Color initialColor = lightColor; - Color finalColor = new Color(125, 75, 75); + Color finalColor = Color.Lerp(new Color(125, 75, 75), Color.Red, (float)Math.Abs(Math.Sin((projectile.ai[1] - startWarningColorGateValue) * (MathHelper.Pi / 45)))); finalColor.A = (byte)(255 - projectile.alpha); - if (projectile.ai[1] > startTurningBrownGateValue) + if (projectile.ai[1] > startWarningColorGateValue) { - float colorTransitionRatio = (projectile.ai[1] - startTurningBrownGateValue) / timeToReachFullBrown; + float colorTransitionRatio = (projectile.ai[1] - startWarningColorGateValue) / timeToReachFullIntensity; Color dehydratedColor = Color.Lerp(initialColor, finalColor, colorTransitionRatio); return dehydratedColor; } @@ -4444,8 +4445,8 @@ namespace CalamityMod.Projectiles Vector2 origin12 = new Vector2(16f, value26.Height / 2); Color alpha5 = projectile.GetAlpha(lightColor); Vector2 vector39 = new Vector2(projectile.scale); - float fadeOutGateValue = masterMode ? 80f : death ? 50f : 10f; - float killGateValue = masterMode ? 90f : death ? 60f : 20f; + float fadeOutGateValue = masterMode ? 80f : death ? 50f : 25f; + float killGateValue = masterMode ? 90f : death ? 60f : 35f; float lerpValue5 = Utils.GetLerpValue(killGateValue, killGateValue - 10f, projectile.ai[0], clamped: true); vector39.Y *= lerpValue5; Vector4 vector40 = lightColor.ToVector4(); diff --git a/Projectiles/Healing/ManaPolarizerHealOrb.cs b/Projectiles/Healing/ManaPolarizerHealOrb.cs index 373c1b9518..c2dbdacf55 100644 --- a/Projectiles/Healing/ManaPolarizerHealOrb.cs +++ b/Projectiles/Healing/ManaPolarizerHealOrb.cs @@ -24,7 +24,7 @@ namespace CalamityMod.Projectiles.Healing public override void AI() { - Projectile.HealingProjectile((int)Projectile.ai[1], (int)Projectile.ai[0], 3f, 15f); + Projectile.HealingProjectile((int)Projectile.ai[1], (int)Projectile.ai[0], 4f, 15f); int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.SpectreStaff, 0f, 0f, 100); Main.dust[dust].noGravity = true; Main.dust[dust].velocity *= 0f; diff --git a/Projectiles/Magic/AetherfluxCannonHoldout.cs b/Projectiles/Magic/AetherfluxCannonHoldout.cs index 94e57a3010..69891cace5 100644 --- a/Projectiles/Magic/AetherfluxCannonHoldout.cs +++ b/Projectiles/Magic/AetherfluxCannonHoldout.cs @@ -1,65 +1,53 @@ using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; +using Terraria.GameContent; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class AetherfluxCannonHoldout : ModProjectile + public class AetherfluxCannonHoldout : BaseGunHoldoutProjectile { - public override LocalizedText DisplayName => CalamityUtils.GetItemName(); - private const int FramesPerFireRateIncrease = 36; - - private Player Owner => Main.player[Projectile.owner]; + public override int AssociatedItemID => ModContent.ItemType(); + public override float MaxOffsetLengthFromArm => 10f; + public override float OffsetXUpwards => -15f; + public override float OffsetXDownwards => 10f; + public override float BaseOffsetY => -15f; + public override float OffsetYUpwards => 8f; + public override float OffsetYDownwards => 15f; + public override string Texture => "CalamityMod/Projectiles/Magic/AetherfluxCannonHoldout"; private ref float DeployedFrames => ref Projectile.ai[0]; private ref float AnimationRate => ref Projectile.ai[1]; private ref float LastShootAttemptTime => ref Projectile.localAI[0]; private ref float LastAnimationTime => ref Projectile.localAI[1]; - public override void SetStaticDefaults() - { - Main.projFrames[Projectile.type] = 8; - } + public override void SetStaticDefaults() => Main.projFrames[Type] = 8; - public override void SetDefaults() + public override void KillHoldoutLogic() { - Projectile.width = 58; - Projectile.height = 94; - Projectile.friendly = true; - Projectile.penetrate = -1; - Projectile.tileCollide = false; - Projectile.ignoreWater = true; - Projectile.DamageType = DamageClass.Magic; - } - - public override void AI() - { - Vector2 armPosition = Owner.RotatedRelativePoint(Owner.MountedCenter, true); - Vector2 gunBarrelPos = armPosition + Projectile.velocity * Projectile.height * 0.4f; - - // If the player is unable to continue using the holdout, delete it. - if (Owner.CantUseHoldout() || !Owner.HasAmmo(Owner.ActiveItem())) - { + base.KillHoldoutLogic(); + bool actuallyShoot = DeployedFrames >= (HeldItem?.useAnimation ?? AetherfluxCannon.UseTime); + bool manaOK = !actuallyShoot || Owner.CheckMana(Owner.ActiveItem()); + if (!manaOK) Projectile.Kill(); - return; - } + } + public override void HoldoutAI() + { // Play a sound frame 1. if (DeployedFrames <= 0f) - { SoundEngine.PlaySound(SoundID.DD2_DarkMageCastHeal with { Volume = SoundID.DD2_DarkMageCastHeal.Volume * 1.5f }, Projectile.Center); - } // Update damage based on curent magic damage stat (so Mana Sickness affects it) - Item weaponItem = Owner.ActiveItem(); - Projectile.damage = weaponItem is null ? 0 : Owner.GetWeaponDamage(weaponItem); + Projectile.damage = HeldItem is null ? 0 : Owner.GetWeaponDamage(HeldItem); // Get the original weapon's use time. - int itemUseTime = weaponItem?.useAnimation ?? AetherfluxCannon.UseTime; + int itemUseTime = HeldItem?.useAnimation ?? AetherfluxCannon.UseTime; // 36, base use time, will result in 5. Speed increasing reforges push it to 4. int framesPerShot = itemUseTime / 7; @@ -73,7 +61,7 @@ namespace CalamityMod.Projectiles.Magic if (DeployedFrames - LastAnimationTime >= AnimationRate) { LastAnimationTime = DeployedFrames; - Projectile.frame = (Projectile.frame + 1) % Main.projFrames[Projectile.type]; + Projectile.frame = (Projectile.frame + 1) % Main.projFrames[Type]; } // Once past the initial spin-up time, fire constantly as long as mana is available. @@ -89,7 +77,7 @@ namespace CalamityMod.Projectiles.Magic SoundEngine.PlaySound(SoundID.Item91, Projectile.Center); int projID = ModContent.ProjectileType(); - float shootSpeed = weaponItem.shootSpeed; + float shootSpeed = HeldItem.shootSpeed; Vector2 shootDirection = Projectile.velocity.SafeNormalize(Vector2.UnitY); Vector2 shootVelocity = shootDirection * shootSpeed; @@ -102,67 +90,24 @@ namespace CalamityMod.Projectiles.Magic for (int i = -1; i <= 1; i += 2) { - Vector2 laserStartPos = gunBarrelPos + i * perp + Main.rand.NextVector2CircularEdge(6f, 6f); + Vector2 laserStartPos = GunTipPosition + i * perp + Main.rand.NextVector2CircularEdge(6f, 6f); Vector2 dustOnlySpread = Main.rand.NextVector2Circular(shootSpeed, shootSpeed); Vector2 dustVelocity = shootVelocity + dustInaccuracy * dustOnlySpread; - if (actuallyShoot) - { - Projectile godRay = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), laserStartPos, shootVelocity, projID, Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, 0f); - // Tell this Phased God Ray exactly which way it should be waving. - godRay.localAI[1] = i * 0.5f; - } - SpawnFiringDust(gunBarrelPos, dustVelocity); + if (actuallyShoot && Main.myPlayer == Projectile.owner) + Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), laserStartPos, shootVelocity, projID, Projectile.damage, Projectile.knockBack, Projectile.owner, i * 0.5f); + SpawnFiringDust(GunTipPosition, dustVelocity); } } - - // Delete the laser gun if a mana cost cannot be paid. - else - { - Projectile.Kill(); - return; - } } - - UpdateProjectileHeldVariables(armPosition); - ManipulatePlayerVariables(); } - private void UpdateProjectileHeldVariables(Vector2 armPosition) - { - if (Main.myPlayer == Projectile.owner) - { - float interpolant = Utils.GetLerpValue(5f, 25f, Projectile.Distance(Main.MouseWorld), true); - Vector2 oldVelocity = Projectile.velocity; - Projectile.velocity = Vector2.Lerp(Projectile.velocity, Projectile.SafeDirectionTo(Main.MouseWorld), interpolant); - if (Projectile.velocity != oldVelocity) - { - Projectile.netSpam = 0; - Projectile.netUpdate = true; - } - } - - Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; - Projectile.Center = armPosition + Projectile.velocity.SafeNormalize(Vector2.UnitX * Owner.direction) * 8f; - Projectile.spriteDirection = Projectile.direction; - Projectile.timeLeft = 2; - } - - private void ManipulatePlayerVariables() - { - Owner.ChangeDir(Projectile.direction); - Owner.heldProj = Projectile.whoAmI; - Owner.itemTime = 2; - Owner.itemAnimation = 2; - Owner.itemRotation = (Projectile.velocity * Projectile.direction).ToRotation(); - } - - private void SpawnFiringDust(Vector2 gunBarrelPos, Vector2 laserVelocity) + private void SpawnFiringDust(Vector2 GunTipPosition, Vector2 laserVelocity) { int dustID = 133; int dustRadius = 12; float dustRandomness = 11f; int dustDiameter = 2 * dustRadius; - Vector2 dustCorner = gunBarrelPos - Vector2.One * dustRadius; + Vector2 dustCorner = GunTipPosition - Vector2.One * dustRadius; for (int i = 0; i < 2; i++) { Vector2 dustVel = laserVelocity + Main.rand.NextVector2Circular(dustRandomness, dustRandomness); @@ -173,9 +118,18 @@ namespace CalamityMod.Projectiles.Magic } } - public override bool? CanDamage() => false; + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = TextureAssets.Projectile[Type].Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + Rectangle frame = texture.Frame(verticalFrames: Main.projFrames[Type], frameY: Projectile.frame); + float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f) + MathHelper.PiOver2; + Vector2 rotationPoint = frame.Size() * 0.5f; + SpriteEffects flipSprite = (Projectile.spriteDirection * Owner.gravDir == -1) ? SpriteEffects.FlipVertically : SpriteEffects.None; - // prevents the item from appearing backwards frame 1 - public override bool PreDraw(ref Color lightColor) => FramesPerFireRateIncrease > 0f; + Main.EntitySpriteDraw(texture, drawPosition, frame, Projectile.GetAlpha(lightColor), drawRotation, rotationPoint, Projectile.scale * Owner.gravDir, flipSprite); + + return false; + } } } diff --git a/Projectiles/Magic/GenesisBeam.cs b/Projectiles/Magic/GenesisBeam.cs index a1b782a551..1290158ebd 100644 --- a/Projectiles/Magic/GenesisBeam.cs +++ b/Projectiles/Magic/GenesisBeam.cs @@ -2,8 +2,8 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; -using Terraria.ID; using Terraria.ModLoader; +using Terraria.WorldBuilding; namespace CalamityMod.Projectiles.Magic { @@ -11,11 +11,17 @@ namespace CalamityMod.Projectiles.Magic { public new string LocalizationCategory => "Projectiles.Magic"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - public ref float time => ref Projectile.ai[0]; - public ref float isSplit => ref Projectile.ai[1]; - public bool splitShot = false; - public Color mainColor = Color.MediumSlateBlue; + public ref float Time => ref Projectile.ai[0]; + public ref float IsSplit => ref Projectile.ai[1]; + public bool SplitShot + { + get => Projectile.ai[2] == 1f; + set => Projectile.ai[2] = value == true ? 1f : 0f; + } + + public Color MainColor { get; set; } = Color.MediumSlateBlue; + public override void SetDefaults() { Projectile.width = 12; @@ -26,51 +32,57 @@ namespace CalamityMod.Projectiles.Magic Projectile.usesIDStaticNPCImmunity = true; Projectile.idStaticNPCHitCooldown = 31; Projectile.penetrate = -1; - Projectile.extraUpdates = 75; + Projectile.extraUpdates = 10; Projectile.timeLeft = 20; } + public override void AI() { - if (isSplit == 0) - splitShot = true; - if (time == 0) + if (IsSplit == 0) + SplitShot = true; + + if (Time == 0) { - if (splitShot) + if (SplitShot) Projectile.penetrate = 1; else Projectile.timeLeft = 50; } - if (Projectile.timeLeft % 2 == 0 && (!splitShot && time > 2 || (splitShot && time > 3 && Projectile.timeLeft > 2))) + if (Projectile.timeLeft < (SplitShot ? 20 : 50)) { - Particle spark = new GlowSparkParticle(Projectile.Center, -Projectile.velocity * 0.05f, false, 17, 0.06f, mainColor, new Vector2(0.5f, 1.3f)); + Particle spark = new GlowSparkParticle(Projectile.Center, -Projectile.velocity * 0.05f, false, 17, 0.06f, MainColor, new Vector2(0.5f, 1.3f)); GeneralParticleHandler.SpawnParticle(spark); } Vector2 dustVel = new Vector2(2, 2).RotatedByRandom(100) * Main.rand.NextFloat(0.1f, 0.8f); Dust dust = Dust.NewDustPerfect(Projectile.Center + dustVel, Main.rand.NextBool(4) ? 264 : 66, dustVel, 0, default, Main.rand.NextFloat(0.9f, 1.2f)); dust.noGravity = true; - dust.color = Main.rand.NextBool() ? Color.Lerp(mainColor, Color.White, 0.5f) : mainColor; + dust.color = Main.rand.NextBool() ? Color.Lerp(MainColor, Color.White, 0.5f) : MainColor; - time++; + Time++; } + public override void OnKill(int timeLeft) { int numProj = 2; - float rotation = MathHelper.ToRadians(20); - if (splitShot) + float rotation = MathHelper.ToRadians(12); + if (SplitShot) { for (int i = 0; i < numProj; i++) { Vector2 perturbedSpeed = Projectile.velocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (numProj - 1))); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, perturbedSpeed, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, 1f); - for (int k = 0; k < 3; k++) - { - Particle blastRing = new CustomPulse(Projectile.Center, Vector2.Zero, mainColor, "CalamityMod/Particles/BloomCircle", Vector2.One, Main.rand.NextFloat(-10, 10), 0.5f, 0.4f, 35); - GeneralParticleHandler.SpawnParticle(blastRing); - Particle blastRing2 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.White, "CalamityMod/Particles/BloomCircle", Vector2.One, Main.rand.NextFloat(-10, 10), 0.4f, 0.3f, 35); - GeneralParticleHandler.SpawnParticle(blastRing2); - } + + if (Main.myPlayer == Projectile.owner) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, perturbedSpeed, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, 1f); + } + + for (int k = 0; k < 3; k++) + { + Particle blastRing = new CustomPulse(Projectile.Center, Vector2.Zero, MainColor, "CalamityMod/Particles/BloomCircle", Vector2.One, Main.rand.NextFloat(-10, 10), 0.5f, 0.4f, 35); + GeneralParticleHandler.SpawnParticle(blastRing); + Particle blastRing2 = new CustomPulse(Projectile.Center, Vector2.Zero, Color.White, "CalamityMod/Particles/BloomCircle", Vector2.One, Main.rand.NextFloat(-10, 10), 0.4f, 0.3f, 35); + GeneralParticleHandler.SpawnParticle(blastRing2); } for (int i = 0; i < 20; i++) @@ -78,7 +90,7 @@ namespace CalamityMod.Projectiles.Magic Vector2 dustVel = new Vector2(13, 13).RotatedByRandom(100) * Main.rand.NextFloat(0.1f, 0.8f); Dust dust = Dust.NewDustPerfect(Projectile.Center + dustVel, Main.rand.NextBool(4) ? 264 : 66, dustVel, 0, default, Main.rand.NextFloat(0.9f, 1.2f)); dust.noGravity = true; - dust.color = Main.rand.NextBool() ? Color.Lerp(mainColor, Color.White, 0.5f) : mainColor; + dust.color = Main.rand.NextBool() ? Color.Lerp(MainColor, Color.White, 0.5f) : MainColor; } } else @@ -88,16 +100,18 @@ namespace CalamityMod.Projectiles.Magic Vector2 dustVel = Projectile.velocity * Main.rand.NextFloat(0.1f, 1.5f); Dust dust = Dust.NewDustPerfect(Projectile.Center + dustVel + Main.rand.NextVector2Circular(6, 6), Main.rand.NextBool(4) ? 264 : 66, dustVel, 0, default, Main.rand.NextFloat(0.9f, 1.2f)); dust.noGravity = true; - dust.color = Main.rand.NextBool() ? Color.Lerp(mainColor, Color.White, 0.5f) : mainColor; + dust.color = Main.rand.NextBool() ? Color.Lerp(MainColor, Color.White, 0.5f) : MainColor; } } - } - public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) - { - if (splitShot) // This is the sweet spot - { - modifiers.SourceDamage *= 1.5f; + Projectile.netSpam = 0; + Projectile.netUpdate = true; + } + + public void OnHitEffects() + { + if (SplitShot) // This is the sweet spot + { int points = 10; float radians = MathHelper.TwoPi / points; Vector2 spinningPoint = Vector2.Normalize(new Vector2(-1f, -1f)); @@ -105,13 +119,24 @@ namespace CalamityMod.Projectiles.Magic for (int k = 0; k < points; k++) { Vector2 velocity = spinningPoint.RotatedBy(radians * k).RotatedBy(-0.45f * rotRando); - Particle subTrail = new GlowSparkParticle(Projectile.Center + velocity * 10.5f, velocity * 5, false, 10, 0.045f, mainColor, new Vector2(2, 0.4f), true); + Particle subTrail = new GlowSparkParticle(Projectile.Center + velocity * 10.5f, velocity * 5, false, 10, 0.045f, MainColor, new Vector2(2, 0.4f), true); GeneralParticleHandler.SpawnParticle(subTrail); } SoundStyle fire = new("CalamityMod/Sounds/Item/ArcNovaDiffuserChargeImpact"); SoundEngine.PlaySound(fire with { Volume = 1.25f, Pitch = 0.4f, PitchVariance = 0.15f }, Projectile.Center); } + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => OnHitEffects(); + + public override void OnHitPlayer(Player target, Player.HurtInfo info) => OnHitEffects(); + + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + if (SplitShot) + modifiers.SourceDamage *= 1.5f; + if (Projectile.numHits > 0) Projectile.damage = (int)(Projectile.damage * 0.95f); if (Projectile.damage < 1) diff --git a/Projectiles/Magic/GenesisHoldout.cs b/Projectiles/Magic/GenesisHoldout.cs index 5f25eaeac0..d0d83c08e1 100644 --- a/Projectiles/Magic/GenesisHoldout.cs +++ b/Projectiles/Magic/GenesisHoldout.cs @@ -1,12 +1,13 @@ -using CalamityMod.Items.Weapons.Magic; +using System.IO; +using CalamityMod.Items.Weapons.Magic; using CalamityMod.Particles; using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; -using ReLogic.Utilities; using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; +using static CalamityMod.Items.Weapons.Magic.Genesis; namespace CalamityMod.Projectiles.Magic { @@ -19,78 +20,68 @@ namespace CalamityMod.Projectiles.Magic public override float BaseOffsetY => -5f; public override float OffsetYDownwards => 5f; - public Color StaticEffectsColor = Color.MediumSlateBlue; + public ref float ShootingTimer => ref Projectile.ai[0]; + public ref float MaxFirerateShots => ref Projectile.ai[1]; + public bool FireYBeam + { + get => Projectile.ai[2] == 1f; + set => Projectile.ai[2] = value == true ? 1f : 0f; + } - public float FiringTime = 15; - public float Windup = 60; - public bool WindingUp = false; - public int time = 0; - public bool fireYBeam = false; - public int maxFirerateShots = 0; - - private ref float ShootingTimer => ref Projectile.ai[0]; + public float Windup { get; set; } = StarterWindup; + public Color EffectsColor { get; set; } = Color.MediumSlateBlue; public override void KillHoldoutLogic() { - if (HeldItem.type != Owner.ActiveItem().type || Owner is null || !Owner.active || Owner.CCed || Owner.dead || Owner.noItems) - { + if (HeldItem.type != Owner.ActiveItem().type || Owner.CantUseHoldout()) Projectile.Kill(); - Projectile.netUpdate = true; - } } public override void HoldoutAI() { - Item heldItem = Owner.ActiveItem(); - // Fire if the owner stops channeling or otherwise cannot use the weapon. - if (Owner.CantUseHoldout()) + if (ShootingTimer >= FireRate) { - Projectile.Kill(); - } - else if (ShootingTimer >= FiringTime) - { - if (Owner.CheckMana(Owner.ActiveItem(), -1, true, false)) + if (Owner.CheckMana(HeldItem, -1, true, false)) { - maxFirerateShots++; + MaxFirerateShots++; - if (maxFirerateShots == 6) + if (MaxFirerateShots == 6f) { - fireYBeam = true; - Windup = 60; + FireYBeam = true; + Windup = 60f; } - if (fireYBeam) - { - Shoot(heldItem, true); - maxFirerateShots = 0; + if (FireYBeam) + { + Shoot(true); + MaxFirerateShots = 0f; } else - Shoot(heldItem, false); + Shoot(false); - ShootingTimer = 0; - - if (Windup > 10) + ShootingTimer = 0f; + + if (Windup > 10f) { - if (!fireYBeam) - Windup -= 12; + if (!FireYBeam) + Windup -= 12f; } else - { - Windup = 10; - } + Windup = 10f; - fireYBeam = false; + FireYBeam = false; } else { SoundEngine.PlaySound(SoundID.MaxMana with { Pitch = -0.5f }, Projectile.Center); Projectile.Kill(); } - } + ShootingTimer++; } - private void Shoot(Item item, bool yBeam) + + public void Shoot(bool yBeam) { Vector2 shootDirection = Projectile.velocity.SafeNormalize(Vector2.Zero); @@ -105,13 +96,14 @@ namespace CalamityMod.Projectiles.Magic SoundStyle fire = new("CalamityMod/Sounds/Item/LanceofDestinyStrong"); SoundEngine.PlaySound(fire with { Volume = 0.35f, Pitch = 1f, PitchVariance = 0.15f }, Projectile.Center); - Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, firingVelocity3, ModContent.ProjectileType(), Projectile.damage * 9, Projectile.knockBack, Projectile.owner, 0, 0); + if (Main.myPlayer == Projectile.owner) + Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, firingVelocity3, ModContent.ProjectileType(), Projectile.damage * 9, Projectile.knockBack, Projectile.owner, 0, 0); - Particle pulse3 = new GlowSparkParticle(GunTipPosition, shootDirection * 18, false, 6, 0.057f, StaticEffectsColor, new Vector2(1.7f, 0.8f), true); + Particle pulse3 = new GlowSparkParticle(GunTipPosition, shootDirection * 18, false, 6, 0.057f, EffectsColor, new Vector2(1.7f, 0.8f), true); GeneralParticleHandler.SpawnParticle(pulse3); for (int i = 0; i < 8; i++) { - SparkParticle spark2 = new SparkParticle(GunTipPosition + Main.rand.NextVector2Circular(10, 10), firingVelocity3 * Main.rand.NextFloat(0.7f, 1.3f), false, Main.rand.Next(20, 30), Main.rand.NextFloat(0.4f, 0.55f), StaticEffectsColor); + SparkParticle spark2 = new SparkParticle(GunTipPosition + Main.rand.NextVector2Circular(10, 10), firingVelocity3 * Main.rand.NextFloat(0.7f, 1.3f), false, Main.rand.Next(20, 30), Main.rand.NextFloat(0.4f, 0.55f), EffectsColor); GeneralParticleHandler.SpawnParticle(spark2); } } @@ -123,15 +115,19 @@ namespace CalamityMod.Projectiles.Magic for (int i = 0; i < 4; i++) { firingVelocity3 = (shootDirection * 10).RotatedBy((0.05f * (i + 1)) * Utils.GetLerpValue(0, 55, Windup, true)); - Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, firingVelocity3 * (1 - i * 0.1f), ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0, 1); + + if (Main.myPlayer == Projectile.owner) + Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, firingVelocity3 * (1 - i * 0.1f), ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0, 1); } for (int i = 0; i < 4; i++) { firingVelocity3 = (shootDirection * 10).RotatedBy((-0.05f * (i + 1)) * Utils.GetLerpValue(0, 55, Windup, true)); - Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, firingVelocity3 * (1 - i * 0.1f), ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0, 1); + + if (Main.myPlayer == Projectile.owner) + Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, firingVelocity3 * (1 - i * 0.1f), ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0, 1); } - Particle pulse3 = new GlowSparkParticle(GunTipPosition, shootDirection * 18, false, 6, 0.057f, StaticEffectsColor, new Vector2(1.7f, 0.8f), true); + Particle pulse3 = new GlowSparkParticle(GunTipPosition, shootDirection * 18, false, 6, 0.057f, EffectsColor, new Vector2(1.7f, 0.8f), true); GeneralParticleHandler.SpawnParticle(pulse3); } @@ -147,7 +143,7 @@ namespace CalamityMod.Projectiles.Magic Dust dust2 = Dust.NewDustPerfect(GunTipPosition, Main.rand.NextBool(4) ? 267 : 66, shootVel); dust2.scale = Main.rand.NextFloat(1.15f, 1.45f); dust2.noGravity = true; - dust2.color = Main.rand.NextBool() ? Color.Lerp(StaticEffectsColor, Color.White, 0.5f) : StaticEffectsColor; + dust2.color = Main.rand.NextBool() ? Color.Lerp(EffectsColor, Color.White, 0.5f) : EffectsColor; } // By decreasing the offset length of the gun from the arms, we give an effect of recoil. @@ -156,5 +152,9 @@ namespace CalamityMod.Projectiles.Magic else OffsetLengthFromArm -= 5f; } + + public override void SendExtraAIHoldout(BinaryWriter writer) => writer.Write(Windup); + + public override void ReceiveExtraAIHoldout(BinaryReader reader) => Windup = reader.ReadSingle(); } } diff --git a/Projectiles/Magic/MeteorStar.cs b/Projectiles/Magic/MeteorStar.cs index e123f24b7b..c2292cb1bb 100644 --- a/Projectiles/Magic/MeteorStar.cs +++ b/Projectiles/Magic/MeteorStar.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using System; using Terraria; using Terraria.Audio; using Terraria.ID; @@ -10,6 +11,8 @@ namespace CalamityMod.Projectiles.Magic public class MeteorStar : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Magic"; + public Player Owner => Main.player[Projectile.owner]; + public override void SetStaticDefaults() { ProjectileID.Sets.TrailCacheLength[Projectile.type] = 5; @@ -22,128 +25,80 @@ namespace CalamityMod.Projectiles.Magic Projectile.width = 42; Projectile.height = 34; Projectile.friendly = true; + Projectile.tileCollide = false; Projectile.DamageType = DamageClass.Magic; Projectile.timeLeft = 361; } public override void AI() { - Player player = Main.player[Projectile.owner]; - bool flippedGravity = player.gravDir == -1f; - Projectile.frameCounter++; - if (Projectile.frameCounter > 6) - { - Projectile.frame++; - Projectile.frameCounter = 0; - } - if (Projectile.frame >= Main.projFrames[Projectile.type]) - { - Projectile.frame = 0; - } - - Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.5f / 255f, (255 - Projectile.alpha) * 0.5f / 255f, (255 - Projectile.alpha) * 0.15f / 255f); + Projectile.frame = Projectile.frameCounter / 6 % Main.projFrames[Projectile.type]; + Color LightYellow = new Color(255, 255, 76); + Lighting.AddLight(Projectile.Center, LightYellow.ToVector3() * Projectile.Opacity * 0.5f); bool explodingSoon = Projectile.timeLeft <= 120; if (Projectile.soundDelay <= 0) { - Projectile.soundDelay = 30 + Main.rand.Next(40); - if (explodingSoon) - Projectile.soundDelay -= 30; - if (Main.rand.NextBool(10) || explodingSoon) - { + Projectile.soundDelay = 30 + Main.rand.Next(explodingSoon ? 10 : 40); + if (Main.rand.NextBool(4) || explodingSoon) SoundEngine.PlaySound(SoundID.Item9, Projectile.Center); - } } - if ((Main.rand.NextBool(20) || explodingSoon) && Main.rand.NextBool(3) && Main.netMode != NetmodeID.Server) + if ((Main.rand.NextBool(12) || (explodingSoon && Main.rand.NextBool(3))) && Main.netMode != NetmodeID.Server) { - int idx = Gore.NewGore(Projectile.GetSource_FromAI(), Projectile.Center, Projectile.velocity * 0.2f, Main.rand.Next(16, 18), 1f); - Main.gore[idx].velocity *= 0.66f; - Main.gore[idx].velocity += Projectile.velocity * 0.3f; + Gore star = Gore.NewGoreDirect(Projectile.GetSource_FromAI(), Projectile.Center, Projectile.velocity * 0.2f, Main.rand.Next(16, 18), 1f); + star.velocity *= 0.66f; + star.velocity += Projectile.velocity * 0.3f; } if (explodingSoon) { for (int i = 0; i < 3; i++) { - int smoke = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Smoke, 0f, 0f, 100, default, 2f); - Dust dust = Main.dust[smoke]; - dust.velocity *= 0.3f; - dust.position.X = Projectile.Center.X + 4f + Main.rand.NextFloat(-6f, 6f); - dust.position.Y = Projectile.Center.Y + Main.rand.NextFloat(-6f, 6f); - dust.noGravity = true; + Dust smoke = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, DustID.Smoke, 0f, 0f, 100, default, 2f); + smoke.velocity *= 0.3f; + smoke.position.X = Projectile.Center.X + 4f + Main.rand.NextFloat(-6f, 6f); + smoke.position.Y = Projectile.Center.Y + Main.rand.NextFloat(-6f, 6f); + smoke.noGravity = true; } } if (Main.myPlayer == Projectile.owner) { - if (player.channel) + // Initialize position + if (Projectile.ai[2] != 1f) { - float speed = 14f; - float mouseDistX = (float)Main.mouseX + Main.screenPosition.X - Projectile.Center.X; - float mouseDistY = (float)Main.mouseY + Main.screenPosition.Y - Projectile.Center.Y; - if (player.gravDir == -1f) - { - mouseDistY = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - Projectile.Center.Y; - } - Vector2 mouseVec = new Vector2(mouseDistX, mouseDistY); - float mouseDist = mouseVec.Length(); - if (mouseDist > speed) - { - mouseDist = speed / mouseDist; - mouseVec.X *= mouseDist; - mouseVec.Y *= mouseDist; - int mouseSpeedX = (int)(mouseVec.X * 1000f); - int projSpeedX = (int)(Projectile.velocity.X * 1000f); - int mouseSpeedY = (int)(mouseVec.Y * 1000f); - int projSpeedY = (int)(Projectile.velocity.Y * 1000f); - if (mouseSpeedX != projSpeedX || mouseSpeedY != projSpeedY) - { - Projectile.netUpdate = true; - } - Projectile.velocity.X = mouseVec.X; - Projectile.velocity.Y = mouseVec.Y; - } + if (Owner.gravDir == -1f) + Projectile.Center = Owner.Top; else - { - int mouseSpeedX = (int)(mouseVec.X * 1000f); - int projSpeedX = (int)(Projectile.velocity.X * 1000f); - int mouseSpeedY = (int)(mouseVec.Y * 1000f); - int projSpeedY = (int)(Projectile.velocity.Y * 1000f); - if (mouseSpeedX != projSpeedX || mouseSpeedY != projSpeedY) - { - Projectile.netUpdate = true; - } - Projectile.velocity.X = mouseVec.X; - Projectile.velocity.Y = mouseVec.Y; - } - player.ChangeDir((int)Projectile.velocity.X); - player.velocity = Projectile.velocity; - if (Projectile.velocity.Y > 16f) - { - Projectile.velocity.Y = 16f; - player.velocity.Y = 16f; - } - if (player.mount != null) - { - player.mount.Dismount(player); - } - if (!flippedGravity) - player.Bottom = Projectile.Center; + Projectile.Center = Owner.Bottom; + + Projectile.ai[2] = 1f; + Projectile.netUpdate = true; + Projectile.netSpam = 0; + } + if (Owner.channel) + { + Owner.mount?.Dismount(Owner); + Owner.RemoveAllGrapplingHooks(); + + Projectile.velocity = Owner.SafeDirectionTo(Owner.Calamity().mouseWorld) * 14f; + Owner.velocity = Projectile.velocity; + Owner.ChangeDir(Math.Sign(Projectile.velocity.X) <= 0 ? -1 : 1); + + // Move the player to the projectile, allowing them to bypass platforms + if (Owner.gravDir == -1f) + Owner.Top = Projectile.Center; else - player.Top = Projectile.Center; + Owner.Bottom = Projectile.Center; } else - { Explode(true); - } } - Projectile.tileCollide = Projectile.velocity != Vector2.Zero && ++Projectile.ai[0] >= 5f; - // Die immediately if the owner of this projectile is clipping into tiles because of its movement. - if (Collision.SolidCollision(player.position, player.width, player.height) && Projectile.velocity != Vector2.Zero) + if (Collision.SolidCollision(Owner.position, Owner.width, Owner.height) && Projectile.velocity != Vector2.Zero) { - player.velocity.Y = 0f; + Owner.velocity.Y = 0f; Explode(); } @@ -155,27 +110,14 @@ namespace CalamityMod.Projectiles.Magic public override void OnHitPlayer(Player target, Player.HurtInfo info) => Explode(); - public override bool OnTileCollide(Vector2 oldVelocity) - { - Explode(); - return base.OnTileCollide(oldVelocity); - } - public override bool PreDraw(ref Color lightColor) { CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1); // Draw the main texture in fullbright Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value; - - int frameHeight = texture.Height / Main.projFrames[Projectile.type]; - int frameY = frameHeight * Projectile.frame; - float scale = Projectile.scale; - float rotation = Projectile.rotation; - - Rectangle rectangle = new Rectangle(0, frameY, texture.Width, frameHeight); - Vector2 origin = rectangle.Size() / 2f; - Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), rectangle, Color.White, rotation, origin, scale, SpriteEffects.None, 0); + Rectangle frame = texture.Frame(1, Main.projFrames[Type], 0, Projectile.frame); + Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition, frame, Color.White, Projectile.rotation, frame.Size() * 0.5f, Projectile.scale, SpriteEffects.None); return false; } @@ -191,12 +133,12 @@ namespace CalamityMod.Projectiles.Magic for (int i = 0; i < 10; i++) { - int idx = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Smoke, 0f, 0f, 100, default, 1.2f); - Main.dust[idx].velocity *= 3f; + Dust smoke = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, DustID.Smoke, 0f, 0f, 100, default, 1.2f); + smoke.velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[idx].scale = 0.5f; - Main.dust[idx].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + smoke.scale = 0.5f; + smoke.fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } if (Main.netMode != NetmodeID.Server) @@ -208,5 +150,11 @@ namespace CalamityMod.Projectiles.Magic } Projectile.Kill(); } + + public override void OnKill(int timeLeft) + { + Owner.velocity *= 0.8f; + Owner.fullRotation = 0f; + } } } diff --git a/Projectiles/Magic/NanoPurgeHoldout.cs b/Projectiles/Magic/NanoPurgeHoldout.cs index b68d0f826f..4127860c0a 100644 --- a/Projectiles/Magic/NanoPurgeHoldout.cs +++ b/Projectiles/Magic/NanoPurgeHoldout.cs @@ -1,57 +1,52 @@ -using CalamityMod.Items.Weapons.Magic; +using System; +using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.GameContent; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class NanoPurgeHoldout : ModProjectile + public class NanoPurgeHoldout : BaseGunHoldoutProjectile { - public override LocalizedText DisplayName => CalamityUtils.GetItemName(); + public override int AssociatedItemID => ModContent.ItemType(); + public override string Texture => "CalamityMod/Projectiles/Magic/NanoPurgeHoldout"; + public override float MaxOffsetLengthFromArm => 10f; + public override float OffsetXUpwards => -15f; + public override float OffsetXDownwards => 5f; + public override float BaseOffsetY => -10f; + public override float OffsetYUpwards => 5f; + public override float OffsetYDownwards => 10f; + private const int FramesPerFireRateIncrease = 36; private static int[] LaserOffsetByAnimationFrame = { 4, 3, 0, 3 }; - private Player Owner => Main.player[Projectile.owner]; private ref float DeployedFrames => ref Projectile.ai[0]; private ref float ChargeTowardsNextShot => ref Projectile.ai[1]; - public override void SetStaticDefaults() - { - Main.projFrames[Projectile.type] = 4; - } + public override void SetStaticDefaults() => Main.projFrames[Type] = 4; - public override void SetDefaults() + public override void KillHoldoutLogic() { - Projectile.width = 34; - Projectile.height = 62; - Projectile.friendly = true; - Projectile.penetrate = -1; - Projectile.tileCollide = false; - Projectile.ignoreWater = true; - Projectile.DamageType = DamageClass.Magic; - } - - public override void AI() - { - Vector2 armPosition = Owner.RotatedRelativePoint(Owner.MountedCenter, true); - Vector2 gunBarrelPos = armPosition + Projectile.velocity * Projectile.height * 0.5f; - - // If the player is unable to continue using the holdout, delete it. - if (Owner.CantUseHoldout() || !Owner.HasAmmo(Owner.ActiveItem())) - { + base.KillHoldoutLogic(); + bool actuallyShoot = DeployedFrames >= (HeldItem?.useAnimation ?? NanoPurge.UseTime); + bool manaOK = !actuallyShoot || Owner.CheckMana(Owner.ActiveItem()); + if (!manaOK) Projectile.Kill(); - return; - } + } + public override void HoldoutAI() + { // Update damage based on curent magic damage stat (so Mana Sickness affects it) - Item weaponItem = Owner.ActiveItem(); - Projectile.damage = weaponItem is null ? 0 : Owner.GetWeaponDamage(weaponItem); + Projectile.damage = HeldItem is null ? 0 : Owner.GetWeaponDamage(HeldItem); // Get the original weapon's use time. - int itemUseTime = weaponItem?.useAnimation ?? NanoPurge.UseTime; + int itemUseTime = HeldItem?.useAnimation ?? NanoPurge.UseTime; // Update time. DeployedFrames += 1f; @@ -76,7 +71,7 @@ namespace CalamityMod.Projectiles.Magic SoundEngine.PlaySound(SoundID.Item91, Projectile.Center); int projID = ModContent.ProjectileType(); - float shootSpeed = weaponItem.shootSpeed; + float shootSpeed = HeldItem.shootSpeed; float inaccuracyRatio = 0.045f; Vector2 shootDirection = Projectile.velocity.SafeNormalize(Vector2.UnitY); Vector2 perp = shootDirection.RotatedBy(MathHelper.PiOver2); @@ -86,59 +81,22 @@ namespace CalamityMod.Projectiles.Magic { Vector2 spread = Main.rand.NextVector2CircularEdge(shootSpeed, shootSpeed); Vector2 shootVelocity = shootDirection * shootSpeed + inaccuracyRatio * spread; - Vector2 splitBarrelPos = gunBarrelPos + i * LaserOffsetByAnimationFrame[Projectile.frame] * perp; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), splitBarrelPos, shootVelocity, projID, Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, 0f); + Vector2 splitBarrelPos = GunTipPosition + i * LaserOffsetByAnimationFrame[Projectile.frame] * perp; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), splitBarrelPos, shootVelocity, projID, Projectile.damage, Projectile.knockBack, Projectile.owner); SpawnFiringDust(splitBarrelPos, shootVelocity); } } - - // Delete the laser gun if a mana cost cannot be paid. - else - { - Projectile.Kill(); - return; - } } - UpdateProjectileHeldVariables(armPosition); - ManipulatePlayerVariables(); + ExtraBackArmRotation = Utils.Remap(Vector2.Dot(-Vector2.UnitY, Projectile.velocity.SafeNormalize(-Vector2.UnitY)), 0f, 1f, MathHelper.PiOver4, 0f); } - private void UpdateProjectileHeldVariables(Vector2 armPosition) - { - if (Main.myPlayer == Projectile.owner) - { - float interpolant = Utils.GetLerpValue(5f, 25f, Projectile.Distance(Main.MouseWorld), true); - Vector2 oldVelocity = Projectile.velocity; - Projectile.velocity = Vector2.Lerp(Projectile.velocity, Projectile.SafeDirectionTo(Main.MouseWorld), interpolant); - if (Projectile.velocity != oldVelocity) - { - Projectile.netSpam = 0; - Projectile.netUpdate = true; - } - } - - Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; - Projectile.Center = armPosition + Projectile.velocity.SafeNormalize(Vector2.UnitX * Owner.direction) * 8f; - Projectile.spriteDirection = Projectile.direction; - Projectile.timeLeft = 2; - } - - private void ManipulatePlayerVariables() - { - Owner.ChangeDir(Projectile.direction); - Owner.heldProj = Projectile.whoAmI; - Owner.itemTime = 2; - Owner.itemAnimation = 2; - Owner.itemRotation = (Projectile.velocity * Projectile.direction).ToRotation(); - } - - private void SpawnFiringDust(Vector2 gunBarrelPos, Vector2 laserVelocity) + private void SpawnFiringDust(Vector2 GunTipPosition, Vector2 laserVelocity) { int dustID = 107; int dustRadius = 5; int dustDiameter = 2 * dustRadius; - Vector2 dustCorner = gunBarrelPos - Vector2.One * dustRadius; + Vector2 dustCorner = GunTipPosition - Vector2.One * dustRadius; for (int i = 0; i < 2; i++) { Vector2 dustVel = laserVelocity + Main.rand.NextVector2Circular(7f, 7f); @@ -149,9 +107,24 @@ namespace CalamityMod.Projectiles.Magic } } - public override bool? CanDamage() => false; + public override void OnSpawn(IEntitySource source) + { + base.OnSpawn(source); + FrontArmStretch = Player.CompositeArmStretchAmount.Quarter; + } - // prevents the item from appearing backwards frame 1 - public override bool PreDraw(ref Color lightColor) => DeployedFrames > 0f; + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = TextureAssets.Projectile[Type].Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + Rectangle frame = texture.Frame(verticalFrames: Main.projFrames[Type], frameY: Projectile.frame); + float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f) + MathHelper.PiOver2; + Vector2 rotationPoint = frame.Size() * 0.5f; + SpriteEffects flipSprite = (Projectile.spriteDirection * Owner.gravDir == -1) ? SpriteEffects.FlipVertically : SpriteEffects.None; + + Main.EntitySpriteDraw(texture, drawPosition, frame, Projectile.GetAlpha(lightColor), drawRotation, rotationPoint, Projectile.scale * Owner.gravDir, flipSprite); + + return false; + } } } diff --git a/Projectiles/Magic/OmicronBeam.cs b/Projectiles/Magic/OmicronBeam.cs index ab72615ff1..2c12781212 100644 --- a/Projectiles/Magic/OmicronBeam.cs +++ b/Projectiles/Magic/OmicronBeam.cs @@ -1,8 +1,8 @@ -using CalamityMod.Particles; +using System.IO; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic @@ -11,10 +11,17 @@ namespace CalamityMod.Projectiles.Magic { public new string LocalizationCategory => "Projectiles.Magic"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - public ref float time => ref Projectile.ai[0]; - public Color mainColor = Color.MediumVioletRed; - public bool HitDirect = false; + public ref float time => ref Projectile.ai[0]; + public ref float isSplit => ref Projectile.ai[1]; + public bool splitShot + { + get => Projectile.ai[2] == 1f; + set => Projectile.ai[2] = value == true ? 1f : 0f; + } + public bool HitDirect { get; set; } + public Color mainColor { get; set; } = Color.MediumVioletRed; + public override void SetDefaults() { Projectile.width = 50; @@ -28,15 +35,25 @@ namespace CalamityMod.Projectiles.Magic Projectile.usesIDStaticNPCImmunity = true; Projectile.idStaticNPCHitCooldown = 91; } + public override void AI() { + if (isSplit == 0) + { + Projectile.netSpam = 0; + Projectile.netUpdate = true; + splitShot = true; + } + Player Owner = Main.player[Projectile.owner]; float targetDist = Vector2.Distance(Owner.Center, Projectile.Center); + if (Projectile.timeLeft % 2 == 0 && time > 2 && targetDist < 1400f) { Particle spark = new GlowSparkParticle(Projectile.Center, -Projectile.velocity * 0.05f, false, 25, MathHelper.Clamp(0.34f - time * 0.07f, 0.085f, 0.34f), mainColor, new Vector2(0.5f, 1.3f)); GeneralParticleHandler.SpawnParticle(spark); } + if (Main.rand.NextBool()) { Vector2 trailPos = Projectile.Center; @@ -44,18 +61,26 @@ namespace CalamityMod.Projectiles.Magic Particle Trail = new SparkParticle(trailPos, Projectile.velocity * Main.rand.NextFloat(0.2f, 0.9f), false, Main.rand.Next(40, 50 + 1), trailScale, mainColor); GeneralParticleHandler.SpawnParticle(Trail); } + Vector2 dustVel = new Vector2(2, 2).RotatedByRandom(100) * Main.rand.NextFloat(0.1f, 0.8f); Dust dust = Dust.NewDustPerfect(Projectile.Center + dustVel, Main.rand.NextBool(4) ? 264 : 66, dustVel, 0, default, Main.rand.NextFloat(0.9f, 1.2f)); dust.noGravity = true; dust.color = Main.rand.NextBool() ? Color.Lerp(mainColor, Color.White, 0.5f) : mainColor; time++; + + if (Projectile.numUpdates == 1) + { + Projectile.netSpam = 0; + Projectile.netUpdate = true; + } } + public override void OnKill(int timeLeft) { int numProj = 2; float rotation = MathHelper.ToRadians(10); - if (Projectile.ai[1] == 0 && time < 250 && !HitDirect) + if (splitShot && time < 250 && !HitDirect) { for (int i = 0; i < numProj; i++) { @@ -89,19 +114,22 @@ namespace CalamityMod.Projectiles.Magic dust.color = Main.rand.NextBool() ? Color.Lerp(mainColor, Color.White, 0.5f) : mainColor; } } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { - if (Projectile.ai[1] == 0 && time > 7 && !HitDirect) + if (splitShot && time > 7 && !HitDirect) Projectile.Kill(); Player Owner = Main.player[Projectile.owner]; + for (int i = 0; i <= 8; i++) { Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(4) ? 264 : 66, (Projectile.velocity.SafeNormalize(Vector2.UnitY) * 15f).RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.1f, 0.8f), 0, default, Main.rand.NextFloat(1.2f, 1.6f)); dust.noGravity = true; dust.color = Main.rand.NextBool() ? Color.Lerp(mainColor, Color.White, 0.5f) : mainColor; } - if (time <= 7 && Projectile.ai[1] == 0) // This is the sweet spot + + if (time <= 7 && splitShot) // This is the sweet spot { modifiers.SourceDamage *= 5; @@ -135,6 +163,11 @@ namespace CalamityMod.Projectiles.Magic HitDirect = true; } } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, time <= 7 ? 90 : 20, targetHitbox); + + public override void SendExtraAI(BinaryWriter writer) => writer.Write(HitDirect); + + public override void ReceiveExtraAI(BinaryReader reader) => HitDirect = reader.ReadBoolean(); } } diff --git a/Projectiles/Magic/OmicronHoldout.cs b/Projectiles/Magic/OmicronHoldout.cs index d1884e6c4b..9d3aef3fb7 100644 --- a/Projectiles/Magic/OmicronHoldout.cs +++ b/Projectiles/Magic/OmicronHoldout.cs @@ -1,4 +1,5 @@ -using CalamityMod.Items.Weapons.Magic; +using System.IO; +using CalamityMod.Items.Weapons.Magic; using CalamityMod.Particles; using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; @@ -6,6 +7,7 @@ using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; +using static CalamityMod.Items.Weapons.Magic.Omicron; namespace CalamityMod.Projectiles.Magic { @@ -18,50 +20,30 @@ namespace CalamityMod.Projectiles.Magic public override float BaseOffsetY => -5f; public override float OffsetYDownwards => 5f; - public Color StaticEffectsColor = Color.MediumVioletRed; + public ref float ShootingTimer => ref Projectile.ai[0]; + public ref float PostFireCooldown => ref Projectile.ai[1]; + public ref float MaxFireRateShots => ref Projectile.ai[2]; - public float FiringTime = 15; - public float Windup = 60; - public bool WindingUp = false; - public int time = 0; - public int PostFireCooldown = 0; - public bool fireYBeam = false; - public int maxFirerateShots = 0; - - private ref float ShootingTimer => ref Projectile.ai[0]; + public float Windup { get; set; } = StarterWinup; + public Color EffectsColor { get; set; } = Color.MediumVioletRed; public override void KillHoldoutLogic() { - if (Owner is null || !Owner.active || Owner.CCed || Owner.dead || Owner.noItems) - { - if (PostFireCooldown <= 0) - Projectile.Kill(); - Projectile.netUpdate = true; - } + if (Owner.CantUseHoldout() && PostFireCooldown <= 0) + Projectile.Kill(); } public override void HoldoutAI() { - Item heldItem = Owner.ActiveItem(); - - // Fire if the owner stops channeling or otherwise cannot use the weapon. - if (Owner.CantUseHoldout()) - { - if (PostFireCooldown <= 0) - Projectile.Kill(); - } - if (PostFireCooldown > 0) - { PostFiringCooldown(); - } if (Owner.Calamity().mouseRight && PostFireCooldown <= 0) { - if (Owner.CheckMana(Owner.ActiveItem(), (int)(heldItem.mana * Owner.manaCost) * 16, true, false)) + if (Owner.CheckMana(Owner.ActiveItem(), (int)(HeldItem.mana * Owner.manaCost) * 16, true, false)) { PostFireCooldown = 100; - Shoot(heldItem, true); + Shoot(true); ShootingTimer = 0; } else @@ -74,31 +56,26 @@ namespace CalamityMod.Projectiles.Magic } } } - else if (ShootingTimer >= FiringTime) + else if (ShootingTimer >= FireRate) { if (Owner.CheckMana(Owner.ActiveItem(), -1, true, false) && PostFireCooldown <= 0) { - maxFirerateShots++; + MaxFireRateShots++; - if (maxFirerateShots == 5) + if (MaxFireRateShots == 5) { Windup = 60; - maxFirerateShots = 0; + MaxFireRateShots = 1; } - Shoot(heldItem, false); + Shoot(false); ShootingTimer = 0; - if (Windup > 10) - { - if (maxFirerateShots > 0) - Windup -= 12; - } + if (Windup > 10 && MaxFireRateShots > 0) + Windup -= 12; else - { Windup = 10; - } } else if (PostFireCooldown <= 0) { @@ -107,14 +84,13 @@ namespace CalamityMod.Projectiles.Magic } } + ShootingTimer++; } - private void Shoot(Item item, bool yBeam) + + public void Shoot(bool yBeam) { Vector2 shootDirection = Projectile.velocity.SafeNormalize(Vector2.Zero); - - // Spawns the projectile. - Vector2 firingVelocity1 = (shootDirection * 8).RotatedBy(0.1f * Utils.GetLerpValue(10, 55, Windup, true)); Vector2 firingVelocity2 = (shootDirection * 8).RotatedBy(-0.1f * Utils.GetLerpValue(10, 55, Windup, true)); Vector2 firingVelocity3 = (shootDirection * 10); @@ -126,7 +102,7 @@ namespace CalamityMod.Projectiles.Magic for (int k = 0; k < 6; k++) { - Particle pulse2 = new GlowSparkParticle(GunTipPosition, shootDirection * 28, false, 8, 0.087f, StaticEffectsColor, new Vector2(2.3f, 0.9f), true); + Particle pulse2 = new GlowSparkParticle(GunTipPosition, shootDirection * 28, false, 8, 0.087f, EffectsColor, new Vector2(2.3f, 0.9f), true); GeneralParticleHandler.SpawnParticle(pulse2); } @@ -135,7 +111,7 @@ namespace CalamityMod.Projectiles.Magic for (int i = 0; i < 8; i++) { - SparkParticle spark2 = new SparkParticle(GunTipPosition + Main.rand.NextVector2Circular(10, 10), firingVelocity3 * Main.rand.NextFloat(0.7f, 1.3f), false, Main.rand.Next(20, 30), Main.rand.NextFloat(0.4f, 0.55f), StaticEffectsColor); + SparkParticle spark2 = new SparkParticle(GunTipPosition + Main.rand.NextVector2Circular(10, 10), firingVelocity3 * Main.rand.NextFloat(0.7f, 1.3f), false, Main.rand.Next(20, 30), Main.rand.NextFloat(0.4f, 0.55f), EffectsColor); GeneralParticleHandler.SpawnParticle(spark2); } } @@ -146,16 +122,16 @@ namespace CalamityMod.Projectiles.Magic for (int i = 0; i < 5; i++) { - firingVelocity3 = (shootDirection * 10).RotatedBy((0.04f * (i + 1)) * Utils.GetLerpValue(0, 55, Windup, true)); + firingVelocity3 = (shootDirection * 10).RotatedBy((0.035f * (i + 1)) * Utils.GetLerpValue(0, 55, Windup, true)); Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, firingVelocity3 * (1 - i * 0.1f), ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0, 2); } for (int i = 0; i < 5; i++) { - firingVelocity3 = (shootDirection * 10).RotatedBy((-0.04f * (i + 1)) * Utils.GetLerpValue(0, 55, Windup, true)); + firingVelocity3 = (shootDirection * 10).RotatedBy((-0.035f * (i + 1)) * Utils.GetLerpValue(0, 55, Windup, true)); Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, firingVelocity3 * (1 - i * 0.1f), ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0, 2); } - Particle pulse3 = new GlowSparkParticle(GunTipPosition, shootDirection * 18, false, 6, 0.057f, StaticEffectsColor, new Vector2(1.7f, 0.8f), true); + Particle pulse3 = new GlowSparkParticle(GunTipPosition, shootDirection * 18, false, 6, 0.057f, EffectsColor, new Vector2(1.7f, 0.8f), true); GeneralParticleHandler.SpawnParticle(pulse3); } @@ -171,7 +147,7 @@ namespace CalamityMod.Projectiles.Magic Dust dust2 = Dust.NewDustPerfect(GunTipPosition, Main.rand.NextBool(4) ? 267 : 66, shootVel); dust2.scale = Main.rand.NextFloat(1.15f, 1.45f); dust2.noGravity = true; - dust2.color = Main.rand.NextBool() ? Color.Lerp(StaticEffectsColor, Color.White, 0.5f) : StaticEffectsColor; + dust2.color = Main.rand.NextBool() ? Color.Lerp(EffectsColor, Color.White, 0.5f) : EffectsColor; } // By decreasing the offset length of the gun from the arms, we give an effect of recoil. @@ -180,21 +156,26 @@ namespace CalamityMod.Projectiles.Magic else OffsetLengthFromArm -= 6f; } - private void PostFiringCooldown() + + public void PostFiringCooldown() { Owner.channel = true; if (PostFireCooldown > 0 && Main.rand.NextBool()) { Vector2 smokeVel = new Vector2(0, -8) * Main.rand.NextFloat(0.1f, 1.1f); - Particle smoke = new HeavySmokeParticle(GunTipPosition, smokeVel, StaticEffectsColor, Main.rand.Next(30, 50 + 1), Main.rand.NextFloat(0.1f, 0.4f), 0.5f, Main.rand.NextFloat(-0.2f, 0.2f), Main.rand.NextBool(), required: true); + Particle smoke = new HeavySmokeParticle(GunTipPosition, smokeVel, EffectsColor, Main.rand.Next(30, 50 + 1), Main.rand.NextFloat(0.1f, 0.4f), 0.5f, Main.rand.NextFloat(-0.2f, 0.2f), Main.rand.NextBool(), required: true); GeneralParticleHandler.SpawnParticle(smoke); Dust dust = Dust.NewDustPerfect(GunTipPosition, 303, smokeVel.RotatedByRandom(0.1f), 80, default, Main.rand.NextFloat(0.2f, 0.8f)); dust.noGravity = false; - dust.color = StaticEffectsColor; + dust.color = EffectsColor; } ShootingTimer = 0; PostFireCooldown--; } + + public override void SendExtraAIHoldout(BinaryWriter writer) => writer.Write(Windup); + + public override void ReceiveExtraAIHoldout(BinaryReader reader) => Windup = reader.ReadSingle(); } } diff --git a/Projectiles/Magic/OmicronWingman.cs b/Projectiles/Magic/OmicronWingman.cs index a932b15d32..9b830bea2a 100644 --- a/Projectiles/Magic/OmicronWingman.cs +++ b/Projectiles/Magic/OmicronWingman.cs @@ -1,19 +1,16 @@ using System; +using System.Collections.Generic; +using System.IO; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Particles; -using Humanizer; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using ReLogic.Utilities; using Terraria; using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; -using System.Collections.Generic; -using System.IO; -using CalamityMod.Graphics.Renderers; namespace CalamityMod.Projectiles.Magic { @@ -26,7 +23,6 @@ namespace CalamityMod.Projectiles.Magic private ref float ShootingTimer => ref Projectile.ai[0]; private float FiringTime = 10; private float PostFireCooldown = 0; - private Vector2 MovementOffset; public bool MovingUp = true; public float xOffset = 1; public float yOffset = 0; @@ -42,45 +38,48 @@ namespace CalamityMod.Projectiles.Magic public bool recharging = false; + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Type] = 9; + ProjectileID.Sets.TrailingMode[Type] = 2; + } + public override void SetDefaults() { Projectile.width = Projectile.height = 142; Projectile.tileCollide = false; Projectile.ignoreWater = true; Projectile.netImportant = true; - ProjectileID.Sets.TrailCacheLength[Projectile.type] = 9; - ProjectileID.Sets.TrailingMode[Projectile.type] = 2; Projectile.hide = true; } public override void AI() { + Owner ??= Main.player[Projectile.owner]; + if (time > 1 && Owner.ownedProjectileCounts[ModContent.ProjectileType()] < 1 && PostFireCooldown <= 0) Projectile.Kill(); + Lighting.AddLight(Projectile.Center, StaticEffectsColor.ToVector3() * 0.2f); + if (time == 0) - { - MovingUp = Projectile.ai[2] == 1 ? true : false; - } + MovingUp = Projectile.ai[2] == 1; + firingDelay--; Item heldItem = Owner.ActiveItem(); // Update damage based on curent magic damage stat (so Mana Sickness affects it) Projectile.damage = heldItem is null ? 0 : Owner.GetWeaponDamage(heldItem); - Vector2 tipPosition = Projectile.Center + Projectile.velocity.SafeNormalize(Vector2.Zero).RotatedBy(-0.05f * Projectile.direction) * 12f; // If there's no player, or the player is the server, or the owner's stunned, there'll be no holdout. if (PostFireCooldown == 0 && launchDelay == 0 && Owner.CantUseHoldout() || heldItem.type != ModContent.ItemType()) { - NetUpdate(); if (PostFireCooldown <= 0) Projectile.Kill(); } if (PostFireCooldown > 0) - { PostFiringCooldown(); - } if (launchDelay > 0 || (PostFireCooldown <= 0 && (Owner.Calamity().mouseRight || (firingDelay <= 0 && Projectile.ai[2] == 1 || Projectile.ai[2] == -1)))) { @@ -89,10 +88,10 @@ namespace CalamityMod.Projectiles.Magic { if (launchDelay < 50) launchDelay++; - + if (launchDelay >= 50 && (Owner.CheckMana(Owner.ActiveItem(), (int)(heldItem.mana * Owner.manaCost) * 2, true, false))) { - Shoot(heldItem, true); + Shoot(true); PostFireCooldown = 50; ShootingTimer = 0; launchDelay = 0; @@ -102,13 +101,11 @@ namespace CalamityMod.Projectiles.Magic { if (Owner.CheckMana(Owner.ActiveItem(), -1, false, false)) { - Shoot(heldItem, false); + Shoot(false); ShootingTimer = 0; } else if (PostFireCooldown <= 0) - { Projectile.Kill(); - } } } @@ -119,7 +116,7 @@ namespace CalamityMod.Projectiles.Magic Vector2 ownerToMouse = Owner.Calamity().mouseWorld - ownerPosition; // Deals with the holdout's rotation and direction, the owner's arms, etc. - ManageHoldout(ownerPosition, ownerToMouse); + ManagePlayerProjectileMembers(ownerToMouse); // When we change the distance of the gun from the arms for the recoil, // recover to the original position smoothly. @@ -127,82 +124,66 @@ namespace CalamityMod.Projectiles.Magic OffsetLength = MathHelper.Lerp(OffsetLength, MaxOffsetLength, 0.1f); ShootingTimer++; - - // Inside here go all the things that dedicated servers shouldn't spend resources on. - // Like visuals and sounds. - if (Main.dedServ) - return; - - Vector2 shootDirection = Projectile.velocity.SafeNormalize(Vector2.Zero) * 20; time++; Projectile.soundDelay--; + + Projectile.netSpam = 0; + Projectile.netUpdate = true; } - private void ManageHoldout(Vector2 mountedCenter, Vector2 ownerToMouse) + private void ManagePlayerProjectileMembers(Vector2 ownerToMouse) { Vector2 rotationVector = Projectile.rotation.ToRotationVector2(); float velocityRotation = Projectile.velocity.ToRotation(); - float proximityLookingUpwards = Vector2.Dot(ownerToMouse.SafeNormalize(Vector2.Zero), -Vector2.UnitY); int direction = MathF.Sign(ownerToMouse.X); - - Vector2 armPosition = Owner.RotatedRelativePoint(mountedCenter, true); Vector2 lengthOffset = rotationVector * OffsetLength; - Vector2 armOffset = new Vector2(Utils.Remap(proximityLookingUpwards, -1f, 1f, 0f, -12f) * direction, -10f + Utils.Remap(MathF.Abs(proximityLookingUpwards), 0f, 1f, 0f, proximityLookingUpwards > 0f ? 15f : 0f)); if (time % 30 == 0) - { MovingUp = !MovingUp; - } //xOffset = MathHelper.Lerp(xOffset, placementOffset.X, 0.01f); yOffset = MathHelper.Lerp(yOffset, 150 * (MovingUp ? -1 : 1), (0.085f - (FiringTime * 0.0012f))); Vector2 placementOffset = Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedBy(MathHelper.PiOver2) * (yOffset); - Vector2 location = Owner.MountedCenter + placementOffset; Projectile.Center = lengthOffset + location; - - Projectile.velocity = velocityRotation.AngleTowards(ownerToMouse.ToRotation(), 0.2f).ToRotationVector2(); - Projectile.rotation = (Main.MouseWorld - Projectile.Center).SafeNormalize(Vector2.UnitX).ToRotation(); + Projectile.rotation = (Owner.Calamity().mouseWorld - Projectile.Center).SafeNormalize(Vector2.UnitX).ToRotation(); Projectile.timeLeft = 2; - - Owner.heldProj = Projectile.whoAmI; - Owner.itemTime = Owner.itemAnimation = 2; - Owner.itemRotation = (Projectile.velocity * Projectile.direction).ToRotation(); - Projectile.spriteDirection = Projectile.direction = direction; } - private void Shoot(Item item, bool isGrenade) + private void Shoot(bool isGrenade) { - Vector2 shootDirection = (Main.MouseWorld - Projectile.Center).SafeNormalize(Vector2.UnitX); + Vector2 shootDirection = (Owner.Calamity().mouseWorld - Projectile.Center).SafeNormalize(Vector2.UnitX); // The position of the tip of the gun. Vector2 tipPosition = Projectile.Center + Projectile.velocity.SafeNormalize(Vector2.Zero).RotatedBy(-0.05f * Projectile.direction) * 12f; - // Spawns the projectile. - Vector2 firingVelocity = shootDirection * 10; if (isGrenade) { SoundStyle fire = new("CalamityMod/Sounds/Item/DeadSunExplosion"); SoundEngine.PlaySound(fire with { Volume = 0.2f, Pitch = -0.4f, PitchVariance = 0.2f }, Projectile.Center); - Projectile bomb = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), tipPosition, firingVelocity, ModContent.ProjectileType(), Projectile.damage * 14, Projectile.knockBack * 5, Projectile.owner, 0, 2); - bomb.timeLeft = 530; - Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), tipPosition, firingVelocity * 1.2f, ModContent.ProjectileType(), Projectile.damage * 14, Projectile.knockBack * 5, Projectile.owner, 0, 2); + if (Main.myPlayer == Projectile.owner) + { + Projectile bomb = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), tipPosition, firingVelocity, ModContent.ProjectileType(), Projectile.damage * 14, Projectile.knockBack * 5, Projectile.owner, 0, 2); + bomb.timeLeft = 530; + Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), tipPosition, firingVelocity * 1.2f, ModContent.ProjectileType(), Projectile.damage * 14, Projectile.knockBack * 5, Projectile.owner, 0, 2); + } } else { SoundStyle fire = new("CalamityMod/Sounds/Item/MagnaCannonShot"); SoundEngine.PlaySound(fire with { Volume = 0.25f, Pitch = 1f, PitchVariance = 0.35f }, Projectile.Center); - - Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), tipPosition, firingVelocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0, 2); - Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), tipPosition, firingVelocity.RotatedBy(-0.05) * 0.85f, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0, 2); - Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), tipPosition, firingVelocity.RotatedBy(0.05) * 0.85f, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0, 2); - } - NetUpdate(); + if (Main.myPlayer == Projectile.owner) + { + Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), tipPosition, firingVelocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0, 2); + Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), tipPosition, firingVelocity.RotatedBy(-0.05) * 0.85f, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0, 2); + Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), tipPosition, firingVelocity.RotatedBy(0.05) * 0.85f, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0, 2); + } + } // Inside here go all the things that dedicated servers shouldn't spend resources on. // Like visuals and sounds. @@ -218,6 +199,7 @@ namespace CalamityMod.Projectiles.Magic dust2.noGravity = true; dust2.color = Main.rand.NextBool() ? Color.Lerp(StaticEffectsColor, Color.White, 0.5f) : StaticEffectsColor; } + Particle pulse = new GlowSparkParticle((tipPosition - shootDirection * 14), shootDirection * 20, false, Main.rand.Next(7, 11 + 1), 0.035f, StaticEffectsColor, new Vector2(1.5f, 0.9f), true); GeneralParticleHandler.SpawnParticle(pulse); @@ -227,6 +209,7 @@ namespace CalamityMod.Projectiles.Magic else OffsetLength -= 5f; } + private void PostFiringCooldown() { Owner.channel = true; @@ -242,23 +225,13 @@ namespace CalamityMod.Projectiles.Magic dust.noGravity = false; dust.color = StaticEffectsColor; } + ShootingTimer = 0; firingDelay = 15; PostFireCooldown--; } - private void NetUpdate() - { - Projectile.netUpdate = true; - if (Projectile.netSpam >= 10) - Projectile.netSpam = 9; - } - - public override void OnSpawn(IEntitySource source) - { - Owner = Main.player[Projectile.owner]; - OffsetLength = MaxOffsetLength; - } + public override void OnSpawn(IEntitySource source) => OffsetLength = MaxOffsetLength; // Because we use the velocity as a direction, we don't need it to change its position. public override bool ShouldUpdatePosition() => false; @@ -270,8 +243,7 @@ namespace CalamityMod.Projectiles.Magic if (time <= 0) return false; - Texture2D texture = ModContent.Request("CalamityMod/Items/Weapons/Magic/Wingman").Value; - + Texture2D texture; if (Projectile.ai[2] == 1) texture = ModContent.Request("CalamityMod/Projectiles/Magic/OmicronWingman").Value; else @@ -291,9 +263,29 @@ namespace CalamityMod.Projectiles.Magic return false; } - public override void DrawBehind(int index, List behindNPCsAndTiles, List behindNPCs, List behindProjectiles, List overPlayers, List overWiresUI) + + public override void DrawBehind(int index, List behindNPCsAndTiles, List behindNPCs, List behindProjectiles, List overPlayers, List overWiresUI) => behindNPCs.Add(index); + + public override void SendExtraAI(BinaryWriter writer) { - behindNPCs.Add(index); + writer.Write(Projectile.rotation); + writer.Write(Projectile.spriteDirection); + writer.Write(OffsetLength); + writer.Write(time); + writer.Write(firingDelay); + writer.Write(launchDelay); + writer.Write(MovingUp); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + Projectile.rotation = reader.ReadSingle(); + Projectile.spriteDirection = reader.ReadInt32(); + OffsetLength = reader.ReadSingle(); + time = reader.ReadInt32(); + firingDelay = reader.ReadInt32(); + launchDelay = reader.ReadInt32(); + MovingUp = reader.ReadBoolean(); } } } diff --git a/Projectiles/Magic/PhasedGodRay.cs b/Projectiles/Magic/PhasedGodRay.cs index 97b300715c..633e74c335 100644 --- a/Projectiles/Magic/PhasedGodRay.cs +++ b/Projectiles/Magic/PhasedGodRay.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Projectiles.Magic // They are extremely carefully chosen and barely work as is! private const float WaveTheta = 0.09f; private const int WaveTwistFrames = 9; - private ref float WaveFrameState => ref Projectile.localAI[1]; + private ref float WaveFrameState => ref Projectile.ai[0]; public override string Texture => "CalamityMod/Projectiles/LaserProj"; @@ -53,7 +53,7 @@ namespace CalamityMod.Projectiles.Magic float waveSign = WaveFrameState < 0f ? -1f : 1f; - // Initialize waving. Setting localAI[1] to a number between -1 and 1 tells it which way to wave. + // Initialize waving. Setting ai[0] to a number between -1 and 1 tells it which way to wave. // Exactly 0 is a coinflip. if (Math.Abs(WaveFrameState) < 1f) { diff --git a/Projectiles/Magic/SandstreamScepterExplosion.cs b/Projectiles/Magic/SandstreamScepterExplosion.cs index 6e5e86bd99..9b6ecb208e 100644 --- a/Projectiles/Magic/SandstreamScepterExplosion.cs +++ b/Projectiles/Magic/SandstreamScepterExplosion.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Projectiles.Magic Projectile.width = 112; Projectile.height = 112; Projectile.friendly = true; - Projectile.DamageType = RogueDamageClass.Instance; + Projectile.DamageType = DamageClass.Magic; Projectile.ignoreWater = true; Projectile.tileCollide = false; Projectile.penetrate = -1; diff --git a/Projectiles/Magic/VoidVortexProj.cs b/Projectiles/Magic/VoidVortexProj.cs index f8c424ab86..d0ba7f2205 100644 --- a/Projectiles/Magic/VoidVortexProj.cs +++ b/Projectiles/Magic/VoidVortexProj.cs @@ -137,6 +137,7 @@ namespace CalamityMod.Projectiles.Magic } public override void OnKill(int timeLeft) { + Projectile.netUpdate = true; if (Projectile.ai[2] == 1) { doDamage = true; diff --git a/Projectiles/Magic/WingmanGrenade.cs b/Projectiles/Magic/WingmanGrenade.cs index fe6b7fb52a..d25fad5311 100644 --- a/Projectiles/Magic/WingmanGrenade.cs +++ b/Projectiles/Magic/WingmanGrenade.cs @@ -1,25 +1,31 @@ -using CalamityMod.Particles; -using CalamityMod.Projectiles.Summon; +using System.IO; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; + namespace CalamityMod.Projectiles.Magic { public class WingmanGrenade : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Magic"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - public int BounceHits = 0; - public Color mainColor = Color.White; - public bool exploding = false; - public float sizeBonus = 1; + + public bool exploding + { + get => Projectile.ai[0] == 1f; + set => Projectile.ai[0] = value == true ? 1f : 0f; + } + public float sizeBonus { get; set; } = 1f; + public Color mainColor { get; set; } = Color.White; + public override void SetStaticDefaults() { - ProjectileID.Sets.TrailCacheLength[Projectile.type] = 14; - ProjectileID.Sets.TrailingMode[Projectile.type] = 2; + ProjectileID.Sets.TrailCacheLength[Type] = 14; + ProjectileID.Sets.TrailingMode[Type] = 2; } public override void SetDefaults() @@ -35,6 +41,8 @@ namespace CalamityMod.Projectiles.Magic Projectile.localNPCHitCooldown = -1; } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, exploding ? 120 * sizeBonus : 20 * sizeBonus, targetHitbox); + public override void AI() { if (mainColor == Color.White) @@ -60,8 +68,10 @@ namespace CalamityMod.Projectiles.Magic if (exploding) { Projectile.velocity = Vector2.Zero; + if (Projectile.timeLeft > 65) Projectile.timeLeft = 65; + if (Projectile.timeLeft == 65) { Particle blastRing2 = new CustomPulse(Projectile.Center, Vector2.Zero, mainColor, "CalamityMod/Particles/HighResHollowCircleHardEdge", Vector2.One, Main.rand.NextFloat(-10, 10), 0f, 0.12f * sizeBonus, 15); @@ -71,6 +81,7 @@ namespace CalamityMod.Projectiles.Magic SoundStyle fire = new("CalamityMod/Sounds/Item/ArcNovaDiffuserChargeImpact"); SoundEngine.PlaySound(fire with { Volume = 1.25f, Pitch = -0.2f, PitchVariance = 0.15f }, Projectile.Center); } + if (Projectile.timeLeft == 65) { Particle blastRing2 = new CustomPulse(Projectile.Center, Vector2.Zero, mainColor, "CalamityMod/Particles/HighResHollowCircleHardEdge", Vector2.One, Main.rand.NextFloat(-10, 10), 0.12f * sizeBonus, 0.135f * sizeBonus, 50); @@ -83,10 +94,11 @@ namespace CalamityMod.Projectiles.Magic GeneralParticleHandler.SpawnParticle(blastRing2); } } - Lighting.AddLight(Projectile.Center, mainColor.ToVector3() * 0.7f); - Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; - + Projectile.velocity *= 0.988f; + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + Lighting.AddLight(Projectile.Center, mainColor.ToVector3() * 0.7f); + if (Projectile.timeLeft % 2 == 0) { if (!exploding && Main.rand.NextBool() || exploding) @@ -97,51 +109,49 @@ namespace CalamityMod.Projectiles.Magic dust.color = Main.rand.NextBool() ? Color.Lerp(mainColor, Color.White, 0.5f) : mainColor; } } - } - public override bool PreDraw(ref Color lightColor) - { - Texture2D texture = ModContent.Request("CalamityMod/Particles/Light").Value; - Vector2 drawPosition = Projectile.Center - Main.screenPosition; - Color drawColor = Projectile.GetAlpha(lightColor); - float drawRotation = Projectile.rotation; - Vector2 rotationPoint = texture.Size() * 0.5f; - if (!exploding) - { - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], Color.Lerp(mainColor, Color.White, 0.5f) * 0.6f, 1); - Main.EntitySpriteDraw(texture, drawPosition, null, mainColor with { A = 0 }, drawRotation, rotationPoint, Projectile.scale, SpriteEffects.None); - Main.EntitySpriteDraw(texture, drawPosition, null, Color.White with { A = 0 }, drawRotation, rotationPoint, Projectile.scale, SpriteEffects.None); - - } - return false; + Projectile.netSpam = 0; + Projectile.netUpdate = true; } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { if (!exploding) - { exploding = true; - } + if (Projectile.numHits > 0) Projectile.damage = (int)(Projectile.damage * 0.80f); if (Projectile.damage < 1) Projectile.damage = 1; } - public override void OnKill(int timeLeft) - { - for (int i = 0; i <= 5; i++) - { - //Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(4) ? 264 : 66, (Projectile.velocity.SafeNormalize(Vector2.UnitY) * 15f).RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.1f, 0.8f), 0, default, Main.rand.NextFloat(1.2f, 1.6f)); - //dust.noGravity = true; - //dust.color = Main.rand.NextBool() ? Color.Lerp(mainColor, Color.White, 0.5f) : mainColor; - } - } + public override bool OnTileCollide(Vector2 oldVelocity) { Projectile.tileCollide = false; exploding = true; return false; } - public override bool? CanDamage() => null; - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, exploding ? 120 * sizeBonus : 20 * sizeBonus, targetHitbox); + + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = ModContent.Request("CalamityMod/Particles/Light").Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + float drawRotation = Projectile.rotation; + Vector2 rotationPoint = texture.Size() * 0.5f; + + if (!exploding) + { + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], Color.Lerp(mainColor, Color.White, 0.5f) * 0.6f, 1); + Main.EntitySpriteDraw(texture, drawPosition, null, mainColor with { A = 0 }, drawRotation, rotationPoint, Projectile.scale, SpriteEffects.None); + Main.EntitySpriteDraw(texture, drawPosition, null, Color.White with { A = 0 }, drawRotation, rotationPoint, Projectile.scale, SpriteEffects.None); + + } + + return false; + } + + public override void SendExtraAI(BinaryWriter writer) => writer.Write(sizeBonus); + + public override void ReceiveExtraAI(BinaryReader reader) => sizeBonus = reader.ReadSingle(); } } diff --git a/Projectiles/Magic/WingmanHoldout.cs b/Projectiles/Magic/WingmanHoldout.cs index 052e406b2a..c0a303c917 100644 --- a/Projectiles/Magic/WingmanHoldout.cs +++ b/Projectiles/Magic/WingmanHoldout.cs @@ -1,19 +1,16 @@ using System; +using System.Collections.Generic; +using System.IO; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Particles; -using Humanizer; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using ReLogic.Utilities; using Terraria; using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; -using System.Collections.Generic; -using System.IO; -using CalamityMod.Graphics.Renderers; namespace CalamityMod.Projectiles.Magic { @@ -24,22 +21,22 @@ namespace CalamityMod.Projectiles.Magic public Color StaticEffectsColor = Color.HotPink; private ref float ShootingTimer => ref Projectile.ai[0]; + private ref float PostFireCooldown => ref Projectile.ai[1]; + public float yOffset; + private float OffsetLength; private float FiringTime = 40; - private float PostFireCooldown = 0; - private Vector2 MovementOffset; - public bool MovingUp = true; - public float xOffset = 1; - public float yOffset = 0; - public int time = 0; + public int time; public int firingDelay = 45; - - private ref float OffsetLength => ref Projectile.localAI[0]; - + public bool MovingUp = true; private Player Owner; - private float MaxOffsetLength = 5f; + private static readonly float MaxOffsetLength = 5f; - public bool recharging = false; + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Type] = 9; + ProjectileID.Sets.TrailingMode[Type] = 2; + } public override void SetDefaults() { @@ -47,19 +44,21 @@ namespace CalamityMod.Projectiles.Magic Projectile.tileCollide = false; Projectile.ignoreWater = true; Projectile.netImportant = true; - ProjectileID.Sets.TrailCacheLength[Projectile.type] = 9; - ProjectileID.Sets.TrailingMode[Projectile.type] = 2; Projectile.hide = true; } public override void AI() { + Owner ??= Main.player[Projectile.owner]; + Lighting.AddLight(Projectile.Center, StaticEffectsColor.ToVector3() * 0.2f); + if (time == 0) { MovingUp = Projectile.ai[2] == 1 ? true : false; } firingDelay--; + Item heldItem = Owner.ActiveItem(); // Update damage based on curent magic damage stat (so Mana Sickness affects it) @@ -72,9 +71,8 @@ namespace CalamityMod.Projectiles.Magic Vector2 tipPosition = Projectile.Center + Projectile.velocity.SafeNormalize(Vector2.Zero).RotatedBy(-0.05f * Projectile.direction) * 12f; // If there's no player, or the player is the server, or the owner's stunned, there'll be no holdout. - if (Owner.CantUseHoldout() || heldItem.type != ModContent.ItemType() ) + if (Owner.CantUseHoldout() || heldItem.type != ModContent.ItemType()) { - NetUpdate(); if (PostFireCooldown <= 0) Projectile.Kill(); } @@ -85,7 +83,7 @@ namespace CalamityMod.Projectiles.Magic { if ((Owner.CheckMana(Owner.ActiveItem(), (int)(heldItem.mana * Owner.manaCost) * 5, true, false))) { - Shoot(heldItem, true); + Shoot(true); PostFireCooldown = 35 + 55 * Utils.GetLerpValue(10, 40, FiringTime, true); ShootingTimer = 0; FiringTime = 40; @@ -102,9 +100,9 @@ namespace CalamityMod.Projectiles.Magic } else if (ShootingTimer >= FiringTime) { - if (Owner.CheckMana(Owner.ActiveItem(), -1, true, false)) + if (Owner.CheckMana(Owner.ActiveItem(), (int)(heldItem.mana * Owner.manaCost), true, false)) { - Shoot(heldItem, false); + Shoot(false); ShootingTimer = 0; if (FiringTime > 10) @@ -132,7 +130,7 @@ namespace CalamityMod.Projectiles.Magic Vector2 ownerToMouse = Owner.Calamity().mouseWorld - ownerPosition; // Deals with the holdout's rotation and direction, the owner's arms, etc. - ManageHoldout(ownerPosition, ownerToMouse); + ManageHoldout(ownerToMouse); // When we change the distance of the gun from the arms for the recoil, // recover to the original position smoothly. @@ -140,79 +138,60 @@ namespace CalamityMod.Projectiles.Magic OffsetLength = MathHelper.Lerp(OffsetLength, MaxOffsetLength, 0.1f); ShootingTimer++; - - // Inside here go all the things that dedicated servers shouldn't spend resources on. - // Like visuals and sounds. - if (Main.dedServ) - return; - - Vector2 shootDirection = Projectile.velocity.SafeNormalize(Vector2.Zero) * 20; time++; Projectile.soundDelay--; + + Projectile.netSpam = 0; + Projectile.netUpdate = true; } - private void ManageHoldout(Vector2 mountedCenter, Vector2 ownerToMouse) + private void ManageHoldout(Vector2 ownerToMouse) { Vector2 rotationVector = Projectile.rotation.ToRotationVector2(); float velocityRotation = Projectile.velocity.ToRotation(); - float proximityLookingUpwards = Vector2.Dot(ownerToMouse.SafeNormalize(Vector2.Zero), -Vector2.UnitY); int direction = MathF.Sign(ownerToMouse.X); - - Vector2 armPosition = Owner.RotatedRelativePoint(mountedCenter, true); Vector2 lengthOffset = rotationVector * OffsetLength; - Vector2 armOffset = new Vector2(Utils.Remap(proximityLookingUpwards, -1f, 1f, 0f, -12f) * direction, -10f + Utils.Remap(MathF.Abs(proximityLookingUpwards), 0f, 1f, 0f, proximityLookingUpwards > 0f ? 15f : 0f)); if (time % 40 == 0) - { MovingUp = !MovingUp; - } //xOffset = MathHelper.Lerp(xOffset, placementOffset.X, 0.01f); yOffset = MathHelper.Lerp(yOffset, 150 * (MovingUp ? -1 : 1), (0.085f - (FiringTime * 0.0012f))); Vector2 placementOffset = Projectile.velocity.SafeNormalize(Vector2.UnitX).RotatedBy(MathHelper.PiOver2) * (yOffset); - Vector2 location = Owner.MountedCenter + placementOffset; Projectile.Center = lengthOffset + location; - - Projectile.velocity = velocityRotation.AngleTowards(ownerToMouse.ToRotation(), 0.2f).ToRotationVector2(); - Projectile.rotation = (Main.MouseWorld - Projectile.Center).SafeNormalize(Vector2.UnitX).ToRotation(); + Projectile.rotation = (Owner.Calamity().mouseWorld - Projectile.Center).SafeNormalize(Vector2.UnitX).ToRotation(); Projectile.timeLeft = 2; + Projectile.spriteDirection = Projectile.direction = direction; + Owner.ChangeDir(direction); + Owner.heldProj = Projectile.whoAmI; Owner.itemTime = Owner.itemAnimation = 2; Owner.itemRotation = (Projectile.velocity * Projectile.direction).ToRotation(); - Projectile.spriteDirection = Projectile.direction = direction; - Owner.ChangeDir(direction); - float armRotation = (Projectile.rotation - MathHelper.PiOver2); // -Pi/2 because the arms rotation starts with arms pointing down. if (Projectile.ai[2] == 1) - { - Owner.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Quarter, armRotation); - } + Owner.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, armRotation); else - { Owner.SetCompositeArmBack(true, Player.CompositeArmStretchAmount.Full, armRotation); - } } - private void Shoot(Item item, bool isGrenade) + private void Shoot(bool isGrenade) { - Vector2 shootDirection = (Main.MouseWorld - Projectile.Center).SafeNormalize(Vector2.UnitX); + Vector2 shootDirection = (Owner.Calamity().mouseWorld - Projectile.Center).SafeNormalize(Vector2.UnitX); // The position of the tip of the gun. Vector2 tipPosition = Projectile.Center + Projectile.velocity.SafeNormalize(Vector2.Zero).RotatedBy(-0.05f * Projectile.direction) * 12f; - // Spawns the projectile. - Vector2 firingVelocity = shootDirection * 10; if (isGrenade) { SoundStyle fire = new("CalamityMod/Sounds/Item/DeadSunExplosion"); SoundEngine.PlaySound(fire with { Volume = 0.35f, Pitch = -0.4f, PitchVariance = 0.2f }, Projectile.Center); - Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), tipPosition, (firingVelocity * 2) * Utils.GetLerpValue(60, 10, FiringTime, true), ModContent.ProjectileType(), (int)(Projectile.damage * 6), Projectile.knockBack * 5, Projectile.owner, 0); + Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), tipPosition, (firingVelocity * 1.3f) * Utils.GetLerpValue(60, 10, FiringTime, true), ModContent.ProjectileType(), (int)(Projectile.damage * 6), Projectile.knockBack * 5, Projectile.owner, 0); } else { @@ -221,8 +200,6 @@ namespace CalamityMod.Projectiles.Magic Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), tipPosition, firingVelocity * Utils.GetLerpValue(80, 10, FiringTime, true), ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0); } - NetUpdate(); - // Inside here go all the things that dedicated servers shouldn't spend resources on. // Like visuals and sounds. if (Main.dedServ) @@ -246,6 +223,7 @@ namespace CalamityMod.Projectiles.Magic else OffsetLength -= 5f; } + private void PostFiringCooldown() { Owner.channel = true; @@ -266,18 +244,7 @@ namespace CalamityMod.Projectiles.Magic PostFireCooldown--; } - private void NetUpdate() - { - Projectile.netUpdate = true; - if (Projectile.netSpam >= 10) - Projectile.netSpam = 9; - } - - public override void OnSpawn(IEntitySource source) - { - Owner = Main.player[Projectile.owner]; - OffsetLength = MaxOffsetLength; - } + public override void OnSpawn(IEntitySource source) => OffsetLength = MaxOffsetLength; // Because we use the velocity as a direction, we don't need it to change its position. public override bool ShouldUpdatePosition() => false; @@ -286,11 +253,10 @@ namespace CalamityMod.Projectiles.Magic public override bool PreDraw(ref Color lightColor) { - if (time <= 0) + if (time <= 0 && !Main.dedServ) return false; - Texture2D texture = ModContent.Request("CalamityMod/Items/Weapons/Magic/Wingman").Value; - + Texture2D texture; if (Projectile.ai[2] == 1) texture = ModContent.Request("CalamityMod/Items/Weapons/Magic/Wingman").Value; else @@ -309,9 +275,31 @@ namespace CalamityMod.Projectiles.Magic return false; } - public override void DrawBehind(int index, List behindNPCsAndTiles, List behindNPCs, List behindProjectiles, List overPlayers, List overWiresUI) + + public override void DrawBehind(int index, List behindNPCsAndTiles, List behindNPCs, List behindProjectiles, List overPlayers, List overWiresUI) => behindNPCs.Add(index); + + public override void SendExtraAI(BinaryWriter writer) { - behindNPCs.Add(index); + writer.Write(Projectile.rotation); + writer.Write(Projectile.spriteDirection); + writer.Write(OffsetLength); + writer.Write(FiringTime); + writer.Write(time); + writer.Write(firingDelay); + writer.Write(MovingUp); + writer.Write(yOffset); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + Projectile.rotation = reader.ReadSingle(); + Projectile.spriteDirection = reader.ReadInt32(); + OffsetLength = reader.ReadSingle(); + FiringTime = reader.ReadSingle(); + time = reader.ReadInt32(); + firingDelay = reader.ReadInt32(); + MovingUp = reader.ReadBoolean(); + yOffset = reader.ReadSingle(); } } } diff --git a/Projectiles/Melee/Cyclone.cs b/Projectiles/Melee/Cyclone.cs index e079ace083..0a14bde12d 100644 --- a/Projectiles/Melee/Cyclone.cs +++ b/Projectiles/Melee/Cyclone.cs @@ -1,10 +1,10 @@ -using System; -using CalamityMod.CalPlayer; +using CalamityMod.CalPlayer; using Microsoft.Xna.Framework; +using System; using Terraria; -using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; +using Terraria.Audio; namespace CalamityMod.Projectiles.Melee { @@ -20,8 +20,8 @@ namespace CalamityMod.Projectiles.Melee public override void SetDefaults() { - Projectile.width = 36; - Projectile.height = 36; + Projectile.width = 56; + Projectile.height = 56; Projectile.alpha = 255; Projectile.friendly = true; Projectile.DamageType = DamageClass.Melee; @@ -54,7 +54,7 @@ namespace CalamityMod.Projectiles.Melee for (int i = 1; i <= 6; i++) { Vector2 dustspeed = new Vector2(3f, 3f).RotatedBy(MathHelper.ToRadians(dustvortex)); - int d = Dust.NewDust(Projectile.Center, Projectile.width / 2, Projectile.height / 2, DustID.Smoke, dustspeed.X, dustspeed.Y, 200, new Color(232, 251, 250, 200), 1.3f); + int d = Dust.NewDust(Projectile.Center, Projectile.width / 2, Projectile.height / 2, 31, dustspeed.X, dustspeed.Y, 200, new Color(232, 251, 250, 200), 1.3f); Main.dust[d].noGravity = true; Main.dust[d].velocity = dustspeed; dustvortex += 60; @@ -63,18 +63,20 @@ namespace CalamityMod.Projectiles.Melee Projectile.ai[1] = 0; } } - float projX = Projectile.Center.X; - float projY = Projectile.Center.Y; - foreach (var npc in Main.ActiveNPCs) + float num472 = Projectile.Center.X; + float num473 = Projectile.Center.Y; + float num474 = 600f; + for (int num475 = 0; num475 < Main.maxNPCs; num475++) { + NPC npc = Main.npc[num475]; if (npc.CanBeChasedBy(Projectile, false) && Collision.CanHit(Projectile.Center, 1, 1, npc.Center, 1, 1) && !CalamityPlayer.areThereAnyDamnBosses) { float npcCenterX = npc.position.X + (float)(npc.width / 2); float npcCenterY = npc.position.Y + (float)(npc.height / 2); - float npcDistance = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - npcCenterX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - npcCenterY); - if (npcDistance < 600f) + float num478 = Math.Abs(Projectile.position.X + (float)(Projectile.width / 2) - npcCenterX) + Math.Abs(Projectile.position.Y + (float)(Projectile.height / 2) - npcCenterY); + if (num478 < num474) { - if (npc.position.X < projX) + if (npc.position.X < num472) { npc.velocity.X += 0.05f; } @@ -82,7 +84,7 @@ namespace CalamityMod.Projectiles.Melee { npc.velocity.X -= 0.05f; } - if (npc.position.Y < projY) + if (npc.position.Y < num473) { npc.velocity.Y += 0.05f; } @@ -113,7 +115,7 @@ namespace CalamityMod.Projectiles.Melee for (int i = 0; i <= 360; i += 3) { Vector2 dustspeed = new Vector2(3f, 3f).RotatedBy(MathHelper.ToRadians(i)); - int d = Dust.NewDust(Projectile.Center, Projectile.width, Projectile.height, DustID.Smoke, dustspeed.X, dustspeed.Y, 200, new Color(232, 251, 250, 200), 1.4f); + int d = Dust.NewDust(Projectile.Center, Projectile.width, Projectile.height, 31, dustspeed.X, dustspeed.Y, 200, new Color(232, 251, 250, 200), 1.4f); Main.dust[d].noGravity = true; Main.dust[d].position = Projectile.Center; Main.dust[d].velocity = dustspeed; diff --git a/Projectiles/Melee/DarklightGreatswordSlash.cs b/Projectiles/Melee/DarklightGreatswordSlash.cs index 240b16bdc5..f745eabf07 100644 --- a/Projectiles/Melee/DarklightGreatswordSlash.cs +++ b/Projectiles/Melee/DarklightGreatswordSlash.cs @@ -1,4 +1,6 @@ using System; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -34,6 +36,11 @@ namespace CalamityMod.Projectiles.Melee { Projectile.rotation = Projectile.velocity.ToRotation(); Projectile.Opacity = Projectile.timeLeft / 35f; + if (Projectile.timeLeft == 34) + { + Particle spark2 = new GlowSparkParticle(Projectile.Center, new Vector2(0.1f, 0.1f).RotatedByRandom(100), false, 12, Main.rand.NextFloat(0.03f, 0.05f), Main.rand.NextBool() ? Color.Pink : Color.Cyan, new Vector2(2, 0.5f), true); + GeneralParticleHandler.SpawnParticle(spark2); + } } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => Projectile.RotatingHitboxCollision(targetHitbox.TopLeft(), targetHitbox.Size()); @@ -44,30 +51,6 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(ref Color lightColor) { - if (Projectile.timeLeft >= 34f) - return false; - - Main.spriteBatch.SetBlendState(BlendState.Additive); - - float progress = (33f - Projectile.timeLeft) / 33f; - - Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value; - Texture2D bloomTexture = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; - - Vector2 drawPosition = Projectile.Center - Main.screenPosition; - Vector2 origin = texture.Size() * 0.5f; - Vector2 scale = new Vector2(MathHelper.Lerp(0.8f, 1.25f, (float)Math.Pow(progress, 0.45)), MathHelper.Lerp(0.6f, 0.24f, (float)Math.Pow(progress, 0.4))) * Projectile.scale; - - // Draw an inner bloom circle to signify power at the center of the strike along with two thinner lines. - Vector2 bloomScale = Projectile.Size / bloomTexture.Size() * new Vector2(1f, 2f); - Vector2 bloomOrigin = bloomTexture.Size() * 0.5f; - Color outerSlashColor = Projectile.ai[2] == 0f ? Color.DarkBlue : Color.DarkRed; - Color innerSlashColor = Projectile.ai[2] == 0f ? Color.Cyan : Color.Pink; - Main.spriteBatch.Draw(bloomTexture, drawPosition, null, outerSlashColor * Projectile.Opacity, Projectile.rotation, bloomOrigin, bloomScale, 0, 0f); - Main.spriteBatch.Draw(texture, drawPosition, null, Projectile.GetAlpha(lightColor), Projectile.rotation, origin, scale, 0, 0f); - Main.spriteBatch.Draw(texture, drawPosition, null, innerSlashColor * Projectile.Opacity, Projectile.rotation, origin, scale * new Vector2(1f, 0.6f), 0, 0f); - - Main.spriteBatch.SetBlendState(BlendState.AlphaBlend); return false; } } diff --git a/Projectiles/Melee/DepthCrusherProjectile.cs b/Projectiles/Melee/DepthCrusherProjectile.cs index 8e65dbcd00..d0b0e7f55d 100644 --- a/Projectiles/Melee/DepthCrusherProjectile.cs +++ b/Projectiles/Melee/DepthCrusherProjectile.cs @@ -105,7 +105,7 @@ namespace CalamityMod.Projectiles.Melee } Projectile.rotation += (0.4f * (MathF.Abs(Projectile.velocity.Y) * 0.2f + 0.6f)) * Projectile.direction; - if (Projectile.velocity.Y < 20) + if (Projectile.velocity.Y < 16) Projectile.velocity.Y += Projectile.numHits >= 3 ? 0.7f : 0.4f; if (Projectile.numHits >= 3) { @@ -119,7 +119,7 @@ namespace CalamityMod.Projectiles.Melee if (Projectile.velocity.Y > 0) Projectile.velocity.X *= 0.975f; - if (Collision.SolidCollision(Projectile.Center, 15, 15)) + if (Collision.SolidCollision(Projectile.Center, 25, 25)) { Projectile.tileCollide = true; } @@ -133,9 +133,9 @@ namespace CalamityMod.Projectiles.Melee if (!setDamage) { if (Projectile.velocity.Y > 0) - Projectile.velocity.Y = -9; + Projectile.velocity.Y -= 6; else - Projectile.velocity.Y = -7; + Projectile.velocity.Y = -6; } for (int i = 0; i < 15; i++) @@ -195,7 +195,7 @@ namespace CalamityMod.Projectiles.Melee SoundEngine.PlaySound(HitSound, Projectile.Center); for (int i = 0; i < 3; i++) { - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, new Vector2(0, -5).RotatedByRandom(0.6f) * Main.rand.NextFloat(0.9f, 1.1f), ModContent.ProjectileType(), startDamage / 4, Projectile.knockBack / 4, Projectile.owner); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Bottom, new Vector2(0, -5).RotatedByRandom(0.6f) * Main.rand.NextFloat(0.9f, 1.1f), ModContent.ProjectileType(), (int)(startDamage * 0.3f), Projectile.knockBack / 4, Projectile.owner); } Projectile.Kill(); } diff --git a/Projectiles/Melee/DepthCrusherSplitProjectile.cs b/Projectiles/Melee/DepthCrusherSplitProjectile.cs index 5c2b6ef338..4da528c2f8 100644 --- a/Projectiles/Melee/DepthCrusherSplitProjectile.cs +++ b/Projectiles/Melee/DepthCrusherSplitProjectile.cs @@ -42,7 +42,7 @@ namespace CalamityMod.Projectiles.Melee } if (Time > 20 && Time < (randTimer - 70)) { - CalamityUtils.HomeInOnNPC(Projectile, true, 280f, MathHelper.Clamp(1f + Time * 0.06f, 1, 10), 20f); + CalamityUtils.HomeInOnNPC(Projectile, true, 384f, MathHelper.Clamp(1f + Time * 0.12f, 1, 11), 20f); } else if (Time >= (randTimer - 70)) { diff --git a/Projectiles/Melee/ExobeamSlash.cs b/Projectiles/Melee/ExobeamSlash.cs index 556a8b8b79..c93a8ee983 100644 --- a/Projectiles/Melee/ExobeamSlash.cs +++ b/Projectiles/Melee/ExobeamSlash.cs @@ -1,5 +1,7 @@ using System; using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -32,6 +34,11 @@ namespace CalamityMod.Projectiles.Melee { Projectile.rotation = Projectile.velocity.ToRotation(); Projectile.Opacity = Projectile.timeLeft / 35f; + if (Projectile.timeLeft == 34) + { + Particle spark2 = new GlowSparkParticle(Projectile.Center, new Vector2(0.1f, 0.1f).RotatedByRandom(100), false, 12, Main.rand.NextFloat(0.05f, 0.09f), (Main.rand.NextBool() ? Color.Cyan : Main.rand.NextBool() ? Color.LightGoldenrodYellow : Color.Lime) * 0.7f, new Vector2(2, 0.5f), true); + GeneralParticleHandler.SpawnParticle(spark2); + } } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) @@ -55,28 +62,6 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(ref Color lightColor) { - if (Projectile.timeLeft > 33) - return false; - - Main.spriteBatch.SetBlendState(BlendState.Additive); - - float progress = (33 - Projectile.timeLeft) / 33f; - - Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value; - Texture2D bloomTexture = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; - - Vector2 drawPosition = Projectile.Center - Main.screenPosition; - Vector2 origin = texture.Size() * 0.5f; - Vector2 scale = new Vector2(0.5f + 0.7f * (float)Math.Pow(progress, 0.45), 0.55f - 0.3f * (float)Math.Pow(progress, 0.4)) * Projectile.scale; - - - Vector2 bloomScale = Projectile.Size / bloomTexture.Size() * new Vector2(1f, 2f); - Vector2 bloomOrigin = bloomTexture.Size() * 0.5f; - Main.spriteBatch.Draw(bloomTexture, drawPosition, null, Color.White * Projectile.Opacity, Projectile.rotation, bloomOrigin, bloomScale, 0, 0f); - Main.spriteBatch.Draw(texture, drawPosition, null, Projectile.GetAlpha(lightColor), Projectile.rotation, origin, scale, 0, 0f); - Main.spriteBatch.Draw(texture, drawPosition, null, Color.White * Projectile.Opacity, Projectile.rotation, origin, scale * new Vector2(1f, 0.6f), 0, 0f); - - Main.spriteBatch.SetBlendState(BlendState.AlphaBlend); return false; } } diff --git a/Projectiles/Melee/ExobladeProj.cs b/Projectiles/Melee/ExobladeProj.cs index 028976e98e..c754b6d14e 100644 --- a/Projectiles/Melee/ExobladeProj.cs +++ b/Projectiles/Melee/ExobladeProj.cs @@ -363,6 +363,10 @@ namespace CalamityMod.Projectiles.Melee Projectile.velocity = Owner.MountedCenter.DirectionTo(Owner.Calamity().mouseWorld); Projectile.oldPos = new Vector2[Projectile.oldPos.Length]; + + // Prevent zeroed out garbage from messing up the trail rendering. + for (int i = 0; i < Projectile.oldPos.Length; ++i) + Projectile.oldPos[i] = Projectile.position; } // Do the dash. @@ -418,8 +422,6 @@ namespace CalamityMod.Projectiles.Melee Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver4 * Direction; } - - public float SlashWidthFunction(float completionRatio) => SquishAtProgress(RealProgressionAtTrailCompletion(completionRatio)) * Projectile.scale * 60.5f; public Color SlashColorFunction(float completionRatio) => Color.Lime * Utils.GetLerpValue(0.9f, 0.4f, completionRatio, true) * Projectile.Opacity; @@ -487,7 +489,6 @@ namespace CalamityMod.Projectiles.Melee Main.spriteBatch.EnterShaderRegion(); - Color mainColor = MulticolorLerp((Main.GlobalTimeWrappedHourly * 2f) % 1, Color.Cyan, Color.Lime, Color.GreenYellow, Color.Goldenrod, Color.Orange); Color secondaryColor = MulticolorLerp((Main.GlobalTimeWrappedHourly * 2f + 0.2f) % 1, Color.Cyan, Color.Lime, Color.GreenYellow, Color.Goldenrod, Color.Orange); @@ -500,7 +501,13 @@ namespace CalamityMod.Projectiles.Melee GameShaders.Misc["CalamityMod:ExobladePierce"].UseColor(mainColor); GameShaders.Misc["CalamityMod:ExobladePierce"].UseSecondaryColor(secondaryColor); GameShaders.Misc["CalamityMod:ExobladePierce"].Apply(); - PrimitiveRenderer.RenderTrail(Projectile.oldPos.Take(51).ToArray(), new(PierceWidthFunction, PierceColorFunction, (_) => trailOffset, shader: GameShaders.Misc["CalamityMod:ExobladePierce"]), 53); + + // Exoblade tracks 120 positions in oldPos. + // Provide 60 points for smoothing, but only render 30 + int numPointsRendered = 30; + int numPointsProvided = 60; + var positionsToUse = Projectile.oldPos.Take(numPointsProvided).ToArray(); + PrimitiveRenderer.RenderTrail(positionsToUse, new(PierceWidthFunction, PierceColorFunction, (_) => trailOffset, shader: GameShaders.Misc["CalamityMod:ExobladePierce"]), numPointsRendered); Main.spriteBatch.ExitShaderRegion(); } diff --git a/Projectiles/Melee/PrismTooth.cs b/Projectiles/Melee/PrismTooth.cs index d7a1981016..27b738b95c 100644 --- a/Projectiles/Melee/PrismTooth.cs +++ b/Projectiles/Melee/PrismTooth.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Graphics.Primitives; using Microsoft.Xna.Framework; @@ -22,7 +23,7 @@ namespace CalamityMod.Projectiles.Melee public override void SetStaticDefaults() { ProjectileID.Sets.TrailingMode[Projectile.type] = 2; - ProjectileID.Sets.TrailCacheLength[Projectile.type] = 36; + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 90; } public override void SetDefaults() @@ -42,6 +43,14 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { + // Frame 1 effect: Prevent zeroed out garbage from messing up the trail rendering. + if (Projectile.localAI[1] == 0f) + { + Projectile.localAI[1] = 1f; + for (int i = 0; i < Projectile.oldPos.Length; ++i) + Projectile.oldPos[i] = Projectile.position; + } + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.Pi * Time / Lifetime; Vector2 baseDirection = (MathHelper.TwoPi * Time / Lifetime - MathHelper.PiOver2).ToRotationVector2(); @@ -128,7 +137,12 @@ namespace CalamityMod.Projectiles.Melee Main.spriteBatch.EnterShaderRegion(); GameShaders.Misc["CalamityMod:PrismaticStreak"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/ScarletDevilStreak")); - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f + generalOffset, shader: GameShaders.Misc["CalamityMod:PrismaticStreak"]), 65); + // Photon Ripper tracks 90 positions in oldPos. + // Provide 60 points for smoothing, but only render 12 + int numPointsRendered = 12; + int numPointsProvided = 60; + var positionsToUse = Projectile.oldPos.Take(numPointsProvided).ToArray(); + PrimitiveRenderer.RenderTrail(positionsToUse, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f + generalOffset, shader: GameShaders.Misc["CalamityMod:PrismaticStreak"], smoothen: false), numPointsRendered); Main.spriteBatch.ExitShaderRegion(); return true; } diff --git a/Projectiles/Melee/Spears/StreamGougeProj.cs b/Projectiles/Melee/Spears/StreamGougeProj.cs index 1f7d7b90fa..49a36ff07b 100644 --- a/Projectiles/Melee/Spears/StreamGougeProj.cs +++ b/Projectiles/Melee/Spears/StreamGougeProj.cs @@ -111,20 +111,16 @@ namespace CalamityMod.Projectiles.Melee.Spears // Black portal. Color color = Color.Lerp(baseColor, Color.Black, 0.55f).MultiplyRGB(Color.DarkGray) * opacity; - Main.EntitySpriteDraw(portalTexture, drawPosition, null, color, rotation, origin, Projectile.scale * 1.2f, SpriteEffects.None, 0); - Main.EntitySpriteDraw(portalTexture, drawPosition, null, color, -rotation, origin, Projectile.scale * 1.2f, SpriteEffects.None, 0); - - Main.spriteBatch.SetBlendState(BlendState.Additive); + Main.EntitySpriteDraw(portalTexture, drawPosition, null, color with { A = 0 }, rotation, origin, Projectile.scale * 1.2f, SpriteEffects.None, 0); + Main.EntitySpriteDraw(portalTexture, drawPosition, null, color with { A = 0 }, -rotation, origin, Projectile.scale * 1.2f, SpriteEffects.None, 0); // Cyan portal. color = Color.Lerp(baseColor, Color.Cyan, 0.55f) * opacity * 1.6f; - Main.EntitySpriteDraw(portalTexture, drawPosition, null, color, rotation * 0.6f, origin, Projectile.scale * 1.2f, SpriteEffects.None, 0); + Main.EntitySpriteDraw(portalTexture, drawPosition, null, color with { A = 0 }, rotation * 0.6f, origin, Projectile.scale * 1.2f, SpriteEffects.None, 0); // Magenta portal. color = Color.Lerp(baseColor, Color.Fuchsia, 0.55f) * opacity * 1.6f; - Main.EntitySpriteDraw(portalTexture, drawPosition, null, color, rotation * -0.6f, origin, Projectile.scale * 1.2f, SpriteEffects.None, 0); - - Main.spriteBatch.SetBlendState(BlendState.AlphaBlend); + Main.EntitySpriteDraw(portalTexture, drawPosition, null, color with { A = 0 }, rotation * -0.6f, origin, Projectile.scale * 1.2f, SpriteEffects.None, 0); } public override bool PreDraw(ref Color lightColor) @@ -134,8 +130,6 @@ namespace CalamityMod.Projectiles.Melee.Spears { Texture2D smear = ModContent.Request("CalamityMod/Particles/SemiCircularSmear").Value; - Main.spriteBatch.EnterShaderRegion(BlendState.Additive); - float rotation = Projectile.rotation - MathHelper.Pi / 5f; if (SpinDirection == -1f) rotation += MathHelper.Pi; @@ -143,7 +137,7 @@ namespace CalamityMod.Projectiles.Melee.Spears Color smearColor = Color.Fuchsia * CalamityUtils.Convert01To010(SpinCompletion) * 0.9f; Vector2 smearOrigin = smear.Size() * 0.5f; - Main.EntitySpriteDraw(smear, Owner.Center - Main.screenPosition, null, smearColor, rotation, smearOrigin, Projectile.scale * 1.45f, 0, 0); + Main.EntitySpriteDraw(smear, Owner.Center - Main.screenPosition, null, smearColor with { A = 0 }, rotation, smearOrigin, Projectile.scale * 1.45f, 0, 0); Main.spriteBatch.ExitShaderRegion(); } diff --git a/Projectiles/Melee/StreamGougePortal.cs b/Projectiles/Melee/StreamGougePortal.cs index eaccceee17..12c3f98945 100644 --- a/Projectiles/Melee/StreamGougePortal.cs +++ b/Projectiles/Melee/StreamGougePortal.cs @@ -59,6 +59,7 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(ref Color lightColor) { + Texture2D texture = ModContent.Request("CalamityMod/Items/Weapons/Melee/StreamGouge").Value; Vector2 spearDrawPosition = SpearCenter - Main.screenPosition; Vector2 spearOrigin = texture.Size() * 0.5f; @@ -76,19 +77,17 @@ namespace CalamityMod.Projectiles.Melee // Black portal. Color color = Color.Lerp(baseColor, Color.Black, 0.55f).MultiplyRGB(Color.DarkGray) * Projectile.Opacity; - Main.EntitySpriteDraw(portalTexture, drawPosition, null, color, rotation, origin, Projectile.scale * 1.2f, SpriteEffects.None, 0); - Main.EntitySpriteDraw(portalTexture, drawPosition, null, color, -rotation, origin, Projectile.scale * 1.2f, SpriteEffects.None, 0); - - Main.spriteBatch.SetBlendState(BlendState.Additive); + Main.EntitySpriteDraw(portalTexture, drawPosition, null, color with { A = 0 }, rotation, origin, Projectile.scale * 1.2f, SpriteEffects.None, 0); + Main.EntitySpriteDraw(portalTexture, drawPosition, null, color with { A = 0 }, -rotation, origin, Projectile.scale * 1.2f, SpriteEffects.None, 0); // Cyan portal. color = Color.Lerp(baseColor, Color.Cyan, 0.55f) * Projectile.Opacity * 1.4f; - Main.EntitySpriteDraw(portalTexture, drawPosition, null, color, rotation * 0.6f, origin, Projectile.scale * 1.2f, SpriteEffects.None, 0); + Main.EntitySpriteDraw(portalTexture, drawPosition, null, color with { A = 0 }, rotation * 0.6f, origin, Projectile.scale * 1.2f, SpriteEffects.None, 0); // Magenta portal. color = Color.Lerp(baseColor, Color.Fuchsia, 0.55f) * Projectile.Opacity * 1.4f; - Main.EntitySpriteDraw(portalTexture, drawPosition, null, color, rotation * -0.7f, origin, Projectile.scale * 1.2f, SpriteEffects.None, 0); - Main.spriteBatch.SetBlendState(BlendState.AlphaBlend); + Main.EntitySpriteDraw(portalTexture, drawPosition, null, color with { A = 0 }, rotation * -0.7f, origin, Projectile.scale * 1.2f, SpriteEffects.None, 0); + return false; } diff --git a/Projectiles/Melee/TerratomereExplosion.cs b/Projectiles/Melee/TerratomereExplosion.cs index ecb1d3d4f6..6082d67ae7 100644 --- a/Projectiles/Melee/TerratomereExplosion.cs +++ b/Projectiles/Melee/TerratomereExplosion.cs @@ -33,7 +33,7 @@ namespace CalamityMod.Projectiles.Melee // Play an explosion sound on the first frame of this projectile's existence. if (Projectile.localAI[0] == 0f) { - SoundEngine.PlaySound(SubsumingVortex.ExplosionSound, Projectile.Center); + SoundEngine.PlaySound(SubsumingVortex.ExplosionSound with { Volume = 0.6f }, Projectile.Center); Projectile.localAI[0] = 1f; } @@ -44,7 +44,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.frameCounter++; if (Projectile.frameCounter % 5 == 4) Projectile.frame++; - if (Projectile.frame >= 18) + if (Projectile.frame >= 17) Projectile.Kill(); // Exponentially accelerate. @@ -60,14 +60,15 @@ namespace CalamityMod.Projectiles.Melee Vector2 drawPosition = Projectile.Center - Main.screenPosition; Vector2 origin = frame.Size() * 0.5f; - for (int i = 0; i < 36; i++) + for (int i = 0; i < 2; i++) { Vector2 lightDrawPosition = drawPosition + (MathHelper.TwoPi * i / 36f + Main.GlobalTimeWrappedHourly * 5f).ToRotationVector2() * Projectile.scale * 12f; Color lightBurstColor = CalamityUtils.MulticolorLerp(Projectile.timeLeft / 144f, Terratomere.TerraColor1, Terratomere.TerraColor2); - lightBurstColor = Color.Lerp(lightBurstColor, Color.White, 0.4f) * Projectile.Opacity * 0.184f; + lightBurstColor = Color.Lerp(lightBurstColor, Color.White, 0.4f) * Projectile.Opacity * 0.24f; Main.spriteBatch.Draw(lightTexture, lightDrawPosition, null, lightBurstColor, 0f, lightTexture.Size() * 0.5f, Projectile.scale * 1.32f, SpriteEffects.None, 0); } - Main.spriteBatch.Draw(texture, drawPosition, frame, Color.White, 0f, origin, 1.6f, SpriteEffects.None, 0); + if (Projectile.timeLeft < 149) + Main.spriteBatch.Draw(texture, drawPosition, frame, Color.White, 0f, origin, 1.6f, SpriteEffects.None, 0); } } } diff --git a/Projectiles/Melee/TerratomereHoldoutProj.cs b/Projectiles/Melee/TerratomereHoldoutProj.cs index 9861f0ab15..95ff843ca5 100644 --- a/Projectiles/Melee/TerratomereHoldoutProj.cs +++ b/Projectiles/Melee/TerratomereHoldoutProj.cs @@ -169,21 +169,21 @@ namespace CalamityMod.Projectiles.Melee for (int i = 0; i < totalBeams; i++) { Vector2 randomVelocity = Main.rand.NextVector2CircularEdge(randomVelocityLimit, randomVelocityLimit); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center - bigSlashVelocity * 0.4f, bigSlashVelocity + randomVelocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center - bigSlashVelocity * 0.4f, bigSlashVelocity + randomVelocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); } } - // This is a slash, not a beam. + // Close range slash effect if (Main.myPlayer == Projectile.owner && Time == (int)(Terratomere.SwingTime * RecoveryCompletionRatio) + 5f) { Vector2 bigSlashVelocity = InitialRotation.ToRotationVector2() * Owner.ActiveItem().shootSpeed / 6f; Vector2 bigSlashSpawnPosition = Projectile.Center + bigSlashVelocity.SafeNormalize(Vector2.UnitY) * 64f; - int slash = Projectile.NewProjectile(Projectile.GetSource_FromThis(), bigSlashSpawnPosition, bigSlashVelocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); + int slash = Projectile.NewProjectile(Projectile.GetSource_FromThis(), bigSlashSpawnPosition, bigSlashVelocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); if (Main.projectile.IndexInRange(slash)) { Main.projectile[slash].ai[0] = (Direction == 1f).ToInt(); - Main.projectile[slash].ModProjectile().ControlPoints = GenerateSlashPoints().ToArray(); + Main.projectile[slash].ModProjectile().ControlPoints = GenerateSlashPoints().ToArray(); } } } diff --git a/Projectiles/Melee/TerratomereBeam.cs b/Projectiles/Melee/TerratomereMeleeSlash.cs similarity index 86% rename from Projectiles/Melee/TerratomereBeam.cs rename to Projectiles/Melee/TerratomereMeleeSlash.cs index e25ce01dd4..1f95774c5f 100644 --- a/Projectiles/Melee/TerratomereBeam.cs +++ b/Projectiles/Melee/TerratomereMeleeSlash.cs @@ -8,7 +8,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class TerratomereBeam : ModProjectile, ILocalizedModType + public class TerratomereMeleeSlash : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Melee"; public Vector2[] ControlPoints; @@ -54,8 +54,8 @@ namespace CalamityMod.Projectiles.Melee for (int i = 0; i < ControlPoints.Length; i++) points.Add(ControlPoints[i] + ControlPoints[i].SafeNormalize(Vector2.Zero) * (Projectile.scale - 1f) * 40f); - for (int i = 0; i < 3; i++) - PrimitiveRenderer.RenderTrail(points, new(SlashWidthFunction, SlashColorFunction, (_) => Projectile.Center, shader: GameShaders.Misc["CalamityMod:ExobladeSlash"]), 65); + // 17MAY2024: Ozzatron: remove Terratomere rendering its trails multiple times + PrimitiveRenderer.RenderTrail(points, new(SlashWidthFunction, SlashColorFunction, (_) => Projectile.Center, shader: GameShaders.Misc["CalamityMod:ExobladeSlash"]), 65); Main.spriteBatch.ExitShaderRegion(); return false; diff --git a/Projectiles/Melee/TerratomereBeam.png b/Projectiles/Melee/TerratomereMeleeSlash.png similarity index 100% rename from Projectiles/Melee/TerratomereBeam.png rename to Projectiles/Melee/TerratomereMeleeSlash.png diff --git a/Projectiles/Melee/TerratomereSlash.cs b/Projectiles/Melee/TerratomereSlash.cs index eb7bdb2e23..56677a094d 100644 --- a/Projectiles/Melee/TerratomereSlash.cs +++ b/Projectiles/Melee/TerratomereSlash.cs @@ -1,4 +1,6 @@ using System; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -33,6 +35,11 @@ namespace CalamityMod.Projectiles.Melee { Projectile.rotation = Projectile.velocity.ToRotation(); Projectile.Opacity = Projectile.timeLeft / 35f; + if (Projectile.timeLeft == 34) + { + Particle spark2 = new GlowSparkParticle(Projectile.Center, new Vector2(0.1f, 0.1f).RotatedByRandom(100), false, 12, Main.rand.NextFloat(0.05f, 0.09f), Main.rand.NextBool() ? Terratomere.TerraColor1 : Terratomere.TerraColor2, new Vector2(2, 0.5f), true); + GeneralParticleHandler.SpawnParticle(spark2); + } } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) @@ -46,28 +53,6 @@ namespace CalamityMod.Projectiles.Melee public override bool PreDraw(ref Color lightColor) { - if (Projectile.timeLeft >= 34f) - return false; - - Main.spriteBatch.SetBlendState(BlendState.Additive); - - float progress = (33f - Projectile.timeLeft) / 33f; - - Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value; - Texture2D bloomTexture = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; - - Vector2 drawPosition = Projectile.Center - Main.screenPosition; - Vector2 origin = texture.Size() * 0.5f; - Vector2 scale = new Vector2(MathHelper.Lerp(0.8f, 1.25f, (float)Math.Pow(progress, 0.45)), MathHelper.Lerp(0.6f, 0.24f, (float)Math.Pow(progress, 0.4))) * Projectile.scale; - - // Draw an inner bloom circle to signify power at the center of the strike along with two thinner lines. - Vector2 bloomScale = Projectile.Size / bloomTexture.Size() * new Vector2(1f, 2f); - Vector2 bloomOrigin = bloomTexture.Size() * 0.5f; - Main.spriteBatch.Draw(bloomTexture, drawPosition, null, Color.White * Projectile.Opacity, Projectile.rotation, bloomOrigin, bloomScale, 0, 0f); - Main.spriteBatch.Draw(texture, drawPosition, null, Projectile.GetAlpha(lightColor), Projectile.rotation, origin, scale, 0, 0f); - Main.spriteBatch.Draw(texture, drawPosition, null, Color.White * Projectile.Opacity, Projectile.rotation, origin, scale * new Vector2(1f, 0.6f), 0, 0f); - - Main.spriteBatch.SetBlendState(BlendState.AlphaBlend); return false; } } diff --git a/Projectiles/Melee/TerratomereBigSlash.cs b/Projectiles/Melee/TerratomereSwordBeam.cs similarity index 79% rename from Projectiles/Melee/TerratomereBigSlash.cs rename to Projectiles/Melee/TerratomereSwordBeam.cs index 0e339a35e8..1343fe2c9f 100644 --- a/Projectiles/Melee/TerratomereBigSlash.cs +++ b/Projectiles/Melee/TerratomereSwordBeam.cs @@ -9,7 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { - public class TerratomereBigSlash : ModProjectile, ILocalizedModType + public class TerratomereSwordBeam : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Melee"; public int TargetIndex = -1; @@ -39,13 +39,21 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { - CalamityUtils.HomeInOnNPC(Projectile, true, 600f, 24f, 20f); + CalamityUtils.HomeInOnNPC(Projectile, true, 400f, 24f, 20f); Projectile.scale = Utils.GetLerpValue(0f, 8f, Projectile.timeLeft, true); + + Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(5) ? 131 : 294, -Projectile.velocity * Main.rand.NextFloat(0.05f, 0.3f)); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(0.75f, 0.95f); + if (dust.type == 131) + dust.scale = Main.rand.NextFloat(0.55f, 0.75f); + else + dust.fadeIn = 0.5f; } public float SlashWidthFunction(float _) => Projectile.width * Projectile.scale * Utils.GetLerpValue(0f, 0.1f, _, true); - public Color SlashColorFunction(float _) => Color.Lime * Projectile.Opacity; + public Color SlashColorFunction(float _) => Color.Turquoise; public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { @@ -72,8 +80,8 @@ namespace CalamityMod.Projectiles.Melee GameShaders.Misc["CalamityMod:ExobladePierce"].UseColor(Terratomere.TerraColor1); GameShaders.Misc["CalamityMod:ExobladePierce"].UseSecondaryColor(Terratomere.TerraColor2); - for (int i = 0; i < 4; i++) - PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(SlashWidthFunction, SlashColorFunction, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:ExobladePierce"]), 30); + // 17MAY2024: Ozzatron: remove Terratomere rendering its trails multiple times + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(SlashWidthFunction, SlashColorFunction, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:ExobladePierce"]), 30); return false; } diff --git a/Projectiles/Melee/ViolenceThrownProjectile.cs b/Projectiles/Melee/ViolenceThrownProjectile.cs index 345883e0f8..393fc828d1 100644 --- a/Projectiles/Melee/ViolenceThrownProjectile.cs +++ b/Projectiles/Melee/ViolenceThrownProjectile.cs @@ -215,7 +215,12 @@ namespace CalamityMod.Projectiles.Melee drawPoints[i] -= (Projectile.oldRot[i] + MathHelper.PiOver4).ToRotationVector2() * Projectile.height * 0.5f; if (Time > Projectile.oldPos.Length) - PrimitiveRenderer.RenderTrail(drawPoints, new(PrimitiveWidthFunction, PrimitiveColorFunction, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 88); + { + // Violence trakcs 36 positions in oldPos. + // Provide all 36 points for smoothing, but only render 24. + int numPointsRendered = 24; + PrimitiveRenderer.RenderTrail(drawPoints, new(PrimitiveWidthFunction, PrimitiveColorFunction, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:TrailStreak"], smoothen: true), numPointsRendered); + } Vector2 drawPosition = Projectile.Center - Main.screenPosition; for (int i = 0; i < 6; i++) diff --git a/Projectiles/Ranged/AdamantiteAcceleratorHoldout.cs b/Projectiles/Ranged/AdamantiteAcceleratorHoldout.cs index 57f572b000..3af7722d96 100644 --- a/Projectiles/Ranged/AdamantiteAcceleratorHoldout.cs +++ b/Projectiles/Ranged/AdamantiteAcceleratorHoldout.cs @@ -1,59 +1,59 @@ -using System; +using System.IO; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Particles; +using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Utilities; using Terraria; using Terraria.Audio; using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; using static CalamityMod.CalamityUtils; using static Terraria.ModLoader.ModContent; namespace CalamityMod.Projectiles.Ranged { - public class AdamantiteAcceleratorHoldout : ModProjectile + public class AdamantiteAcceleratorHoldout : BaseGunHoldoutProjectile { - public override LocalizedText DisplayName => CalamityUtils.GetItemName(); - public override string Texture => "CalamityMod/Items/Weapons/Ranged/AdamantiteParticleAccelerator"; - const float maxTimeAnim = 35; - public Player Owner => Main.player[Projectile.owner]; - public float Timer => maxTimeAnim - Projectile.timeLeft; + public override int AssociatedItemID => ItemType(); + public override Vector2 GunTipPosition => Owner.MountedCenter + Projectile.rotation.ToRotationVector2() * 70f + (Vector2.UnitY * -12f * Owner.direction).RotatedBy(Projectile.rotation); + public override float MaxOffsetLengthFromArm => base.MaxOffsetLengthFromArm; + public override float OffsetXUpwards => base.OffsetXUpwards; + public override float OffsetXDownwards => base.OffsetXDownwards; + public override float BaseOffsetY => base.BaseOffsetY; + public override float OffsetYUpwards => base.OffsetYUpwards; + public override float OffsetYDownwards => base.OffsetYDownwards; + public ref float ChargeTimer => ref Projectile.ai[0]; public ref float DelayTimer => ref Projectile.ai[1]; public ref float ChargeRate => ref Projectile.localAI[0]; public ref float BounceBackPower => ref Projectile.localAI[1]; - public Vector2 NuzzlePosition => Owner.MountedCenter + Projectile.rotation.ToRotationVector2() * 70f + (Vector2.UnitY * -12f * Owner.direction).RotatedBy(Projectile.rotation); private SlotId ChargeupSoundSlot; - public override void SetDefaults() + public override void KillHoldoutLogic() { - Projectile.width = 54; - Projectile.height = 52; - // This projectile has no hitboxes and no damage type. - Projectile.friendly = false; - Projectile.tileCollide = false; - Projectile.ignoreWater = true; - Projectile.timeLeft = 900; - Projectile.velocity = Vector2.Zero; + int maxTime = AdamantiteParticleAccelerator.ChargeFrames + AdamantiteParticleAccelerator.CooldownFrames; + if (ChargeTimer > maxTime) + { + if (!Owner.CantUseHoldout()) + ResetToStart(); + else + { + Projectile.Kill(); + return; + } + } } // ChargeTimer is a time-dilated frame counter. DelayTimer is the frame counter for when the beams are fired. // ChargeRate is the rate at which the "frame" counter increases. BounceBackPower is there for the visuals of the gun recoiling in the players hands. - public override void AI() + public override void HoldoutAI() { - Player player = Main.player[Projectile.owner]; - Vector2 rrp = player.RotatedRelativePoint(player.MountedCenter, true); - - Projectile.rotation = Owner.MountedCenter.AngleTo(Owner.Calamity().mouseWorld); - // Calculate how quickly the gun should charge. Charge increases by some number close to 1 every frame. // Speed increasing reforges make this number greater than 1. Slowing reforges make it smaller than 1. if (ChargeRate == 0f) - ChargeRate = 44f / player.ActiveItem().useTime; + ChargeRate = 44f / HeldItem.useTime; if (ChargeTimer == 0f) ChargeupSoundSlot = SoundEngine.PlaySound(SoundID.DD2_WitherBeastAuraPulse with { Volume = SoundID.DD2_WitherBeastAuraPulse.Volume * 1.6f }, Projectile.Center); @@ -69,24 +69,10 @@ namespace CalamityMod.Projectiles.Ranged // Increment the timer for the gun. If the timer has passed 44, destroy it. ChargeTimer += ChargeRate; - int maxTime = AdamantiteParticleAccelerator.ChargeFrames + AdamantiteParticleAccelerator.CooldownFrames; - if (ChargeTimer > maxTime) - { - if (Owner.channel) - ResetToStart(); - else - { - Projectile.Kill(); - return; - } - } // Compute the weapon's charge. float chargeLevel = MathHelper.Clamp(Projectile.ai[0] / AdamantiteParticleAccelerator.ChargeFrames, 0f, 1f); - // Common code among holdouts to keep the holdout projectile directly in the player's hand - UpdatePlayerVisuals(player, rrp); - // Firing or charging? if (chargeLevel >= 1f) { @@ -96,8 +82,8 @@ namespace CalamityMod.Projectiles.Ranged FiringEffects(new Color(235, 40, 121)); if (Projectile.owner == Main.myPlayer) { - Projectile redLaser = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), NuzzlePosition, Projectile.rotation.ToRotationVector2(), ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0, 120); - redLaser.Center = NuzzlePosition; + Projectile redLaser = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, Projectile.rotation.ToRotationVector2(), ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0, 120); + redLaser.Center = GunTipPosition; } } @@ -107,8 +93,8 @@ namespace CalamityMod.Projectiles.Ranged FiringEffects(new Color(49, 161, 246)); if (Projectile.owner == Main.myPlayer) { - Projectile blueLaser = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), NuzzlePosition, Projectile.rotation.ToRotationVector2(), ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0, -120); - blueLaser.Center = NuzzlePosition; + Projectile blueLaser = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, Projectile.rotation.ToRotationVector2(), ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0, -120); + blueLaser.Center = GunTipPosition; } } DelayTimer += 1f; @@ -124,27 +110,12 @@ namespace CalamityMod.Projectiles.Ranged public CurveSegment oversquish = new CurveSegment(SineBumpEasing, 0.7f, 0f, -0.6f); internal float RecoilSquish => PiecewiseAnimation(1 - MathHelper.Clamp(BounceBackPower * 2f, 0f, 1f), new CurveSegment[] { unsquish, oversquish }); - private void UpdatePlayerVisuals(Player player, Vector2 rrp) - { - // Place the projectile directly into the player's hand at all times - Projectile.Center = rrp; - - // The gun is a holdout projectile, so change the player's variables to reflect that - player.ChangeDir(Math.Sign(Projectile.rotation.ToRotationVector2().X)); - player.heldProj = Projectile.whoAmI; - player.itemTime = 2; - player.itemAnimation = 2; - - player.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, Projectile.rotation - MathHelper.PiOver2); - - } - private void FiringEffects(Color color) { - SoundEngine.PlaySound(SoundID.Item92, NuzzlePosition); - SoundEngine.PlaySound(SoundID.Item60, NuzzlePosition); + SoundEngine.PlaySound(SoundID.Item92, GunTipPosition); + SoundEngine.PlaySound(SoundID.Item60, GunTipPosition); - Particle pulse = new DirectionalPulseRing(NuzzlePosition + Projectile.rotation.ToRotationVector2() * 5f, Vector2.Zero, color, new Vector2(0.5f, 1f), Projectile.rotation, 0.05f, 0.34f + Main.rand.NextFloat(0.3f), 30); + Particle pulse = new DirectionalPulseRing(GunTipPosition + Projectile.rotation.ToRotationVector2() * 5f, Vector2.Zero, color, new Vector2(0.5f, 1f), Projectile.rotation, 0.05f, 0.34f + Main.rand.NextFloat(0.3f), 30); GeneralParticleHandler.SpawnParticle(pulse); if (Owner == Main.LocalPlayer && Owner.Calamity().GeneralScreenShakePower < 5) @@ -174,7 +145,7 @@ namespace CalamityMod.Projectiles.Ranged public override bool PreKill(int timeLeft) { - if (Owner.channel) + if (!Owner.CantUseHoldout()) { ResetToStart(); return false; @@ -185,9 +156,20 @@ namespace CalamityMod.Projectiles.Ranged public void ResetToStart() { - Projectile.timeLeft = 900; ChargeTimer = 0f; DelayTimer = 0f; } + + public override void SendExtraAIHoldout(BinaryWriter writer) + { + writer.Write(ChargeRate); + writer.Write(BounceBackPower); + } + + public override void ReceiveExtraAIHoldout(BinaryReader reader) + { + ChargeRate = reader.ReadSingle(); + BounceBackPower = reader.ReadSingle(); + } } } diff --git a/Projectiles/Ranged/ArcNovaDiffuserHoldout.cs b/Projectiles/Ranged/ArcNovaDiffuserHoldout.cs index bc886a28f8..bfda144189 100644 --- a/Projectiles/Ranged/ArcNovaDiffuserHoldout.cs +++ b/Projectiles/Ranged/ArcNovaDiffuserHoldout.cs @@ -24,19 +24,16 @@ namespace CalamityMod.Projectiles.Ranged public static float BulletSpeed = 12f; public SlotId NovaChargeSlot; - private ref float CurrentChargingFrames => ref Projectile.ai[0]; - private ref float ShotsLoaded => ref Projectile.ai[1]; - private ref float ShootRecoilTimer => ref Projectile.ai[2]; // Dual functions for rapid fire shooting cooldown and recoil - private bool ChargeLV1 => CurrentChargingFrames >= ArcNovaDiffuser.Charge1Frames; - private bool ChargeLV2 => CurrentChargingFrames >= ArcNovaDiffuser.Charge2Frames; + public ref float CurrentChargingFrames => ref Projectile.ai[0]; + public ref float ShotsLoaded => ref Projectile.ai[1]; + public ref float ShootRecoilTimer => ref Projectile.ai[2]; // Dual functions for rapid fire shooting cooldown and recoil + public bool ChargeLV1 => CurrentChargingFrames >= ArcNovaDiffuser.Charge1Frames; + public bool ChargeLV2 => CurrentChargingFrames >= ArcNovaDiffuser.Charge2Frames; public override void KillHoldoutLogic() { - if (HeldItem.type != Owner.ActiveItem().type || Owner is null || !Owner.active || Owner.CCed || Owner.dead || Owner.noItems) - { + if (Owner.CantUseHoldout(false) || HeldItem.type != Owner.ActiveItem().type) Projectile.Kill(); - Projectile.netUpdate = true; - } } public override void HoldoutAI() @@ -74,8 +71,6 @@ namespace CalamityMod.Projectiles.Ranged ShotsLoaded = 0; ShootRecoilTimer = 24f; OffsetLengthFromArm -= 25f; - Projectile.netSpam = 0; - Projectile.netUpdate = true; } // Retracting recoil else if (ShootRecoilTimer > 0) @@ -107,8 +102,6 @@ namespace CalamityMod.Projectiles.Ranged ShotsLoaded--; ShootRecoilTimer = 16f; OffsetLengthFromArm -= 5f; - Projectile.netSpam = 0; - Projectile.netUpdate = true; } } // Retracting any remaining recoil diff --git a/Projectiles/Ranged/BloodfireArrowProj.cs b/Projectiles/Ranged/BloodfireArrowProj.cs index 822774e748..69a3118522 100644 --- a/Projectiles/Ranged/BloodfireArrowProj.cs +++ b/Projectiles/Ranged/BloodfireArrowProj.cs @@ -46,7 +46,7 @@ namespace CalamityMod.Projectiles.Ranged if (Projectile.localAI[0] == 0) { - player.statLife -= Main.player[Main.myPlayer].lifeSteal <= 0f ? 0 : 1; + player.statLife -= 1; if (player.statLife <= 0) { PlayerDeathReason pdr = PlayerDeathReason.ByCustomReason(CalamityUtils.GetText("Status.Death.BloodFireArrow" + Main.rand.Next(1, 2 + 1)).Format(player.name)); @@ -100,7 +100,7 @@ namespace CalamityMod.Projectiles.Ranged if (player.moonLeech) return; - if (Main.player[Main.myPlayer].lifeSteal <= 0f || target.lifeMax <= 5) + if (target.lifeMax <= 5) return; float lifeRatio = (float)player.statLife / player.statLifeMax2; diff --git a/Projectiles/Ranged/BloodfireBulletProj.cs b/Projectiles/Ranged/BloodfireBulletProj.cs index e4373bbc82..e45df960a2 100644 --- a/Projectiles/Ranged/BloodfireBulletProj.cs +++ b/Projectiles/Ranged/BloodfireBulletProj.cs @@ -81,8 +81,8 @@ namespace CalamityMod.Projectiles.Ranged // Returns the amount of bonus damage that should be dealt. Boosts life regeneration appropriately as a side effect. private int OnHitEffect(Player owner) { - // Adds 2 frames to lifeRegenTime on every hit. This increased value is used for the damage calculation. - owner.lifeRegenTime += 2; + // Adds 3 frames to lifeRegenTime on every hit. This increased value is used for the damage calculation. + owner.lifeRegenTime += 3; // Deals (1.00 + (0.1 * current lifeRegen))% of current lifeRegenTime as flat bonus damage on hit. // For example, at 0 life regen, you get 1% of lifeRegenTime as bonus damage. @@ -91,15 +91,16 @@ namespace CalamityMod.Projectiles.Ranged int regenForCalc = owner.lifeRegen > 0 ? owner.lifeRegen : 0; float regenDamageRatio = (1f + 0.1f * regenForCalc) / 100f; - // For the sake of bonus damage, life regen time caps at 3600, aka 60 seconds. This is its natural cap in vanilla. This then gets divided by 2 for computing final damage. - int regenTimeForCalc = (int)MathHelper.Clamp(owner.lifeRegenTime, 0f, 3600f) / 2; + // For the sake of bonus damage, life regen time caps at 3600, aka 60 seconds. This is its natural cap in vanilla. 75% of this is taken for computing the final damage. + int regenTimeForCalc = (int)(MathHelper.Clamp(owner.lifeRegenTime, 0f, 3600f) * 0.75f); int finalDamageBoost = (int)(regenDamageRatio * regenTimeForCalc); - // Damage boost has a cap of 25 to prevent it from getting too crazy. - if (finalDamageBoost > 25) - finalDamageBoost = 25; + // Damage boost has a cap of 35 to prevent it from getting too crazy. + int damageCap = 35; + if (finalDamageBoost > damageCap) + finalDamageBoost = damageCap; - if (finalDamageBoost == 25) // Special hit visual if youre at max bonus damage + if (finalDamageBoost == damageCap) // Special hit visual if the bonus damage is at the cap. { for (int k = 0; k < 3; k++) { diff --git a/Projectiles/Ranged/BrimstoneFireFriendly.cs b/Projectiles/Ranged/BrimstoneFireFriendly.cs index 60828b0eef..e419809b56 100644 --- a/Projectiles/Ranged/BrimstoneFireFriendly.cs +++ b/Projectiles/Ranged/BrimstoneFireFriendly.cs @@ -15,7 +15,7 @@ namespace CalamityMod.Projectiles.Ranged public override string Texture => "CalamityMod/Projectiles/FireProj"; public static int Lifetime => 60; - public static int Fadetime => 80; + public static int Fadetime => 50; public ref float Time => ref Projectile.ai[0]; public int MistType = -1; diff --git a/Projectiles/Ranged/CinderArrowProj.cs b/Projectiles/Ranged/CinderArrowProj.cs index 3b599fa134..cfd82c1257 100644 --- a/Projectiles/Ranged/CinderArrowProj.cs +++ b/Projectiles/Ranged/CinderArrowProj.cs @@ -15,7 +15,8 @@ namespace CalamityMod.Projectiles.Ranged public override string Texture => "CalamityMod/Items/Ammo/CinderArrow"; public ref float Time => ref Projectile.ai[1]; - public bool isShrapnel => Projectile.ai[2] > 0f; + public ref float isSplit => ref Projectile.ai[2]; + public bool splitShot = false; public override void SetStaticDefaults() { @@ -41,13 +42,23 @@ namespace CalamityMod.Projectiles.Ranged { Time++; Projectile.rotation = Projectile.velocity.ToRotation() - MathHelper.PiOver2; - if (isShrapnel) + + if (isSplit > 0) { + Projectile.netUpdate = true; + splitShot = true; + } + + if (splitShot) + { + Lighting.AddLight(Projectile.Center, Color.Red.ToVector3() * 0.15f); if (Main.rand.NextBool(4)) { Dust dust = Dust.NewDustPerfect(Projectile.Center + Projectile.velocity * 2, 90, -Projectile.velocity * Main.rand.NextFloat(0.1f, 0.55f)); dust.noGravity = true; dust.scale = Main.rand.NextFloat(0.65f, 0.85f); + dust.noLight = true; + dust.noLightEmittence = true; } } else @@ -72,7 +83,7 @@ namespace CalamityMod.Projectiles.Ranged public override void OnKill(int timeLeft) { - if (!isShrapnel) + if (!splitShot) { int Dusts = 9; float radians = MathHelper.TwoPi / Dusts; @@ -90,14 +101,14 @@ namespace CalamityMod.Projectiles.Ranged for (int b = 0; b < 3; b++) { - Vector2 velocity = Vector2.UnitY.RotatedByRandom(0.8f) * Main.rand.NextFloat(-2.75f, -2.25f); - Projectile shrapnel = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.1f), 0f, Projectile.owner, ai2: 1f); + Vector2 velocity = Vector2.UnitY.RotatedByRandom(0.8f) * Main.rand.NextFloat(-3.5f, -3f); + Projectile shrapnel = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.06f), 0f, Projectile.owner, ai2: 1f); shrapnel.timeLeft = 300; shrapnel.arrow = false; shrapnel.MaxUpdates = 4; } - Projectile.damage = (int)(Projectile.damage * 0.5f); + Projectile.damage = (int)(Projectile.damage * 0.4f); Projectile.penetrate = -1; Projectile.ExpandHitboxBy(110); Projectile.Damage(); @@ -105,17 +116,17 @@ namespace CalamityMod.Projectiles.Ranged } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - if (isShrapnel) + if (splitShot) { target.AddBuff(ModContent.BuffType(), 180); } } public override bool PreDraw(ref Color lightColor) { - if (isShrapnel) + if (splitShot) { Texture2D texture = ModContent.Request("CalamityMod/Particles/DrainLine").Value; - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], Color.Crimson * 0.35f, 1, texture); + CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], Color.Crimson * 0.3f, 1, texture); return false; } else @@ -127,6 +138,6 @@ namespace CalamityMod.Projectiles.Ranged } } - public override bool? CanDamage() => isShrapnel && Time < 20 ? false : null; + public override bool? CanDamage() => splitShot && Time < 20 ? false : null; } } diff --git a/Projectiles/Ranged/CondemnationHoldout.cs b/Projectiles/Ranged/CondemnationHoldout.cs index 04693f2c48..adb6c6d397 100644 --- a/Projectiles/Ranged/CondemnationHoldout.cs +++ b/Projectiles/Ranged/CondemnationHoldout.cs @@ -1,18 +1,20 @@ -using CalamityMod.Items.Weapons.Ranged; -using CalamityMod.Sounds; +using System.IO; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class CondemnationHoldout : ModProjectile + public class CondemnationHoldout : BaseGunHoldoutProjectile { - public override LocalizedText DisplayName => CalamityUtils.GetItemName(); - private Player Owner => Main.player[Projectile.owner]; + public override int AssociatedItemID => ModContent.ItemType(); + public override float MaxOffsetLengthFromArm => 25f; + public override float OffsetXUpwards => -5f; + public override float BaseOffsetY => -5f; private ref float CurrentChargingFrames => ref Projectile.ai[0]; private ref float ArrowsLoaded => ref Projectile.ai[1]; @@ -22,24 +24,8 @@ namespace CalamityMod.Projectiles.Ranged public const float velocityMultiplier = 1.2f; public bool homing = false; - public override string Texture => "CalamityMod/Items/Weapons/Ranged/Condemnation"; - - public override void SetDefaults() + public override void KillHoldoutLogic() { - Projectile.width = 130; - Projectile.height = 42; - Projectile.friendly = true; - Projectile.penetrate = -1; - Projectile.tileCollide = false; - Projectile.DamageType = DamageClass.Ranged; - Projectile.ignoreWater = true; - } - - public override void AI() - { - Vector2 armPosition = Owner.RotatedRelativePoint(Owner.MountedCenter, true); - Vector2 tipPosition = armPosition + Projectile.velocity * Projectile.width * 0.5f; - // Fire arrows if the owner stops channeling or otherwise cannot use the weapon. if (Owner.CantUseHoldout()) { @@ -51,65 +37,61 @@ namespace CalamityMod.Projectiles.Ranged } // Fire one charged arrow every frame until you're out of arrows. - ShootProjectiles(tipPosition, homing); + ShootProjectiles(homing); --ArrowsLoaded; if (ArrowsLoaded == 0 && homing == true) homing = false; } - else + } + + public override void HoldoutAI() + { + // Frame 1 effects: Record how fast the Condemnation item being used is, to determine how fast to load arrows. + if (FramesToLoadNextArrow == 0f) { + SoundEngine.PlaySound(SoundID.Item20, Projectile.Center); + FramesToLoadNextArrow = HeldItem.useAnimation; + } - // Frame 1 effects: Record how fast the Condemnation item being used is, to determine how fast to load arrows. - if (FramesToLoadNextArrow == 0f) + // If no arrows are loaded, spawn a bit of dust to indicate it's not ready yet. + // Spawn the same dust if the max number of arrows have been loaded or the player ran out of ammos to load. + if (ArrowsLoaded <= 0f || ArrowsLoaded >= Condemnation.MaxLoadedArrows || !Owner.HasAmmo(Owner.ActiveItem())) + SpawnCannotLoadArrowsDust(GunTipPosition); + + if (Owner.HasAmmo(HeldItem)) + { + // Actually make progress towards loading more arrows. + ++CurrentChargingFrames; + + // If it is time to load an arrow, produce a pulse of dust and add an arrow. + // Also accelerate charging, because it's fucking awesome. + // Take the ammo here as well + if (CurrentChargingFrames >= FramesToLoadNextArrow && ArrowsLoaded < Condemnation.MaxLoadedArrows) { - SoundEngine.PlaySound(SoundID.Item20, Projectile.Center); - FramesToLoadNextArrow = Owner.ActiveItem().useAnimation; - } + // Save the stats here for later + Owner.PickAmmo(HeldItem, out _, out float shootSpeed, out int damage, out float knockback, out _); + Projectile.damage = damage; + Projectile.knockBack = knockback; + storedVelocity = shootSpeed * velocityMultiplier; - // If no arrows are loaded, spawn a bit of dust to indicate it's not ready yet. - // Spawn the same dust if the max number of arrows have been loaded or the player ran out of ammos to load. - if (ArrowsLoaded <= 0f || ArrowsLoaded >= Condemnation.MaxLoadedArrows || !Owner.HasAmmo(Owner.ActiveItem())) - SpawnCannotLoadArrowsDust(tipPosition); + SpawnArrowLoadedDust(); + CurrentChargingFrames = 0f; + ++ArrowsLoaded; + --FramesToLoadNextArrow; - if (Owner.HasAmmo(Owner.ActiveItem())) - { - // Actually make progress towards loading more arrows. - ++CurrentChargingFrames; + // Play a sound for additional notification that an arrow has been loaded. + var loadSound = SoundEngine.PlaySound(SoundID.Item108 with { Volume = SoundID.Item108.Volume * 0.3f }); - // If it is time to load an arrow, produce a pulse of dust and add an arrow. - // Also accelerate charging, because it's fucking awesome. - // Take the ammo here as well - if (CurrentChargingFrames >= FramesToLoadNextArrow && ArrowsLoaded < Condemnation.MaxLoadedArrows) + if (ArrowsLoaded >= Condemnation.MaxLoadedArrows) { - // Save the stats here for later - Item heldItem = Owner.ActiveItem(); - Owner.PickAmmo(heldItem, out _, out float shootSpeed, out int damage, out float knockback, out _); - Projectile.damage = damage; - Projectile.knockBack = knockback; - storedVelocity = shootSpeed * velocityMultiplier; - - SpawnArrowLoadedDust(tipPosition); - CurrentChargingFrames = 0f; - ++ArrowsLoaded; - --FramesToLoadNextArrow; - - // Play a sound for additional notification that an arrow has been loaded. - var loadSound = SoundEngine.PlaySound(SoundID.Item108 with { Volume = SoundID.Item108.Volume * 0.3f }); - - if (ArrowsLoaded >= Condemnation.MaxLoadedArrows) - { - SoundEngine.PlaySound(new("CalamityMod/Sounds/Custom/AbilitySounds/BrimflameRecharge")); - homing = true; - } + SoundEngine.PlaySound(new("CalamityMod/Sounds/Custom/AbilitySounds/BrimflameRecharge")); + homing = true; } } } - - UpdateProjectileHeldVariables(armPosition); - ManipulatePlayerVariables(); } - public void SpawnArrowLoadedDust(Vector2 tipPosition) + public void SpawnArrowLoadedDust() { if (Main.dedServ) return; @@ -126,7 +108,7 @@ namespace CalamityMod.Projectiles.Ranged Vector2 end = nextAngle.ToRotationVector2(); for (int j = 0; j < 40; j++) { - Dust starDust = Dust.NewDustPerfect(tipPosition, 267); + Dust starDust = Dust.NewDustPerfect(GunTipPosition, 267); starDust.scale = 2.5f; starDust.velocity = Vector2.Lerp(start, end, j / 40f) * 16f; starDust.color = Color.Crimson; @@ -138,7 +120,7 @@ namespace CalamityMod.Projectiles.Ranged for (int i = 0; i < 36; i++) { - Dust chargeMagic = Dust.NewDustPerfect(tipPosition, 267); + Dust chargeMagic = Dust.NewDustPerfect(GunTipPosition, 267); chargeMagic.velocity = (MathHelper.TwoPi * i / 36f).ToRotationVector2() * 5f + Owner.velocity; chargeMagic.scale = Main.rand.NextFloat(1f, 1.5f); chargeMagic.color = Color.Violet; @@ -146,62 +128,43 @@ namespace CalamityMod.Projectiles.Ranged } } - public void SpawnCannotLoadArrowsDust(Vector2 tipPosition) + public void SpawnCannotLoadArrowsDust(Vector2 GunTipPosition) { if (Main.dedServ) return; for (int i = 0; i < 2; i++) { - Dust chargeMagic = Dust.NewDustPerfect(tipPosition + Main.rand.NextVector2Circular(20f, 20f), 267); - chargeMagic.velocity = (tipPosition - chargeMagic.position) * 0.1f + Owner.velocity; + Dust chargeMagic = Dust.NewDustPerfect(GunTipPosition + Main.rand.NextVector2Circular(20f, 20f), 267); + chargeMagic.velocity = (GunTipPosition - chargeMagic.position) * 0.1f + Owner.velocity; chargeMagic.scale = Main.rand.NextFloat(1f, 1.5f); chargeMagic.color = Projectile.GetAlpha(Color.White); chargeMagic.noGravity = true; } } - public void ShootProjectiles(Vector2 tipPosition, bool homing) + public void ShootProjectiles(bool homing) { if (Main.myPlayer != Projectile.owner) return; Vector2 shootVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * storedVelocity; int ArrowType = homing ? ModContent.ProjectileType() : ModContent.ProjectileType(); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), tipPosition, shootVelocity, ArrowType, Projectile.damage, Projectile.knockBack, Projectile.owner); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity, ArrowType, Projectile.damage, Projectile.knockBack, Projectile.owner); } - private void UpdateProjectileHeldVariables(Vector2 armPosition) + public override void SendExtraAIHoldout(BinaryWriter writer) { - if (Main.myPlayer == Projectile.owner) - { - float interpolant = Utils.GetLerpValue(5f, 25f, Projectile.Distance(Main.MouseWorld), true); - Vector2 oldVelocity = Projectile.velocity; - Projectile.velocity = Vector2.Lerp(Projectile.velocity, Projectile.SafeDirectionTo(Main.MouseWorld), interpolant); - if (Projectile.velocity != oldVelocity) - { - Projectile.netSpam = 0; - Projectile.netUpdate = true; - } - } - - Projectile.position = armPosition - Projectile.Size * 0.5f; - Projectile.rotation = Projectile.velocity.ToRotation(); - if (Projectile.spriteDirection == -1) - Projectile.rotation += MathHelper.Pi; - Projectile.spriteDirection = Projectile.direction; - Projectile.timeLeft = 2; + writer.Write(FramesToLoadNextArrow); + writer.Write(storedVelocity); + writer.Write(homing); } - private void ManipulatePlayerVariables() + public override void ReceiveExtraAIHoldout(BinaryReader reader) { - Owner.ChangeDir(Projectile.direction); - Owner.heldProj = Projectile.whoAmI; - Owner.itemTime = 2; - Owner.itemAnimation = 2; - Owner.itemRotation = (Projectile.velocity * Projectile.direction).ToRotation(); + FramesToLoadNextArrow = reader.ReadSingle(); + storedVelocity = reader.ReadSingle(); + homing = reader.ReadBoolean(); } - - public override bool? CanDamage() => false; } } diff --git a/Projectiles/Ranged/DryadsTearMain.cs b/Projectiles/Ranged/DryadsTearMain.cs index 5676aded04..2002b27fe6 100644 --- a/Projectiles/Ranged/DryadsTearMain.cs +++ b/Projectiles/Ranged/DryadsTearMain.cs @@ -60,7 +60,7 @@ namespace CalamityMod.Projectiles.Ranged for (int b = 0; b < 2; b++) { Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.3), 0f, Projectile.owner, 0f, 0f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.1), 0f, Projectile.owner, 0f, 0f); } for (int i = 0; i < 3; i++) { diff --git a/Projectiles/Ranged/DryadsTearSplit.cs b/Projectiles/Ranged/DryadsTearSplit.cs index 92d247019b..6b712b70a2 100644 --- a/Projectiles/Ranged/DryadsTearSplit.cs +++ b/Projectiles/Ranged/DryadsTearSplit.cs @@ -27,6 +27,7 @@ namespace CalamityMod.Projectiles.Ranged Projectile.timeLeft = 210; Projectile.extraUpdates = 1; Projectile.tileCollide = false; + Projectile.ArmorPenetration = 10; AIType = ProjectileID.Bullet; } diff --git a/Projectiles/Ranged/ElementalEruptionHouldout.cs b/Projectiles/Ranged/ElementalEruptionHouldout.cs index e3c445aa01..bb8f4c68f1 100644 --- a/Projectiles/Ranged/ElementalEruptionHouldout.cs +++ b/Projectiles/Ranged/ElementalEruptionHouldout.cs @@ -1,4 +1,5 @@ -using CalamityMod.Items.Weapons.Ranged; +using System.IO; +using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; using Terraria; @@ -17,19 +18,16 @@ namespace CalamityMod.Projectiles.Ranged public override float BaseOffsetY => -5f; public override float OffsetYDownwards => 10f; - private ref float ShotCooldown => ref Projectile.ai[0]; - private ref float ShotsFired => ref Projectile.ai[1]; - private ref float ShootTimer => ref Projectile.ai[2]; - public int FireBlobs = 0; + public ref float ShotCooldown => ref Projectile.ai[0]; + public ref float ShotsFired => ref Projectile.ai[1]; + public ref float ShootTimer => ref Projectile.ai[2]; + public int FireBlobs { get; set; } public override void KillHoldoutLogic() { base.KillHoldoutLogic(); if (ShotsFired >= 24) - { Projectile.Kill(); - Projectile.netUpdate = true; - } } public override void HoldoutAI() @@ -91,5 +89,9 @@ namespace CalamityMod.Projectiles.Ranged base.OnSpawn(source); SoundEngine.PlaySound(SoundID.Item73 with { Volume = 0.7f }, Projectile.Center); } + + public override void SendExtraAIHoldout(BinaryWriter writer) => writer.Write(FireBlobs); + + public override void ReceiveExtraAIHoldout(BinaryReader reader) => FireBlobs = reader.ReadInt32(); } } diff --git a/Projectiles/Ranged/FlakKrakenHoldout.cs b/Projectiles/Ranged/FlakKrakenHoldout.cs index 2eaeff6f2a..362c7e66a2 100644 --- a/Projectiles/Ranged/FlakKrakenHoldout.cs +++ b/Projectiles/Ranged/FlakKrakenHoldout.cs @@ -134,8 +134,6 @@ namespace CalamityMod.Projectiles.Ranged SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Item/FlakKrakenShoot") { Volume = 0.6f }, GunTipPosition); } - - NetUpdate(); } // When it has shot all the projectiles in the burst, reset all the variables and back to shooting. @@ -143,7 +141,6 @@ namespace CalamityMod.Projectiles.Ranged { ShootingTimer = 0f; TimerBetweenBursts = 0f; - NetUpdate(); } } @@ -155,12 +152,5 @@ namespace CalamityMod.Projectiles.Ranged base.OnSpawn(source); FrontArmStretch = Player.CompositeArmStretchAmount.ThreeQuarters; } - - public void NetUpdate() - { - Projectile.netUpdate = true; - if (Projectile.netSpam >= 10) - Projectile.netSpam = 9; - } } } diff --git a/Projectiles/Ranged/FlakKrakenProjectile.cs b/Projectiles/Ranged/FlakKrakenProjectile.cs index 962a9ba3c5..98db63bb3b 100644 --- a/Projectiles/Ranged/FlakKrakenProjectile.cs +++ b/Projectiles/Ranged/FlakKrakenProjectile.cs @@ -61,6 +61,8 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { + Owner ??= Main.player[Projectile.owner]; + // Enforces the gravity. if (IsShrapnel) { @@ -124,15 +126,9 @@ namespace CalamityMod.Projectiles.Ranged trailDust.noGravity = true; trailDust.noLight = true; trailDust.alpha = (int)Utils.Remap(Projectile.timeLeft, 30f, 0f, 127f, 0f); - - Lighting.AddLight(Projectile.Center, Color.White.ToVector3() * (IsShrapnel ? 0.3f : 1f)); } - public override void OnSpawn(IEntitySource source) - { - Owner = Main.player[Projectile.owner]; - Projectile.scale = 1.5f; - } + public override void OnSpawn(IEntitySource source) => Projectile.scale = 1.5f; public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { @@ -169,7 +165,7 @@ namespace CalamityMod.Projectiles.Ranged { bool usedClusterRockets = RocketID == ItemID.ClusterRocketI || RocketID == ItemID.ClusterRocketII; int flakAmount = usedClusterRockets ? ClusterShrapnelAmount : ShrapnelAmount; - for (int i = 0; i < flakAmount; i++) + for (int i = 0; i < flakAmount && Main.myPlayer == Projectile.owner; i++) { Projectile shrapnel = Projectile.NewProjectileDirect( Projectile.GetSource_FromThis(), diff --git a/Projectiles/Ranged/FlakToxicannonHoldout.cs b/Projectiles/Ranged/FlakToxicannonHoldout.cs index 05b47dfeeb..1bf6ce82a7 100644 --- a/Projectiles/Ranged/FlakToxicannonHoldout.cs +++ b/Projectiles/Ranged/FlakToxicannonHoldout.cs @@ -135,7 +135,7 @@ namespace CalamityMod.Projectiles.Ranged } ShootingTimer = 0f; - Projectile.netUpdate = true; + } ShootingTimer++; diff --git a/Projectiles/Ranged/FlakToxicannonProjectile.cs b/Projectiles/Ranged/FlakToxicannonProjectile.cs index 01b0f9336b..a01cdd3535 100644 --- a/Projectiles/Ranged/FlakToxicannonProjectile.cs +++ b/Projectiles/Ranged/FlakToxicannonProjectile.cs @@ -59,6 +59,8 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { + Owner ??= Main.player[Projectile.owner]; + // Enforces the gravity. if (IsShrapnel) { @@ -119,11 +121,7 @@ namespace CalamityMod.Projectiles.Ranged Lighting.AddLight(Projectile.Center, Color.GreenYellow.ToVector3() * (IsShrapnel ? 1.5f : 2.5f)); } - public override void OnSpawn(IEntitySource source) - { - Owner = Main.player[Projectile.owner]; - Projectile.scale = 1.5f; - } + public override void OnSpawn(IEntitySource source) => Projectile.scale = 1.5f; public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { @@ -160,7 +158,7 @@ namespace CalamityMod.Projectiles.Ranged { bool usedClusterRockets = RocketID == ItemID.ClusterRocketI || RocketID == ItemID.ClusterRocketII; int flakAmount = usedClusterRockets ? ClusterShrapnelAmount : ShrapnelAmount; - for (int i = 0; i < flakAmount; i++) + for (int i = 0; i < flakAmount && Main.myPlayer == Projectile.owner; i++) { Projectile shrapnel = Projectile.NewProjectileDirect( Projectile.GetSource_FromThis(), diff --git a/Projectiles/Ranged/HailstormBulletProj.cs b/Projectiles/Ranged/HailstormBulletProj.cs index 66721fffd5..ac240f4e5d 100644 --- a/Projectiles/Ranged/HailstormBulletProj.cs +++ b/Projectiles/Ranged/HailstormBulletProj.cs @@ -1,4 +1,5 @@ -using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; @@ -59,7 +60,7 @@ namespace CalamityMod.Projectiles.Ranged rotIncrease += 0.1f * (rotDirection ? -1 : 1); - Projectile.velocity *= 0.982f; + Projectile.velocity *= 0.984f; if (Projectile.localAI[0] > 100f && Projectile.localAI[0] < 300 && Projectile.localAI[0] % 9 == 0) { @@ -71,12 +72,15 @@ namespace CalamityMod.Projectiles.Ranged public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { Player Owner = Main.player[Projectile.owner]; - target.AddBuff(BuffID.Frostburn, 120); + target.AddBuff(BuffID.Frostburn2, 120); if (hit.Crit) { SoundStyle crit = new("CalamityMod/Sounds/NPCHit/CryogenPhaseTransitionCrack"); SoundEngine.PlaySound(crit with { Volume = 0.35f, Pitch = 1f }, Projectile.Center); - target.AddBuff(BuffID.Frostburn2, 300); + + if (!target.boss) + target.AddBuff(ModContent.BuffType(), 120); + int points = 6; float radians = MathHelper.TwoPi / points; Vector2 spinningPoint = Vector2.Normalize(new Vector2(-1f, -1f)); @@ -88,7 +92,7 @@ namespace CalamityMod.Projectiles.Ranged WaterFlavoredParticle subTrail = new WaterFlavoredParticle(Projectile.Center + velocity * 4.5f + addedPlacement, velocity * 7, false, 6, 0.65f, Color.SkyBlue); GeneralParticleHandler.SpawnParticle(subTrail); } - int onHitDamage = Owner.CalcIntDamage(0.36f * Projectile.damage); + int onHitDamage = (int)(Projectile.damage * 0.5f); Owner.ApplyDamageToNPC(target, onHitDamage, 0f, 0, false); } } diff --git a/Projectiles/Ranged/HolyFireBulletProj.cs b/Projectiles/Ranged/HolyFireBulletProj.cs index 97da541fc2..d02a941194 100644 --- a/Projectiles/Ranged/HolyFireBulletProj.cs +++ b/Projectiles/Ranged/HolyFireBulletProj.cs @@ -81,7 +81,7 @@ namespace CalamityMod.Projectiles.Ranged public override void OnKill(int timeLeft) { - // Spawn an on-hit explosion which deals 75% of the projectile's damage. + // Spawn an on-hit explosion which deals 30% of the projectile's damage. if (Projectile.owner == Main.myPlayer) { Projectile.damage = (int)(Projectile.damage * HolyFireBullet.ExplosionMultiplier); diff --git a/Projectiles/Ranged/HyperiusBulletProj.cs b/Projectiles/Ranged/HyperiusBulletProj.cs index 8a5405821b..0399e05bd4 100644 --- a/Projectiles/Ranged/HyperiusBulletProj.cs +++ b/Projectiles/Ranged/HyperiusBulletProj.cs @@ -108,7 +108,7 @@ namespace CalamityMod.Projectiles.Ranged { for (int b = 0; b < 3; b++) { - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, -oldVelocity.RotatedByRandom(0.5f) * 0.7f, ModContent.ProjectileType(), (int)(Projectile.damage * 0.35), 0f, Projectile.owner, 0f, 0f, Main.rand.Next(0, 4 + 1)); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, -oldVelocity.RotatedByRandom(0.5f) * 0.7f, ModContent.ProjectileType(), (int)(Projectile.damage * 0.1), 0f, Projectile.owner, 0f, 0f, Main.rand.Next(0, 4 + 1)); } } return true; @@ -130,7 +130,7 @@ namespace CalamityMod.Projectiles.Ranged for (int b = 0; b < 3; b++) { Vector2 velocity = Projectile.velocity.RotatedByRandom(0.5f); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity * 0.7f, ModContent.ProjectileType(), (int)(Projectile.damage * 0.15), Projectile.knockBack * 2f, Projectile.owner, 0f, 0f, Main.rand.Next(0, 4 + 1)); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity * 0.7f, ModContent.ProjectileType(), (int)(Projectile.damage * 0.1), Projectile.knockBack * 2f, Projectile.owner, 0f, 0f, Main.rand.Next(0, 4 + 1)); } } } diff --git a/Projectiles/Ranged/IcicleArrowProj.cs b/Projectiles/Ranged/IcicleArrowProj.cs index 45dc5b612d..8e49752c80 100644 --- a/Projectiles/Ranged/IcicleArrowProj.cs +++ b/Projectiles/Ranged/IcicleArrowProj.cs @@ -27,7 +27,7 @@ namespace CalamityMod.Projectiles.Ranged Projectile.extraUpdates = 6; Projectile.timeLeft = 1000; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 15 * Projectile.extraUpdates; + Projectile.localNPCHitCooldown = 15 * Projectile.MaxUpdates; Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } @@ -119,10 +119,10 @@ namespace CalamityMod.Projectiles.Ranged public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { if (falling) - modifiers.SourceDamage *= 1.35f; + modifiers.SourceDamage *= 1.1f; if (Projectile.numHits > 1 && falling) - Projectile.damage = (int)(Projectile.damage * 0.6f); + Projectile.damage = (int)(Projectile.damage * 0.5f); if (Projectile.damage < 1) Projectile.damage = 1; } @@ -149,6 +149,7 @@ namespace CalamityMod.Projectiles.Ranged dust2.noGravity = false; } Projectile.velocity = new Vector2(0, -6.5f).RotatedByRandom(0.25f) * Main.rand.NextFloat(0.75f, 1.1f); + Projectile.tileCollide = false; return false; } else diff --git a/Projectiles/Ranged/MagnaCannonHoldout.cs b/Projectiles/Ranged/MagnaCannonHoldout.cs index 46cd0b8502..ef4ea8c38e 100644 --- a/Projectiles/Ranged/MagnaCannonHoldout.cs +++ b/Projectiles/Ranged/MagnaCannonHoldout.cs @@ -1,67 +1,48 @@ -using System; -using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Particles; +using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using ReLogic.Utilities; using Terraria; using Terraria.Audio; -using Terraria.Localization; +using Terraria.GameContent; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class MagnaCannonHoldout : ModProjectile + public class MagnaCannonHoldout : BaseGunHoldoutProjectile { - // Take the name and texture from the weapon - public override LocalizedText DisplayName => CalamityUtils.GetItemName(); - public override string Texture => "CalamityMod/Items/Weapons/Ranged/MagnaCannon"; - - public static int FramesPerLoad = 9; - public static int MaxLoadableShots = 20; - public static float BulletSpeed = 12f; - - private Player Owner => Main.player[Projectile.owner]; - public SlotId MagnaChargeSlot; + public override int AssociatedItemID => ModContent.ItemType(); + public override float MaxOffsetLengthFromArm => 20f; + public override float OffsetXUpwards => -5f; + public override float BaseOffsetY => -5f; private ref float CurrentChargingFrames => ref Projectile.ai[0]; private ref float ShotsLoaded => ref Projectile.ai[1]; private ref float ShootTimer => ref Projectile.ai[2]; private bool FullyCharged => CurrentChargingFrames >= MagnaCannon.FullChargeFrames; - public int Time = 0; + public SlotId MagnaChargeSlot; + public static int FramesPerLoad = 9; + public static int MaxLoadableShots = 20; + public static float BulletSpeed = 12f; - public override void SetDefaults() + public override void KillHoldoutLogic() { - Projectile.width = 58; - Projectile.height = 30; - Projectile.friendly = true; - Projectile.tileCollide = false; - Projectile.DamageType = DamageClass.Ranged; - Projectile.ignoreWater = true; + if (Owner.CantUseHoldout(false) || HeldItem.type != Owner.ActiveItem().type) + Projectile.Kill(); } - public override void AI() + public override void HoldoutAI() { - Time++; - if (Time == 1) - Projectile.alpha = 255; - else - Projectile.alpha = 0; - - if (Owner.dead) // destroy the holdout if the player dies - { - Projectile.Kill(); - return; - } - - Vector2 armPosition = Owner.RotatedRelativePoint(Owner.MountedCenter, true); - Vector2 tipPosition = armPosition + Projectile.velocity * Projectile.width * 0.9f; - if (SoundEngine.TryGetActiveSound(MagnaChargeSlot, out var ChargeSound) && ChargeSound.IsPlaying) ChargeSound.Position = Projectile.Center; // Fire if the owner stops channeling or otherwise cannot use the weapon. if (Owner.CantUseHoldout()) { + KeepRefreshingLifetime = false; + if (ShotsLoaded > 0) { // While bullets are remaining, refresh the lifespan; it will not refresh again after bullets run out @@ -75,24 +56,19 @@ namespace CalamityMod.Projectiles.Ranged SoundEngine.PlaySound(MagnaCannon.Fire, Projectile.position); Vector2 shootVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * BulletSpeed; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), tipPosition, shootVelocity.RotatedByRandom(MathHelper.ToRadians(9f)), ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack * (FullyCharged ? 3 : 1), Projectile.owner); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity.RotatedByRandom(MathHelper.ToRadians(9f)), ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack * (FullyCharged ? 3 : 1), Projectile.owner); for (int i = 0; i <= 3; i++) { - Dust dust = Dust.NewDustPerfect(tipPosition, 187, shootVelocity.RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.9f, 1.2f), 0, default, Main.rand.NextFloat(1.5f, 2.3f)); + Dust dust = Dust.NewDustPerfect(GunTipPosition, 187, shootVelocity.RotatedByRandom(MathHelper.ToRadians(15f)) * Main.rand.NextFloat(0.9f, 1.2f), 0, default, Main.rand.NextFloat(1.5f, 2.3f)); dust.noGravity = true; } ShotsLoaded--; - ShootTimer = (FullyCharged ? 4f : 5f); - Projectile.netSpam = 0; - Projectile.netUpdate = true; + ShootTimer = FullyCharged ? 4f : 5f; } } else { - // While channeled, keep refreshing the projectile lifespan - Projectile.timeLeft = 2; - // Loads shots until maxed out if (ShotsLoaded < MaxLoadableShots && CurrentChargingFrames % FramesPerLoad == 0) ShotsLoaded++; @@ -116,13 +92,13 @@ namespace CalamityMod.Projectiles.Ranged { if (!FullyCharged) { - Particle streak = new ManaDrainStreak(Owner, Main.rand.NextFloat(0.06f + (CurrentChargingFrames / 180), 0.08f + (CurrentChargingFrames / 180)), Main.rand.NextVector2CircularEdge(2f, 2f) * Main.rand.NextFloat(0.3f * CurrentChargingFrames, 0.3f * CurrentChargingFrames), 0f, Color.White, Color.Aqua, 7, tipPosition); + Particle streak = new ManaDrainStreak(Owner, Main.rand.NextFloat(0.06f + (CurrentChargingFrames / 180), 0.08f + (CurrentChargingFrames / 180)), Main.rand.NextVector2CircularEdge(2f, 2f) * Main.rand.NextFloat(0.3f * CurrentChargingFrames, 0.3f * CurrentChargingFrames), 0f, Color.White, Color.Aqua, 7, GunTipPosition); GeneralParticleHandler.SpawnParticle(streak); } float orbScale = MathHelper.Clamp(CurrentChargingFrames, 0f, MagnaCannon.FullChargeFrames); - Particle orb = new GenericBloom(tipPosition, Projectile.velocity, Color.DarkBlue, orbScale / 135f, 2); + Particle orb = new GenericBloom(GunTipPosition, Projectile.velocity, Color.DarkBlue, orbScale / 135f, 2); GeneralParticleHandler.SpawnParticle(orb); - Particle orb2 = new GenericBloom(tipPosition, Projectile.velocity, Color.Aqua, orbScale / 200f, 2); + Particle orb2 = new GenericBloom(GunTipPosition, Projectile.velocity, Color.Aqua, orbScale / 200f, 2); GeneralParticleHandler.SpawnParticle(orb2); } @@ -131,49 +107,38 @@ namespace CalamityMod.Projectiles.Ranged { for (int i = 0; i < 36; i++) { - Dust chargefull = Dust.NewDustPerfect(tipPosition, 160); + Dust chargefull = Dust.NewDustPerfect(GunTipPosition, 160); chargefull.velocity = (MathHelper.TwoPi * i / 36f).ToRotationVector2() * 18f + Owner.velocity; chargefull.scale = Main.rand.NextFloat(1f, 1.5f); chargefull.noGravity = true; } } } - UpdateProjectileHeldVariables(armPosition); - ManipulatePlayerVariables(); } - private void UpdateProjectileHeldVariables(Vector2 armPosition) - { - if (Main.myPlayer == Projectile.owner) - { - float interpolant = Utils.GetLerpValue(5f, 40f, Projectile.Distance(Main.MouseWorld), true); - Vector2 oldVelocity = Projectile.velocity; - Projectile.velocity = Vector2.Lerp(Projectile.velocity, Projectile.SafeDirectionTo(Main.MouseWorld), interpolant); - } - Projectile.Center = armPosition + Projectile.velocity * 20; - Projectile.rotation = Projectile.velocity.ToRotation() + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f); - Projectile.spriteDirection = Projectile.direction; - - // Rumble (only while channeling) - float rumble = MathHelper.Clamp(CurrentChargingFrames, 0f, MagnaCannon.FullChargeFrames); - if (!Owner.CantUseHoldout()) - Projectile.position += Main.rand.NextVector2Circular(rumble / 43f, rumble / 43f); - } - - private void ManipulatePlayerVariables() - { - Owner.ChangeDir(Projectile.direction); - Owner.heldProj = Projectile.whoAmI; - Owner.itemTime = 2; - Owner.itemAnimation = 2; - Owner.itemRotation = (Projectile.velocity * Projectile.direction).ToRotation(); - } public override void OnKill(int timeLeft) { if (SoundEngine.TryGetActiveSound(MagnaChargeSlot, out var ChargeSound)) ChargeSound?.Stop(); } - public override bool? CanDamage() => false; + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = TextureAssets.Projectile[Type].Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f); + Vector2 rotationPoint = texture.Size() * 0.5f; + SpriteEffects flipSprite = (Projectile.spriteDirection * Owner.gravDir == -1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + if (!Owner.CantUseHoldout()) + { + float rumble = MathHelper.Clamp(CurrentChargingFrames, 0f, MagnaCannon.FullChargeFrames); + drawPosition += Main.rand.NextVector2Circular(rumble / 43f, rumble / 43f); + } + + Main.EntitySpriteDraw(texture, drawPosition, null, Projectile.GetAlpha(lightColor), drawRotation, rotationPoint, Projectile.scale * Owner.gravDir, flipSprite); + + return false; + } } } diff --git a/Projectiles/Ranged/MarksmanShot.cs b/Projectiles/Ranged/MarksmanShot.cs index 5afea94f6a..e7f74735cf 100644 --- a/Projectiles/Ranged/MarksmanShot.cs +++ b/Projectiles/Ranged/MarksmanShot.cs @@ -45,6 +45,8 @@ namespace CalamityMod.Projectiles.Ranged Projectile.DamageType = DamageClass.Ranged; Projectile.friendly = true; Projectile.penetrate = -1; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; Projectile.timeLeft = Lifetime; Projectile.MaxUpdates = UpdateCount; Projectile.alpha = 255; diff --git a/Projectiles/Ranged/MineralMortarHoldout.cs b/Projectiles/Ranged/MineralMortarHoldout.cs index 72ced92643..aa1f8f32b6 100644 --- a/Projectiles/Ranged/MineralMortarHoldout.cs +++ b/Projectiles/Ranged/MineralMortarHoldout.cs @@ -31,7 +31,7 @@ namespace CalamityMod.Projectiles.Ranged { Owner.PickAmmo(Owner.ActiveItem(), out _, out float speed, out int damage, out float knockback, out int usedItemAmmoId); - Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, Projectile.velocity.SafeNormalize(Vector2.UnitX) * speed, ModContent.ProjectileType(), damage, knockback, Projectile.owner, usedItemAmmoId); + Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), GunTipPosition, Projectile.velocity.SafeNormalize(Vector2.UnitX) * speed * 1.5f, ModContent.ProjectileType(), damage, knockback, Projectile.owner, usedItemAmmoId); // Doesn't sync this to the server, it's just effects. if (!Main.dedServ) diff --git a/Projectiles/Ranged/NullShot.cs b/Projectiles/Ranged/NullShot.cs index b0b6881f10..2ec483b36b 100644 --- a/Projectiles/Ranged/NullShot.cs +++ b/Projectiles/Ranged/NullShot.cs @@ -1,4 +1,6 @@ -using CalamityMod.NPCs.NormalNPCs; +using CalamityMod.CalPlayer; +using CalamityMod.NPCs; +using CalamityMod.NPCs.NormalNPCs; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -47,40 +49,40 @@ namespace CalamityMod.Projectiles.Ranged { return; } - int nullBuff = Main.rand.Next(7); + + int randAmt = (CalamityPlayer.areThereAnyDamnBosses || CalamityLists.AquaticScourgeIDs.Contains(target.type)) ? 6 : 8; + int nullBuff = Main.rand.Next(randAmt); if (!target.boss) { - if (nullBuff == 0) + switch (nullBuff) { - target.scale *= 2f; - } - else if (nullBuff == 1) - { - target.scale *= 0.5f; - } - else if (nullBuff == 2 && target.type != ModContent.NPCType()) - { - target.damage += 10; - } - else if (nullBuff == 3) - { - target.damage -= 10; - } - else if (nullBuff == 4) - { - target.knockBackResist = 0f; - } - else if (nullBuff == 5) - { - target.knockBackResist = 1f; - } - else if (nullBuff == 6) - { - target.defense += 5; - } - else - { - target.defense -= 5; + case 0: + if (target.type != ModContent.NPCType()) + target.damage += 10; + break; + case 1: + target.damage -= 10; + break; + case 2: + target.knockBackResist = 0f; + break; + case 3: + target.knockBackResist = 1f; + break; + case 4: + target.defense += 5; + break; + case 5: + target.defense -= 5; + break; + case 6: + target.scale *= 2f; + break; + case 7: + target.scale *= 0.5f; + break; + default: + break; } } } diff --git a/Projectiles/Ranged/NullShot2.cs b/Projectiles/Ranged/NullShot2.cs index 7342465df3..d24185b9d0 100644 --- a/Projectiles/Ranged/NullShot2.cs +++ b/Projectiles/Ranged/NullShot2.cs @@ -1,4 +1,5 @@ -using CalamityMod.NPCs.NormalNPCs; +using CalamityMod.CalPlayer; +using CalamityMod.NPCs.NormalNPCs; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -48,48 +49,46 @@ namespace CalamityMod.Projectiles.Ranged { return; } - int nullBuff = Main.rand.Next(10); + + int randAmt = (CalamityPlayer.areThereAnyDamnBosses || CalamityLists.AquaticScourgeIDs.Contains(target.type)) ? 8 : 10; + int nullBuff = Main.rand.Next(randAmt); if (!target.boss) { - if (nullBuff == 0) + switch (nullBuff) { - target.scale *= 5f; - } - else if (nullBuff == 1) - { - target.scale *= 0.1f; - } - else if (nullBuff == 2 && target.type != ModContent.NPCType()) - { - target.damage += 20; - } - else if (nullBuff == 3) - { - target.damage -= 20; - } - else if (nullBuff == 4) - { - target.knockBackResist = 0f; - } - else if (nullBuff == 5) - { - target.knockBackResist = 1f; - } - else if (nullBuff == 6) - { - target.defense += 10; - } - else if (nullBuff == 7) - { - target.defense -= 10; - } - else if (nullBuff == 8) - { - target.velocity.Y = Main.rand.NextBool() ? 30f : -30f; - } - else - { - target.velocity.X = Main.rand.NextBool() ? 30f : -30f; + case 0: + if (target.type != ModContent.NPCType()) + target.damage += 20; + break; + case 1: + target.damage -= 20; + break; + case 2: + target.knockBackResist = 0f; + break; + case 3: + target.knockBackResist = 1f; + break; + case 4: + target.defense += 10; + break; + case 5: + target.defense -= 10; + break; + case 6: + target.velocity.Y = Main.rand.NextBool() ? 30f : -30f; + break; + case 7: + target.velocity.X = Main.rand.NextBool() ? 30f : -30f; + break; + case 8: + target.scale *= 5f; + break; + case 9: + target.scale *= 0.1f; + break; + default: + break; } } } diff --git a/Projectiles/Ranged/OpalStrikerHoldout.cs b/Projectiles/Ranged/OpalStrikerHoldout.cs index afc3cb7b6d..7a42eabdbf 100644 --- a/Projectiles/Ranged/OpalStrikerHoldout.cs +++ b/Projectiles/Ranged/OpalStrikerHoldout.cs @@ -1,92 +1,71 @@ -using System; -using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Particles; +using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using ReLogic.Utilities; using Terraria; using Terraria.Audio; -using Terraria.Localization; +using Terraria.GameContent; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class OpalStrikerHoldout : ModProjectile + public class OpalStrikerHoldout : BaseGunHoldoutProjectile { - // Take the name and texture from the weapon - public override LocalizedText DisplayName => CalamityUtils.GetItemName(); - public override string Texture => "CalamityMod/Items/Weapons/Ranged/OpalStriker"; + public override int AssociatedItemID => ModContent.ItemType(); + public override float MaxOffsetLengthFromArm => 15f; + public override float OffsetXUpwards => -5f; + public override float BaseOffsetY => -5f; + private ref float CurrentChargingFrames => ref Projectile.ai[0]; + private bool FullyCharged => CurrentChargingFrames >= OpalStriker.FullChargeFrames; + public SlotId OpalChargeSlot; public static float ChargedDamageMult = 5f; public static float ChargedKBMult = 3f; public static float BulletSpeed = 12f; - private Player Owner => Main.player[Projectile.owner]; - public SlotId OpalChargeSlot; - - private ref float CurrentChargingFrames => ref Projectile.ai[0]; - private bool FullyCharged => CurrentChargingFrames >= OpalStriker.FullChargeFrames; - public int Time = 0; - - public override void SetDefaults() + public override void KillHoldoutLogic() { - Projectile.width = 46; - Projectile.height = 30; - Projectile.friendly = true; - Projectile.tileCollide = false; - Projectile.DamageType = DamageClass.Ranged; - Projectile.ignoreWater = true; + if (Owner.CantUseHoldout(false) || HeldItem.type != Owner.ActiveItem().type) + Projectile.Kill(); } - public override void AI() + public override void HoldoutAI() { - Time++; - if (Time == 1) - Projectile.alpha = 255; - else - Projectile.alpha = 0; - - if (Owner.dead) // destroy the holdout if the player dies - { - Projectile.Kill(); - return; - } - - Vector2 armPosition = Owner.RotatedRelativePoint(Owner.MountedCenter, true); - Vector2 tipPosition = (armPosition + Projectile.velocity * Projectile.width * 0.85f) + (Projectile.velocity * 4).RotatedBy(-0.3f * Projectile.direction); - if (SoundEngine.TryGetActiveSound(OpalChargeSlot, out var ChargeSound) && ChargeSound.IsPlaying) ChargeSound.Position = Projectile.Center; // Fire if the owner stops channeling or otherwise cannot use the weapon. if (Owner.CantUseHoldout()) { + KeepRefreshingLifetime = false; + if (Projectile.ai[1] != 1f) { + Projectile.timeLeft = OpalStriker.AftershotCooldownFrames; + ChargeSound?.Stop(); SoundEngine.PlaySound(FullyCharged ? OpalStriker.ChargedFire : OpalStriker.Fire, Projectile.Center); Vector2 shootVelocity = Projectile.velocity.SafeNormalize(Vector2.UnitY) * BulletSpeed; if (FullyCharged) { - Projectile.NewProjectile(Projectile.GetSource_FromThis(), tipPosition, shootVelocity, ModContent.ProjectileType(), (int)(Projectile.damage * ChargedDamageMult), Projectile.knockBack * ChargedKBMult, Projectile.owner); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity, ModContent.ProjectileType(), (int)(Projectile.damage * ChargedDamageMult), Projectile.knockBack * ChargedKBMult, Projectile.owner); for (int i = 0; i <= 10; i++) { - Dust dust = Dust.NewDustPerfect(tipPosition, 162, shootVelocity.RotatedByRandom(MathHelper.ToRadians(20f)) * Main.rand.NextFloat(0.8f, 1.4f), 0, default, Main.rand.NextFloat(1.5f, 2.3f)); + Dust dust = Dust.NewDustPerfect(GunTipPosition, 162, shootVelocity.RotatedByRandom(MathHelper.ToRadians(20f)) * Main.rand.NextFloat(0.8f, 1.4f), 0, default, Main.rand.NextFloat(1.5f, 2.3f)); dust.noGravity = true; } } else - Projectile.NewProjectile(Projectile.GetSource_FromThis(), tipPosition, shootVelocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), GunTipPosition, shootVelocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); Projectile.ai[1] = 1f; - Projectile.netSpam = 0; - Projectile.netUpdate = true; } } else { - // While channeled, keep refreshing the projectile lifespan to the amount when attacking - Projectile.timeLeft = OpalStriker.AftershotCooldownFrames; CurrentChargingFrames++; // Sounds @@ -103,14 +82,14 @@ namespace CalamityMod.Projectiles.Ranged { if (!FullyCharged) { - Particle streak = new ManaDrainStreak(Owner, Main.rand.NextFloat(0.06f + (CurrentChargingFrames / 180), 0.08f + (CurrentChargingFrames / 180)), Main.rand.NextVector2CircularEdge(2f, 2f) * Main.rand.NextFloat(0.3f * CurrentChargingFrames, 0.3f * CurrentChargingFrames), 0f, Color.Gold, Color.Orange, 7, tipPosition); + Particle streak = new ManaDrainStreak(Owner, Main.rand.NextFloat(0.06f + (CurrentChargingFrames / 180), 0.08f + (CurrentChargingFrames / 180)), Main.rand.NextVector2CircularEdge(2f, 2f) * Main.rand.NextFloat(0.3f * CurrentChargingFrames, 0.3f * CurrentChargingFrames), 0f, Color.Gold, Color.Orange, 7, GunTipPosition); GeneralParticleHandler.SpawnParticle(streak); } float orbScale = MathHelper.Clamp(CurrentChargingFrames, 0f, OpalStriker.FullChargeFrames); - Particle orb = new GenericBloom(tipPosition, Projectile.velocity, Color.OrangeRed, orbScale / 135f, 2); + Particle orb = new GenericBloom(GunTipPosition, Projectile.velocity, Color.OrangeRed, orbScale / 135f, 2); GeneralParticleHandler.SpawnParticle(orb); - Particle orb2 = new GenericBloom(tipPosition, Projectile.velocity, Color.Coral, orbScale / 200f, 2); + Particle orb2 = new GenericBloom(GunTipPosition, Projectile.velocity, Color.Coral, orbScale / 200f, 2); GeneralParticleHandler.SpawnParticle(orb2); } @@ -119,50 +98,38 @@ namespace CalamityMod.Projectiles.Ranged { for (int i = 0; i < 36; i++) { - Dust chargefull = Dust.NewDustPerfect(tipPosition, 162); + Dust chargefull = Dust.NewDustPerfect(GunTipPosition, 162); chargefull.velocity = (MathHelper.TwoPi * i / 36f).ToRotationVector2() * 13f + Owner.velocity; chargefull.scale = Main.rand.NextFloat(2f, 2.5f); chargefull.noGravity = true; } } } - - UpdateProjectileHeldVariables(armPosition); - ManipulatePlayerVariables(); } - private void UpdateProjectileHeldVariables(Vector2 armPosition) - { - if (Main.myPlayer == Projectile.owner) - { - float interpolant = Utils.GetLerpValue(5f, 35f, Projectile.Distance(Main.MouseWorld), true); - Vector2 oldVelocity = Projectile.velocity; - Projectile.velocity = Vector2.Lerp(Projectile.velocity, Projectile.SafeDirectionTo(Main.MouseWorld), interpolant); - } - Projectile.Center = armPosition + Projectile.velocity * 15 + new Vector2(0, 3); - Projectile.rotation = Projectile.velocity.ToRotation() + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f); - Projectile.spriteDirection = Projectile.direction; - - // Rumble (only while channeling) - float rumble = MathHelper.Clamp(CurrentChargingFrames, 0f, OpalStriker.FullChargeFrames); - if (!Owner.CantUseHoldout()) - Projectile.position += Main.rand.NextVector2Circular(rumble / 30f, rumble / 30f); - } - - private void ManipulatePlayerVariables() - { - Owner.ChangeDir(Projectile.direction); - Owner.heldProj = Projectile.whoAmI; - Owner.itemTime = 2; - Owner.itemAnimation = 2; - Owner.itemRotation = (Projectile.velocity * Projectile.direction).ToRotation(); - } public override void OnKill(int timeLeft) { if (SoundEngine.TryGetActiveSound(OpalChargeSlot, out var ChargeSound)) ChargeSound?.Stop(); } - public override bool? CanDamage() => false; + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = TextureAssets.Projectile[Type].Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f); + Vector2 rotationPoint = texture.Size() * 0.5f; + SpriteEffects flipSprite = (Projectile.spriteDirection * Owner.gravDir == -1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + if (!Owner.CantUseHoldout()) + { + float rumble = MathHelper.Clamp(CurrentChargingFrames, 0f, OpalStriker.FullChargeFrames); + drawPosition += Main.rand.NextVector2Circular(rumble / 30f, rumble / 30f); + } + + Main.EntitySpriteDraw(texture, drawPosition, null, Projectile.GetAlpha(lightColor), drawRotation, rotationPoint, Projectile.scale * Owner.gravDir, flipSprite); + + return false; + } } } diff --git a/Projectiles/Ranged/PolarStar.cs b/Projectiles/Ranged/PolarStar.cs index bdc4de08d8..b870ab4aff 100644 --- a/Projectiles/Ranged/PolarStar.cs +++ b/Projectiles/Ranged/PolarStar.cs @@ -46,6 +46,7 @@ namespace CalamityMod.Projectiles.Ranged Projectile.DamageType = DamageClass.Ranged; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = -1; + Projectile.tileCollide = true; } public override void AI() @@ -126,30 +127,6 @@ namespace CalamityMod.Projectiles.Ranged DoSlowdown = false; } } - public override bool OnTileCollide(Vector2 oldVelocity) - { - Time = 2; - - if (tileBounces >= 2) - Projectile.Kill(); - else - tileBounces++; - - for (int i = 0; i <= 5; i++) - { - SquishyLightParticle energy = new(Projectile.Center, Projectile.velocity.RotatedByRandom(100) * Main.rand.NextFloat(0.08f, 0.15f), Main.rand.NextFloat(0.4f, 0.7f), EffectsColor, Main.rand.Next(40, 50 + 1), 0.25f, 2f); - GeneralParticleHandler.SpawnParticle(energy); - } - if (Projectile.velocity.X != oldVelocity.X) - { - Projectile.velocity.X = -oldVelocity.X; - } - if (Projectile.velocity.Y != oldVelocity.Y) - { - Projectile.velocity.Y = -oldVelocity.Y; - } - return false; - } public override void OnKill(int timeLeft) { int points = 5; diff --git a/Projectiles/Ranged/RealmRavagerBullet.cs b/Projectiles/Ranged/RealmRavagerBullet.cs index f0dc66f4ef..64d52761a0 100644 --- a/Projectiles/Ranged/RealmRavagerBullet.cs +++ b/Projectiles/Ranged/RealmRavagerBullet.cs @@ -59,7 +59,7 @@ namespace CalamityMod.Projectiles.Ranged Projectile.penetrate = -1; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 10; - Projectile.damage /= 2; + Projectile.damage /= 3; Projectile.Damage(); } } diff --git a/Projectiles/Ranged/ScorpioHoldout.cs b/Projectiles/Ranged/ScorpioHoldout.cs index c18f942a5d..36669dd5f8 100644 --- a/Projectiles/Ranged/ScorpioHoldout.cs +++ b/Projectiles/Ranged/ScorpioHoldout.cs @@ -29,7 +29,7 @@ namespace CalamityMod.Projectiles.Ranged // It'll carry over to the projectiles that it shoots. public static int DustEffectsID { get; set; } public static Color EffectsColor { get; set; } - public static Color StaticEffectsColor = Color.Turquoise; + public static Color StaticEffectsColor { get; set; } = Color.Turquoise; public override void HoldoutAI() { @@ -58,7 +58,6 @@ namespace CalamityMod.Projectiles.Ranged { ShootingTimer = 0f; TimerBetweenBursts = 0f; - NetUpdate(); } } @@ -155,8 +154,6 @@ namespace CalamityMod.Projectiles.Ranged rocketType, projSpeed); - NetUpdate(); - // Inside here go all the things that dedicated servers shouldn't spend resources on. // Like visuals and sounds. if (Main.dedServ) @@ -195,13 +192,6 @@ namespace CalamityMod.Projectiles.Ranged GeneralParticleHandler.SpawnParticle(shootPulse); } - public void NetUpdate() - { - Projectile.netUpdate = true; - if (Projectile.netSpam >= 10) - Projectile.netSpam = 9; - } - public override bool PreDraw(ref Color lightColor) { Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value; diff --git a/Projectiles/Ranged/SproutingArrowMain.cs b/Projectiles/Ranged/SproutingArrowMain.cs index 93fbb6180f..c67de8f3a6 100644 --- a/Projectiles/Ranged/SproutingArrowMain.cs +++ b/Projectiles/Ranged/SproutingArrowMain.cs @@ -34,7 +34,7 @@ namespace CalamityMod.Projectiles.Ranged { if (Projectile.ai[0] == 0) { - Projectile.damage = (int)(Projectile.damage * 0.18f); + Projectile.damage = (int)(Projectile.damage * 0.3f); Projectile.velocity *= 0.25f; LineParticle spark = new LineParticle(Projectile.Center + Projectile.velocity * 4, Projectile.velocity * 4.95f, false, 9, 2.4f, Color.LimeGreen); GeneralParticleHandler.SpawnParticle(spark); @@ -51,8 +51,8 @@ namespace CalamityMod.Projectiles.Ranged Vector2 vel1 = (Projectile.velocity * 0.4f).RotatedBy(Main.rand.NextFloat(0.015f, 0.04f)); Vector2 vel2 = (Projectile.velocity * 0.4f).RotatedBy(Main.rand.NextFloat(-0.015f, -0.04f)); - int split1 = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, vel1 * Main.rand.NextFloat(0.95f, 1.05f), ModContent.ProjectileType(), (int)(Projectile.damage * 3), 0f, Projectile.owner, 0f, hitDirect ? 1f : 0f); - int split2 = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, vel2 * Main.rand.NextFloat(0.95f, 1.05f), ModContent.ProjectileType(), (int)(Projectile.damage * 3), 0f, Projectile.owner, 0f, hitDirect ? 1f : 0f); + int split1 = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, vel1 * Main.rand.NextFloat(0.95f, 1.05f), ModContent.ProjectileType(), (int)(Projectile.damage * 2), 0f, Projectile.owner, 0f, hitDirect ? 1f : 0f); + int split2 = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, vel2 * Main.rand.NextFloat(0.95f, 1.05f), ModContent.ProjectileType(), (int)(Projectile.damage * 2), 0f, Projectile.owner, 0f, hitDirect ? 1f : 0f); if (Projectile.Calamity().allProjectilesHome) // Allows the split arrows to home when using Arterial Assault as well { Main.projectile[split1].Calamity().allProjectilesHome = true; diff --git a/Projectiles/Ranged/TheHiveHoldout.cs b/Projectiles/Ranged/TheHiveHoldout.cs index f29cb26b3e..a282f52ad9 100644 --- a/Projectiles/Ranged/TheHiveHoldout.cs +++ b/Projectiles/Ranged/TheHiveHoldout.cs @@ -8,6 +8,7 @@ using Terraria; using Terraria.Audio; using Terraria.DataStructures; using Terraria.ID; +using static CalamityMod.Items.Weapons.Ranged.TheHive; using static Terraria.ModLoader.ModContent; namespace CalamityMod.Projectiles.Ranged @@ -25,14 +26,18 @@ namespace CalamityMod.Projectiles.Ranged // It'll carry over to the projectiles that it shoots. public static int DustEffectsID { get; set; } public static Color EffectsColor { get; set; } - public static Color StaticEffectsColor = Color.Lime; + public static Color StaticEffectsColor { get; set; } = Color.Lime; - private ref float ShootingTimer => ref Projectile.ai[0]; - private bool FireNuke; - private float PostFireCooldown = 0; - private bool HasLetGo = false; - private SlotId HiveHum; - private const float MaxCharge = 90f; + public ref float ShootingTimer => ref Projectile.ai[0]; + public ref float PostFireCooldown => ref Projectile.ai[1]; + public bool HasLetGo + { + get => Projectile.ai[2] == 1f; + set => Projectile.ai[2] = value == true ? 1f : 0f; + } + + public bool FireNuke => ShootingTimer > MaxCharge; + public SlotId HiveHum { get; set; } public override void KillHoldoutLogic() { @@ -42,9 +47,6 @@ namespace CalamityMod.Projectiles.Ranged public override void HoldoutAI() { - - FireNuke = ShootingTimer > MaxCharge; - // If there's no player, or the player is the server, or the owner's stunned, there'll be no holdout. if (Owner.CantUseHoldout() && !HasLetGo) { @@ -54,7 +56,6 @@ namespace CalamityMod.Projectiles.Ranged } if (HeldItem.type == ItemType()) ShootRocket(); - NetUpdate(); HasLetGo = true; } @@ -102,7 +103,7 @@ namespace CalamityMod.Projectiles.Ranged } } - private void ShootRocket() + public void ShootRocket() { // We use the velocity of this projectile as its direction vector. Vector2 shootDirection = Projectile.velocity.SafeNormalize(Vector2.Zero); @@ -173,8 +174,6 @@ namespace CalamityMod.Projectiles.Ranged PostFireCooldown = 30; } - NetUpdate(); - // Inside here go all the things that dedicated servers shouldn't spend resources on. // Like visuals and sounds. if (Main.dedServ) @@ -210,7 +209,7 @@ namespace CalamityMod.Projectiles.Ranged OffsetLengthFromArm -= FireNuke ? 16f : 6f; } - private void PostFiringCooldown() + public void PostFiringCooldown() { Owner.channel = true; if (PostFireCooldown > 0) @@ -227,21 +226,11 @@ namespace CalamityMod.Projectiles.Ranged else { if (SoundEngine.TryGetActiveSound(HiveHum, out var hum) && hum.IsPlaying) - { hum?.Stop(); - } Projectile.Kill(); - NetUpdate(); } } - private void NetUpdate() - { - Projectile.netUpdate = true; - if (Projectile.netSpam >= 10) - Projectile.netSpam = 9; - } - public override void OnSpawn(IEntitySource source) { base.OnSpawn(source); diff --git a/Projectiles/Ranged/WildfireBloomHoldout.cs b/Projectiles/Ranged/WildfireBloomHoldout.cs index 6144e97939..dc4086d841 100644 --- a/Projectiles/Ranged/WildfireBloomHoldout.cs +++ b/Projectiles/Ranged/WildfireBloomHoldout.cs @@ -1,12 +1,10 @@ -using CalamityMod.Items.Weapons.Ranged; +using System.IO; +using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Projectiles.BaseProjectiles; 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; @@ -22,19 +20,16 @@ namespace CalamityMod.Projectiles.Ranged public override float BaseOffsetY => -5f; public override float OffsetYDownwards => 5f; - private ref float ShotCooldown => ref Projectile.ai[0]; - private ref float ShotsFired => ref Projectile.ai[1]; - private ref float ShootTimer => ref Projectile.ai[2]; - public int FireBlobs = 0; + public ref float ShotCooldown => ref Projectile.ai[0]; + public ref float ShotsFired => ref Projectile.ai[1]; + public ref float ShootTimer => ref Projectile.ai[2]; + public int FireBlobs { get; set; } public override void KillHoldoutLogic() { base.KillHoldoutLogic(); if (ShotsFired >= 16) - { Projectile.Kill(); - Projectile.netUpdate = true; - } } public override void HoldoutAI() @@ -83,5 +78,9 @@ namespace CalamityMod.Projectiles.Ranged base.OnSpawn(source); SoundEngine.PlaySound(SoundID.Item73 with { Volume = 0.7f }, Projectile.Center); } + + public override void SendExtraAIHoldout(BinaryWriter writer) => writer.Write(FireBlobs); + + public override void ReceiveExtraAIHoldout(BinaryReader reader) => FireBlobs = reader.ReadInt32(); } } diff --git a/Projectiles/Rogue/AlphaSeeker.cs b/Projectiles/Rogue/AlphaSeeker.cs index e15fc1e560..7d91a5bc1f 100644 --- a/Projectiles/Rogue/AlphaSeeker.cs +++ b/Projectiles/Rogue/AlphaSeeker.cs @@ -28,6 +28,7 @@ namespace CalamityMod.Projectiles.Rogue Projectile.penetrate = 1; Projectile.timeLeft = lifetime; Projectile.DamageType = RogueDamageClass.Instance; + Projectile.Calamity().CannotProc = true; Projectile.extraUpdates = 1; } diff --git a/Projectiles/Rogue/BallisticPoisonBombProj.cs b/Projectiles/Rogue/BallisticPoisonBombProj.cs index 1085f9f558..6ef3ba74cc 100644 --- a/Projectiles/Rogue/BallisticPoisonBombProj.cs +++ b/Projectiles/Rogue/BallisticPoisonBombProj.cs @@ -66,7 +66,7 @@ namespace CalamityMod.Projectiles.Rogue Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), Projectile.damage, 0f, Projectile.owner); } - int cloudAmt = Projectile.Calamity().stealthStrike ? Main.rand.Next(8, 12+1) : Main.rand.Next(3, 5+1); + int cloudAmt = Projectile.Calamity().stealthStrike ? Main.rand.Next(7, 10+1) : Main.rand.Next(3, 5+1); for (int c = 0; c < cloudAmt; c++) { Vector2 velocity = CalamityUtils.RandomVelocity(100f, 10f, 200f, 0.01f); diff --git a/Projectiles/Rogue/BallisticPoisonCloud.cs b/Projectiles/Rogue/BallisticPoisonCloud.cs index 47f612c1ef..df259e395b 100644 --- a/Projectiles/Rogue/BallisticPoisonCloud.cs +++ b/Projectiles/Rogue/BallisticPoisonCloud.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Projectiles.Rogue Projectile.height = 34; Projectile.friendly = true; Projectile.alpha = 255; - Projectile.penetrate = -1; + Projectile.penetrate = 5; Projectile.tileCollide = false; Projectile.ignoreWater = true; Projectile.timeLeft = 600; diff --git a/Projectiles/Rogue/ExorcismProj.cs b/Projectiles/Rogue/ExorcismProj.cs index ff5246efc9..79b74887d0 100644 --- a/Projectiles/Rogue/ExorcismProj.cs +++ b/Projectiles/Rogue/ExorcismProj.cs @@ -73,6 +73,20 @@ namespace CalamityMod.Projectiles.Rogue } } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + // Stars + if (Projectile.Calamity().stealthStrike) + { + for (int i = 0; i < 6; i++) + { + Vector2 pos = new Vector2(Projectile.Center.X + (float)Projectile.width * 0.5f + (float)Main.rand.Next(-201, 201), Main.screenPosition.Y - 600f - Main.rand.Next(50)); + Vector2 starVelocity = CalamityUtils.CalculatePredictiveAimToTargetMaxUpdates(pos, target, 30f, 2); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), pos, starVelocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.75f), Projectile.knockBack * 0.5f, Projectile.owner, Main.rand.NextFloat(-3f, 3f), 0f); + } + } + } + public override bool PreDraw(ref Color lightColor) { Texture2D tex = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value; @@ -97,17 +111,6 @@ namespace CalamityMod.Projectiles.Rogue Main.projectile[p].rotation = Projectile.rotation; if (Projectile.Calamity().stealthStrike) Main.projectile[p].Calamity().stealthStrike = true; - // Stars - if (Projectile.Calamity().stealthStrike) - { - for (int i = 0; i < 6; i++) - { - Vector2 pos = new Vector2(Projectile.Center.X + (float)Projectile.width * 0.5f + (float)Main.rand.Next(-201, 201), Main.screenPosition.Y - 600f - Main.rand.Next(50)); - float speedX = (Projectile.Center.X - pos.X) / 20f; - float speedY = (Projectile.Center.Y - pos.Y) / 20f; - Projectile.NewProjectile(Projectile.GetSource_FromThis(), pos.X, pos.Y, speedX, speedY, ModContent.ProjectileType(), (int)(Projectile.damage * 0.75f), Projectile.knockBack * 0.5f, Projectile.owner, Main.rand.NextFloat(-3f, 3f), 0f); - } - } } } } diff --git a/Projectiles/Rogue/ExorcismStar.cs b/Projectiles/Rogue/ExorcismStar.cs index 1205f4d2c5..9c31376c1d 100644 --- a/Projectiles/Rogue/ExorcismStar.cs +++ b/Projectiles/Rogue/ExorcismStar.cs @@ -28,7 +28,7 @@ namespace CalamityMod.Projectiles.Rogue Projectile.tileCollide = false; Projectile.ignoreWater = true; Projectile.timeLeft = 300; - Projectile.extraUpdates = 3; + Projectile.MaxUpdates = 2; Projectile.DamageType = RogueDamageClass.Instance; } diff --git a/Projectiles/Rogue/Honeycomb.cs b/Projectiles/Rogue/Honeycomb.cs index 5e3ca0a392..657b228b40 100644 --- a/Projectiles/Rogue/Honeycomb.cs +++ b/Projectiles/Rogue/Honeycomb.cs @@ -71,6 +71,11 @@ namespace CalamityMod.Projectiles.Rogue public void SpawnProjectiles() { + // If it's already spawned projectiles, don't do anything. Prevents it from spawning double the projectile amount when hitting enemies. + if (Projectile.ai[1] == 1f) + return; + + Projectile.ai[1] = 1f; Player player = Main.player[Main.myPlayer]; int fragAmt = 2; for (int i = 0; i < fragAmt; i++) diff --git a/Projectiles/Summon/HarvestStaffMinion.cs b/Projectiles/Summon/HarvestStaffMinion.cs index c00e7bf69b..15842a6816 100644 --- a/Projectiles/Summon/HarvestStaffMinion.cs +++ b/Projectiles/Summon/HarvestStaffMinion.cs @@ -46,8 +46,6 @@ namespace CalamityMod.Projectiles.Summon } else if (value == AIState.Idle) Animation = AnimationState.Idle; - - NetUpdate(); } } @@ -127,8 +125,6 @@ namespace CalamityMod.Projectiles.Summon FramesUntilNextAnimationFrame = 5; break; } - - NetUpdate(); } } @@ -138,9 +134,10 @@ namespace CalamityMod.Projectiles.Summon public int AnimationFrames { get; set; } /// - /// The amount of time, in frames, that it'll take to go to the next frame of animation. + /// The amount of time, in frames, that it'll take to go to the next frame of animation.
+ /// Defaults to 1 so it doesn't divide by 0. ///
- public int FramesUntilNextAnimationFrame { get; set; } + public int FramesUntilNextAnimationFrame { get; set; } = 1; /// /// A convienent bool for when the animation has been completed.
@@ -214,18 +211,19 @@ namespace CalamityMod.Projectiles.Summon } } - public int NetUpdateTimer { get; set; } - #endregion #region AI and Collisions public override void AI() { - if (Animation == AnimationState.Grow && (MySentry is null || Projectile.Distance(MySentry.Center) > 600f)) + Owner ??= Main.player[Projectile.owner]; + Projectile.width = Projectile.height = Variant == 0 ? 28 : (Variant == 1 ? 22 : 20); + + if (Animation == AnimationState.Grow && (MySentry is null || Projectile.Distance(MySentry.Center) > 600f) && Main.myPlayer == Projectile.owner) { Projectile.Kill(); - NetUpdate(); + return; } Target = Projectile.Center.MinionHoming(State == AIState.Still ? PlantedEnemyDistanceDetection : NormalEnemyDistanceDetection, Owner, false); @@ -249,13 +247,7 @@ namespace CalamityMod.Projectiles.Summon Projectile.timeLeft = 2; DoGravity(); DoAnimation(); - - NetUpdateTimer++; - if (NetUpdateTimer > 60) - { - NetUpdateTimer = 0; - NetUpdate(); - } + NetUpdate(); } public override bool OnTileCollide(Vector2 oldVelocity) @@ -300,9 +292,13 @@ namespace CalamityMod.Projectiles.Summon { if (State != AIState.Attack) return; - + Projectile.ExpandHitboxBy(4f); - Projectile.Damage(); + if (Main.myPlayer == Projectile.owner) + Projectile.Damage(); + + if (Main.dedServ) + return; for (int i = 0; i < (int)Utils.Remap(Variant, 0f, 2f, 4f, 2f); i++) { @@ -312,11 +308,6 @@ namespace CalamityMod.Projectiles.Summon gore.timeLeft = 15; } - NetUpdate(); - - if (Main.dedServ) - return; - for (int i = 0; i < 20; i++) { if (BirthdayParty.PartyIsUp) @@ -374,7 +365,6 @@ namespace CalamityMod.Projectiles.Summon { IdleWalkingTime = IdleWalkingTimer = Main.rand.Next(60, 180); IdleWalkingDirection = MySentry == null || Projectile.WithinRange(MySentry.Center, 960f) ? (Main.rand.NextBool() ? -1 : 1) : MathF.Sign(MySentry.Center.X - Projectile.Center.X); - NetUpdate(); } else if (IdleWalkingTimer != 0f) @@ -447,8 +437,6 @@ namespace CalamityMod.Projectiles.Summon Animation = AnimationState.Jump; SoundEngine.PlaySound(_jumpSound with { Pitch = Utils.Remap(Variant, 0f, 2f, -0.3f, 0.3f) }, Projectile.Center); - - NetUpdate(); } /// @@ -478,7 +466,6 @@ namespace CalamityMod.Projectiles.Summon Projectile.velocity.Y = -MathF.Sqrt(-2f * PumpkinGravityStrength * (destination.Y - Projectile.Bottom.Y)); Animation = AnimationState.Jump; SoundEngine.PlaySound(_jumpSound with { Pitch = Utils.Remap(Variant, 0f, 2f, -0.3f, 0.3f) }, Projectile.Center); - NetUpdate(); } /// @@ -524,9 +511,10 @@ namespace CalamityMod.Projectiles.Summon return; Projectile.frameCounter++; - if (Projectile.frameCounter % FramesUntilNextAnimationFrame == 0) + if (Projectile.frameCounter >= FramesUntilNextAnimationFrame) { Projectile.frame = Math.Min(Projectile.frame + 1, AnimationFrames - 1); + Projectile.frameCounter = 0; // If it's the run animation, loop it. if (Animation == AnimationState.Run && CompletedAnimation) @@ -539,9 +527,8 @@ namespace CalamityMod.Projectiles.Summon /// public void NetUpdate() { + Projectile.netSpam = 0; Projectile.netUpdate = true; - if (Projectile.netSpam >= 10) - Projectile.netSpam = 9; } #endregion @@ -566,34 +553,34 @@ namespace CalamityMod.Projectiles.Summon public override void SendExtraAI(BinaryWriter writer) { - writer.Write(IdleWalkingTime); - writer.Write(IdleWalkingTimer); - writer.Write(IdleJumpCount); - writer.Write(IdleJumpCooldown); - writer.Write(IdleWalkingDirection); - writer.Write(NetUpdateTimer); + writer.Write7BitEncodedInt(Direction); + writer.Write7BitEncodedInt(IdleWalkingTime); + writer.Write7BitEncodedInt(IdleWalkingTimer); + writer.Write7BitEncodedInt(IdleJumpCount); + writer.Write7BitEncodedInt(IdleJumpCooldown); + writer.Write7BitEncodedInt(IdleWalkingDirection); + writer.Write7BitEncodedInt(AnimationFrames); + writer.Write7BitEncodedInt(FramesUntilNextAnimationFrame); } public override void ReceiveExtraAI(BinaryReader reader) { - IdleWalkingTime = reader.ReadInt32(); - IdleWalkingTimer = reader.ReadInt32(); - IdleJumpCount = reader.ReadInt32(); - IdleJumpCooldown = reader.ReadInt32(); - IdleWalkingDirection = reader.ReadInt32(); - NetUpdateTimer = reader.ReadInt32(); + Direction = reader.Read7BitEncodedInt(); + IdleWalkingTime = reader.Read7BitEncodedInt(); + IdleWalkingTimer = reader.Read7BitEncodedInt(); + IdleJumpCount = reader.Read7BitEncodedInt(); + IdleJumpCooldown = reader.Read7BitEncodedInt(); + IdleWalkingDirection = reader.Read7BitEncodedInt(); + AnimationFrames = reader.Read7BitEncodedInt(); + FramesUntilNextAnimationFrame = reader.Read7BitEncodedInt(); } public override bool? CanDamage() => State == AIState.Attack ? null : false; - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => NetUpdate(); - public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) => modifiers.SourceDamage *= Utils.Remap(Variant, 0f, 2f, 1.5f, 0.5f); public override void OnSpawn(IEntitySource source) { - Owner = Main.player[Projectile.owner]; - Projectile.width = Projectile.height = Variant == 0 ? 28 : (Variant == 1 ? 22 : 20); Direction = Main.rand.NextBool() ? -1 : 1; Animation = AnimationState.None; } diff --git a/Projectiles/Summon/LiliesOfFinalityAoE.cs b/Projectiles/Summon/LiliesOfFinalityAoE.cs index 8ea6e54e24..819d1308fb 100644 --- a/Projectiles/Summon/LiliesOfFinalityAoE.cs +++ b/Projectiles/Summon/LiliesOfFinalityAoE.cs @@ -2,7 +2,6 @@ using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; -using Terraria.DataStructures; using Terraria.ModLoader; using static CalamityMod.Items.Weapons.Summon.LiliesOfFinality; @@ -38,6 +37,8 @@ namespace CalamityMod.Projectiles.Summon public override void AI() { + Ariane ??= Main.projectile[(int)ArianeID]; + if (Ariane != null && Ariane.active && Ariane.owner == Projectile.owner && Ariane.type == ModContent.ProjectileType() && Ariane.ModProjectile().State == LiliesOfFinalityAriane.AIState.Attack) Projectile.timeLeft = 2; @@ -100,8 +101,6 @@ namespace CalamityMod.Projectiles.Summon Timer++; } - public override void OnSpawn(IEntitySource source) => Ariane = Main.projectile[(int)ArianeID]; - public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) => modifiers.SourceDamage *= Ariane_AoEDMGMultiplier; } } diff --git a/Projectiles/Summon/LiliesOfFinalityAriane.cs b/Projectiles/Summon/LiliesOfFinalityAriane.cs index 1da87b762c..a6e2b0c3bf 100644 --- a/Projectiles/Summon/LiliesOfFinalityAriane.cs +++ b/Projectiles/Summon/LiliesOfFinalityAriane.cs @@ -7,9 +7,6 @@ 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; using static System.MathF; using static CalamityMod.Items.Weapons.Summon.LiliesOfFinality; @@ -58,8 +55,6 @@ namespace CalamityMod.Projectiles.Summon Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ProjectileType(), Projectile.damage, 0f, Projectile.owner, Projectile.whoAmI); Timer = 0f; - - NetUpdate(); } } @@ -128,23 +123,23 @@ namespace CalamityMod.Projectiles.Summon public override void CheckMinionExistence() { + if (Elster is null) + { + for (int i = 0; i < Main.maxProjectiles; i++) + { + Projectile p = Main.projectile[i]; + if (p == null || !p.active || p.owner != Projectile.owner || p.type != ProjectileType()) + continue; + Elster = p; + break; + } + } + Projectile.timeLeft = 2; if (Elster is null || !Elster.active || Elster.owner != Projectile.owner || Elster.type != ProjectileType()) Projectile.Kill(); } - public override void OnSpawn(IEntitySource source) - { - for (int i = 0; i < Main.maxProjectiles; i++) - { - Projectile p = Main.projectile[i]; - if (p == null || !p.active || p.owner != Projectile.owner || p.type != ProjectileType()) - continue; - Elster = p; - break; - } - } - public override bool OnTileCollide(Vector2 oldVelocity) => false; public override bool TileCollideStyle(ref int width, ref int height, ref bool fallThrough, ref Vector2 hitboxCenterFrac) @@ -182,6 +177,9 @@ namespace CalamityMod.Projectiles.Summon Timer++; + Projectile.netSpam = 0; + Projectile.netUpdate = true; + // If on a dedicated server, don't bother running the visuals and sounds to save resources. if (Main.dedServ) return; @@ -297,7 +295,6 @@ namespace CalamityMod.Projectiles.Summon Projectile.owner); Timer = 0f; - NetUpdate(); // If on a dedicated server, don't bother running the visuals and sounds to save resources. if (Main.dedServ) @@ -347,13 +344,6 @@ namespace CalamityMod.Projectiles.Summon Projectile.spriteDirection = spriteDirection; } - private void NetUpdate() - { - Projectile.netUpdate = true; - if (Projectile.netSpam >= 10) - Projectile.netSpam = 9; - } - #endregion #region Syncing diff --git a/Projectiles/Summon/LiliesOfFinalityElster.cs b/Projectiles/Summon/LiliesOfFinalityElster.cs index a34bfd5172..04baf4f098 100644 --- a/Projectiles/Summon/LiliesOfFinalityElster.cs +++ b/Projectiles/Summon/LiliesOfFinalityElster.cs @@ -7,8 +7,6 @@ using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; using Terraria.Audio; -using Terraria.GameContent; -using Terraria.ID; using Terraria.ModLoader; using static System.MathF; using static CalamityMod.Items.Weapons.Summon.LiliesOfFinality; @@ -54,8 +52,6 @@ namespace CalamityMod.Projectiles.Summon // Because some states mess with the rotation, we reset it so it doesn't cause visual issues on the states that don't deal with rotation. Projectile.rotation = 0f; - - NetUpdate(); } } @@ -179,6 +175,9 @@ namespace CalamityMod.Projectiles.Summon } Timer++; + + Projectile.netSpam = 0; + Projectile.netUpdate = true; } private void IdleState() @@ -316,7 +315,6 @@ namespace CalamityMod.Projectiles.Summon Projectile.owner); HasShotOnce = true; - NetUpdate(); // If on a dedicated server, don't bother running the visuals and sounds to save resources. if (Main.dedServ) @@ -368,13 +366,6 @@ namespace CalamityMod.Projectiles.Summon } } - private void NetUpdate() - { - Projectile.netUpdate = true; - if (Projectile.netSpam >= 10) - Projectile.netSpam = 9; - } - #endregion #region Syncing diff --git a/Projectiles/Typeless/FlameLickedBarrage.cs b/Projectiles/Typeless/FlameLickedBarrage.cs index 9cf48e17df..494f9b6096 100644 --- a/Projectiles/Typeless/FlameLickedBarrage.cs +++ b/Projectiles/Typeless/FlameLickedBarrage.cs @@ -25,7 +25,7 @@ namespace CalamityMod.Projectiles.Typeless Projectile.friendly = true; Projectile.ignoreWater = true; Projectile.tileCollide = false; - Projectile.penetrate = -1; + Projectile.penetrate = 3; Projectile.timeLeft = 300; Projectile.localNPCHitCooldown = -1; Projectile.usesLocalNPCImmunity = true; diff --git a/Projectiles/Typeless/FlameLickedHellblast.cs b/Projectiles/Typeless/FlameLickedHellblast.cs index b9e0ee19ff..d9071df464 100644 --- a/Projectiles/Typeless/FlameLickedHellblast.cs +++ b/Projectiles/Typeless/FlameLickedHellblast.cs @@ -27,7 +27,7 @@ namespace CalamityMod.Projectiles.Typeless Projectile.friendly = true; Projectile.ignoreWater = true; Projectile.tileCollide = false; - Projectile.penetrate = -1; + Projectile.penetrate = 5; Projectile.timeLeft = 255; Projectile.localNPCHitCooldown = -1; Projectile.usesLocalNPCImmunity = true; diff --git a/Projectiles/Typeless/PauldronDash.cs b/Projectiles/Typeless/PauldronDash.cs index 6a17b3d5f8..04613c3e65 100644 --- a/Projectiles/Typeless/PauldronDash.cs +++ b/Projectiles/Typeless/PauldronDash.cs @@ -27,8 +27,8 @@ namespace CalamityMod.Projectiles.Typeless Projectile.tileCollide = false; Projectile.penetrate = 1; Projectile.timeLeft = 4; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = -1; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.idStaticNPCHitCooldown = 22; } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) diff --git a/Projectiles/Typeless/RelicOfDeliveranceSpear.cs b/Projectiles/Typeless/RelicOfDeliveranceSpear.cs index d8d5974075..1c2161af35 100644 --- a/Projectiles/Typeless/RelicOfDeliveranceSpear.cs +++ b/Projectiles/Typeless/RelicOfDeliveranceSpear.cs @@ -176,11 +176,8 @@ namespace CalamityMod.Projectiles.Typeless // Adjust the player's held projectile type. if (player.heldProj == -1) player.heldProj = Projectile.whoAmI; - if (player.mount != null) - { - player.mount.Dismount(player); - } - player.ChangeDir((int)Projectile.velocity.X); + player.mount?.Dismount(player); + player.ChangeDir(Math.Sign(Projectile.velocity.X) <= 0 ? -1 : 1); // Generate dust if (Projectile.ai[0] % DustSpawnInterval == DustSpawnInterval - 1f) { diff --git a/Sounds/Custom/AbilitySounds/ChaosStateOver.ogg b/Sounds/Custom/AbilitySounds/ChaosStateOver.ogg index 8019d05fd4..cef7b85009 100644 Binary files a/Sounds/Custom/AbilitySounds/ChaosStateOver.ogg and b/Sounds/Custom/AbilitySounds/ChaosStateOver.ogg differ diff --git a/Systems/DifficultyModeSystem.cs b/Systems/DifficultyModeSystem.cs index 514d003dd5..afbfc41794 100644 --- a/Systems/DifficultyModeSystem.cs +++ b/Systems/DifficultyModeSystem.cs @@ -59,7 +59,7 @@ namespace CalamityMod.Systems public static void CalculateDifficultyData() { MostAlternateDifficulties = 1; - Difficulties.OrderBy(d => d.DifficultyScale); + Difficulties = Difficulties.OrderBy(d => d.DifficultyScale).ToList(); //Difficulties are arranged in "tiers". This is done so that multiple mods can add their own alternate difficulties sharing a tier with the base ones DifficultyTiers = new List(); diff --git a/Tiles/Abyss/AbyssAmbient/AbyssKelp.cs b/Tiles/Abyss/AbyssAmbient/AbyssKelp.cs index 780c4f5224..5685b37c6e 100644 --- a/Tiles/Abyss/AbyssAmbient/AbyssKelp.cs +++ b/Tiles/Abyss/AbyssAmbient/AbyssKelp.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient Main.tileNoAttach[Type] = true; Main.tileNoFail[Type] = true; Main.tileLavaDeath[Type] = true; - Main.tileWaterDeath[Type] = true; + Main.tileWaterDeath[Type] = false; Main.tileFrameImportant[Type] = true; TileID.Sets.ReplaceTileBreakUp[Type] = true; TileID.Sets.SwaysInWindBasic[Type] = true; diff --git a/Tiles/Abyss/AbyssAmbient/PhoviamareHalm.cs b/Tiles/Abyss/AbyssAmbient/PhoviamareHalm.cs index df321133ff..4e4ed2bf49 100644 --- a/Tiles/Abyss/AbyssAmbient/PhoviamareHalm.cs +++ b/Tiles/Abyss/AbyssAmbient/PhoviamareHalm.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient Main.tileNoAttach[Type] = true; Main.tileNoFail[Type] = true; Main.tileLavaDeath[Type] = true; - Main.tileWaterDeath[Type] = true; + Main.tileWaterDeath[Type] = false; Main.tileFrameImportant[Type] = true; TileID.Sets.ReplaceTileBreakUp[Type] = true; TileID.Sets.SwaysInWindBasic[Type] = true; diff --git a/Tiles/Abyss/AbyssAmbient/TenebrisRemnant.cs b/Tiles/Abyss/AbyssAmbient/TenebrisRemnant.cs index a5a676ba0f..6d10d5c19c 100644 --- a/Tiles/Abyss/AbyssAmbient/TenebrisRemnant.cs +++ b/Tiles/Abyss/AbyssAmbient/TenebrisRemnant.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Tiles.Abyss.AbyssAmbient Main.tileNoAttach[Type] = true; Main.tileNoFail[Type] = true; Main.tileLavaDeath[Type] = true; - Main.tileWaterDeath[Type] = true; + Main.tileWaterDeath[Type] = false; Main.tileFrameImportant[Type] = true; TileID.Sets.ReplaceTileBreakUp[Type] = true; TileID.Sets.SwaysInWindBasic[Type] = true; diff --git a/Tiles/Abyss/AbyssGravel.cs b/Tiles/Abyss/AbyssGravel.cs index 1754b7fc58..04d2dd8bb0 100644 --- a/Tiles/Abyss/AbyssGravel.cs +++ b/Tiles/Abyss/AbyssGravel.cs @@ -9,13 +9,11 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Abyss { - public class AbyssGravel : ModTile, IMergeableTile + public class AbyssGravel : ModTile { int animationFrameWidth = 234; public static readonly SoundStyle MineSound = new("CalamityMod/Sounds/Custom/AbyssGravelMine", 3); - - List IMergeableTile.TileAdjacencies { get; } = []; public override void SetStaticDefaults() { diff --git a/Tiles/Abyss/HardenedSulphurousSandstone.cs b/Tiles/Abyss/HardenedSulphurousSandstone.cs index e7f7eeb788..f48079fad5 100644 --- a/Tiles/Abyss/HardenedSulphurousSandstone.cs +++ b/Tiles/Abyss/HardenedSulphurousSandstone.cs @@ -8,10 +8,8 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Abyss { - public class HardenedSulphurousSandstone : ModTile, IMergeableTile + public class HardenedSulphurousSandstone : ModTile { - List IMergeableTile.TileAdjacencies { get; } = []; - public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/Abyss/PlantyMush.cs b/Tiles/Abyss/PlantyMush.cs index f80d61113a..52fa770985 100644 --- a/Tiles/Abyss/PlantyMush.cs +++ b/Tiles/Abyss/PlantyMush.cs @@ -14,11 +14,9 @@ namespace CalamityMod.Tiles.Abyss { // Transforms any and all Tenebris in old worlds into planty mush. [LegacyName("Tenebris")] - public class PlantyMush : ModTile, IMergeableTile + public class PlantyMush : ModTile { public static readonly SoundStyle MineSound = new("CalamityMod/Sounds/Custom/PlantyMushMine", 3); - - List IMergeableTile.TileAdjacencies { get; } = []; public override void SetStaticDefaults() { diff --git a/Tiles/Abyss/PyreMantle.cs b/Tiles/Abyss/PyreMantle.cs index 12d1cd6f9c..90da582ec4 100644 --- a/Tiles/Abyss/PyreMantle.cs +++ b/Tiles/Abyss/PyreMantle.cs @@ -11,12 +11,10 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Abyss { - public class PyreMantle : ModTile, IMergeableTile + public class PyreMantle : ModTile { public static readonly SoundStyle MineSound = new("CalamityMod/Sounds/Custom/VoidstoneMine", 3) { Volume = 0.4f }; - - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/Abyss/PyreMantleMolten.cs b/Tiles/Abyss/PyreMantleMolten.cs index 74c659b73f..9fe87dc7c4 100644 --- a/Tiles/Abyss/PyreMantleMolten.cs +++ b/Tiles/Abyss/PyreMantleMolten.cs @@ -11,13 +11,11 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Abyss { - public class PyreMantleMolten : ModTile, IMergeableTile + public class PyreMantleMolten : ModTile { public static readonly SoundStyle MineSound = new("CalamityMod/Sounds/Custom/VoidstoneMine", 3) { Volume = 0.4f }; internal static Texture2D GlowTexture; - List IMergeableTile.TileAdjacencies { get; } = []; - public override void SetStaticDefaults() { if (!Main.dedServ) diff --git a/Tiles/Abyss/SulphurousSand.cs b/Tiles/Abyss/SulphurousSand.cs index c0e83d585a..3dbc1957d9 100644 --- a/Tiles/Abyss/SulphurousSand.cs +++ b/Tiles/Abyss/SulphurousSand.cs @@ -16,10 +16,8 @@ namespace CalamityMod.Tiles.Abyss // It would create block swap issues with regular sulphurous sand and was rendered obsolete with the removal of this tile's water emission mechanic. // For compatibility reasons (including with schematics), however, that tile is converted into this one. [LegacyName("SulphurousSandNoWater")] - public class SulphurousSand : ModTile, IMergeableTile + public class SulphurousSand : ModTile { - List IMergeableTile.TileAdjacencies { get; } = []; - public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/Abyss/SulphurousSandstone.cs b/Tiles/Abyss/SulphurousSandstone.cs index 5b2c948dfe..692a04edbc 100644 --- a/Tiles/Abyss/SulphurousSandstone.cs +++ b/Tiles/Abyss/SulphurousSandstone.cs @@ -8,10 +8,8 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Abyss { - public class SulphurousSandstone : ModTile, IMergeableTile + public class SulphurousSandstone : ModTile { - List IMergeableTile.TileAdjacencies { get; } = []; - public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/Abyss/SulphurousShale.cs b/Tiles/Abyss/SulphurousShale.cs index c4652868ac..22bddd38b4 100644 --- a/Tiles/Abyss/SulphurousShale.cs +++ b/Tiles/Abyss/SulphurousShale.cs @@ -13,14 +13,12 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Abyss { - public class SulphurousShale : ModTile, IMergeableTile + public class SulphurousShale : ModTile { int animationFrameWidth = 234; public static readonly SoundStyle MineSound = new("CalamityMod/Sounds/Custom/AbyssGravelMine", 3); - List IMergeableTile.TileAdjacencies { get; } = []; - public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/Abyss/Voidstone.cs b/Tiles/Abyss/Voidstone.cs index 45f6f30719..8d859cad1f 100644 --- a/Tiles/Abyss/Voidstone.cs +++ b/Tiles/Abyss/Voidstone.cs @@ -11,12 +11,10 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Abyss { - public class Voidstone : ModTile, IMergeableTile + public class Voidstone : ModTile { public static readonly SoundStyle MineSound = new("CalamityMod/Sounds/Custom/VoidstoneMine", 3) { Volume = 0.4f }; internal static Texture2D GlowTexture; - - List IMergeableTile.TileAdjacencies { get; } = []; public override void SetStaticDefaults() { diff --git a/Tiles/AerialiteBrick.cs b/Tiles/AerialiteBrick.cs index 73a3990d3f..d5df1c8c04 100644 --- a/Tiles/AerialiteBrick.cs +++ b/Tiles/AerialiteBrick.cs @@ -7,10 +7,9 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles { - public class AerialiteBrick : ModTile, IMergeableTile + public class AerialiteBrick : ModTile { - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/Astral/AstralClay.cs b/Tiles/Astral/AstralClay.cs index d5afdd919e..b84e3de8ab 100644 --- a/Tiles/Astral/AstralClay.cs +++ b/Tiles/Astral/AstralClay.cs @@ -9,10 +9,9 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Astral { - public class AstralClay : ModTile, IMergeableTile + public class AstralClay : ModTile { - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/Astral/AstralDirt.cs b/Tiles/Astral/AstralDirt.cs index 4cd269dab8..18ff19942a 100644 --- a/Tiles/Astral/AstralDirt.cs +++ b/Tiles/Astral/AstralDirt.cs @@ -9,10 +9,9 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Astral { - public class AstralDirt : ModTile, IMergeableTile + public class AstralDirt : ModTile { - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/Astral/AstralMonolith.cs b/Tiles/Astral/AstralMonolith.cs index 9724660bfb..1ce58af87c 100644 --- a/Tiles/Astral/AstralMonolith.cs +++ b/Tiles/Astral/AstralMonolith.cs @@ -10,13 +10,11 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Astral { - public class AstralMonolith : ModTile, IMergeableTile + public class AstralMonolith : ModTile { private static int sheetWidth = 216; private static int sheetHeight = 72; - List IMergeableTile.TileAdjacencies { get; } = []; - public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/Astral/AstralStone.cs b/Tiles/Astral/AstralStone.cs index 5d4eb9f993..75f1648019 100644 --- a/Tiles/Astral/AstralStone.cs +++ b/Tiles/Astral/AstralStone.cs @@ -9,10 +9,9 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Astral { - public class AstralStone : ModTile, IMergeableTile + public class AstralStone : ModTile { - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/Astral/NovaeSlag.cs b/Tiles/Astral/NovaeSlag.cs index 60fd932b1d..b8fda17830 100644 --- a/Tiles/Astral/NovaeSlag.cs +++ b/Tiles/Astral/NovaeSlag.cs @@ -11,10 +11,9 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Astral { [LegacyName("AstralSilt")] - public class NovaeSlag : ModTile, IMergeableTile + public class NovaeSlag : ModTile { - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/AstralBrick.cs b/Tiles/AstralBrick.cs index 3af5cfe613..17921c8fcb 100644 --- a/Tiles/AstralBrick.cs +++ b/Tiles/AstralBrick.cs @@ -9,13 +9,12 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles { - public class AstralBrick : ModTile, IMergeableTile + public class AstralBrick : ModTile { private const short subsheetWidth = 324; private const short subsheetHeight = 90; - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/AstralDesert/AstralSand.cs b/Tiles/AstralDesert/AstralSand.cs index b93e3e27db..1d49d41226 100644 --- a/Tiles/AstralDesert/AstralSand.cs +++ b/Tiles/AstralDesert/AstralSand.cs @@ -11,10 +11,9 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.AstralDesert { - public class AstralSand : ModTile, IMergeableTile + public class AstralSand : ModTile { - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/AstralDesert/AstralSandstone.cs b/Tiles/AstralDesert/AstralSandstone.cs index 026c0bf2df..12389f0650 100644 --- a/Tiles/AstralDesert/AstralSandstone.cs +++ b/Tiles/AstralDesert/AstralSandstone.cs @@ -9,10 +9,9 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.AstralDesert { - public class AstralSandstone : ModTile, IMergeableTile + public class AstralSandstone : ModTile { - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/AstralDesert/CelestialRemains.cs b/Tiles/AstralDesert/CelestialRemains.cs index 515e549546..984b7f9937 100644 --- a/Tiles/AstralDesert/CelestialRemains.cs +++ b/Tiles/AstralDesert/CelestialRemains.cs @@ -10,10 +10,9 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.AstralDesert { [LegacyName("AstralFossil")] - public class CelestialRemains : ModTile, IMergeableTile + public class CelestialRemains : ModTile { - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/AstralDesert/HardenedAstralSand.cs b/Tiles/AstralDesert/HardenedAstralSand.cs index 0918cabd0a..1c2a7d92d0 100644 --- a/Tiles/AstralDesert/HardenedAstralSand.cs +++ b/Tiles/AstralDesert/HardenedAstralSand.cs @@ -8,10 +8,9 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.AstralDesert { - public class HardenedAstralSand : ModTile, IMergeableTile + public class HardenedAstralSand : ModTile { - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/AstralSnow/AstralIce.cs b/Tiles/AstralSnow/AstralIce.cs index a339f14e98..767b6e94dd 100644 --- a/Tiles/AstralSnow/AstralIce.cs +++ b/Tiles/AstralSnow/AstralIce.cs @@ -9,10 +9,9 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.AstralSnow { - public class AstralIce : ModTile, IMergeableTile + public class AstralIce : ModTile { - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/AstralSnow/AstralSnow.cs b/Tiles/AstralSnow/AstralSnow.cs index 6ab01d8390..27b8b2a29e 100644 --- a/Tiles/AstralSnow/AstralSnow.cs +++ b/Tiles/AstralSnow/AstralSnow.cs @@ -9,10 +9,9 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.AstralSnow { - public class AstralSnow : ModTile, IMergeableTile + public class AstralSnow : ModTile { - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/CalamityGlobalTile.cs b/Tiles/CalamityGlobalTile.cs index d3bdbfd406..bccfbf26c0 100644 --- a/Tiles/CalamityGlobalTile.cs +++ b/Tiles/CalamityGlobalTile.cs @@ -63,11 +63,6 @@ namespace CalamityMod.Tiles Main.tileOreFinderPriority[TileID.LunarOre] = 900; } - public override bool PreHitWire(int i, int j, int type) - { - return !BossRushEvent.BossRushActive; - } - public override bool TileFrame(int i, int j, int type, ref bool resetFrame, ref bool noBreak) { // Custom plant framing diff --git a/Tiles/Crags/BrimstoneSlab.cs b/Tiles/Crags/BrimstoneSlab.cs index 04d2cd4666..61ff7a8d59 100644 --- a/Tiles/Crags/BrimstoneSlab.cs +++ b/Tiles/Crags/BrimstoneSlab.cs @@ -9,13 +9,11 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Crags { - public class BrimstoneSlab : ModTile, IMergeableTile + public class BrimstoneSlab : ModTile { private int subsheetWidth = 450; private int subsheetHeight = 198; - List IMergeableTile.TileAdjacencies { get; } = []; - public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/Crags/BrimstoneSlag.cs b/Tiles/Crags/BrimstoneSlag.cs index 3a1a485968..b63f9e0daa 100644 --- a/Tiles/Crags/BrimstoneSlag.cs +++ b/Tiles/Crags/BrimstoneSlag.cs @@ -8,13 +8,11 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Crags { - public class BrimstoneSlag : ModTile, IMergeableTile + public class BrimstoneSlag : ModTile { private const short subsheetWidth = 450; private const short subsheetHeight = 198; - List IMergeableTile.TileAdjacencies { get; } = []; - public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/Crags/ScorchedBone.cs b/Tiles/Crags/ScorchedBone.cs index 9a875a0ff7..540a6774d7 100644 --- a/Tiles/Crags/ScorchedBone.cs +++ b/Tiles/Crags/ScorchedBone.cs @@ -8,13 +8,12 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Crags { - public class ScorchedBone : ModTile, IMergeableTile + public class ScorchedBone : ModTile { private int sheetWidth = 450; private int sheetHeight = 198; - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/Crags/ScorchedRemains.cs b/Tiles/Crags/ScorchedRemains.cs index 74f47d6744..065de6ee5c 100644 --- a/Tiles/Crags/ScorchedRemains.cs +++ b/Tiles/Crags/ScorchedRemains.cs @@ -8,13 +8,12 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Crags { - public class ScorchedRemains : ModTile, IMergeableTile + public class ScorchedRemains : ModTile { private int sheetWidth = 234; private int sheetHeight = 90; - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/Crags/ScorchedRemainsGrass.cs b/Tiles/Crags/ScorchedRemainsGrass.cs index a83fa18de3..5cf19faafc 100644 --- a/Tiles/Crags/ScorchedRemainsGrass.cs +++ b/Tiles/Crags/ScorchedRemainsGrass.cs @@ -10,15 +10,13 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Crags { - public class ScorchedRemainsGrass : ModTile, IMergeableTile + public class ScorchedRemainsGrass : ModTile { private const short subsheetWidth = 234; private const short subsheetHeight = 90; private int extraFrameHeight = 36; private int extraFrameWidth = 90; - List IMergeableTile.TileAdjacencies { get; } = []; - public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/CryonicBrick.cs b/Tiles/CryonicBrick.cs index 96c010298a..cd7dbfeaa2 100644 --- a/Tiles/CryonicBrick.cs +++ b/Tiles/CryonicBrick.cs @@ -7,13 +7,12 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles { - public class CryonicBrick : ModTile, IMergeableTile + public class CryonicBrick : ModTile { int subsheetHeight = 90; int subsheetWidth = 234; - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/DraedonStructures/AgedReinforcedCrate.cs b/Tiles/DraedonStructures/AgedReinforcedCrate.cs index 6ff4190e16..826777407f 100644 --- a/Tiles/DraedonStructures/AgedReinforcedCrate.cs +++ b/Tiles/DraedonStructures/AgedReinforcedCrate.cs @@ -19,6 +19,7 @@ namespace CalamityMod.Tiles.DraedonStructures Main.tileNoAttach[Type] = true; Main.tileLavaDeath[Type] = false; Main.tileWaterDeath[Type] = false; + Main.tileTable[Type] = true; Main.tileSolidTop[Type] = true; TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); TileObjectData.newTile.LavaDeath = false; diff --git a/Tiles/DraedonStructures/LaboratoryPanels.cs b/Tiles/DraedonStructures/LaboratoryPanels.cs index 61724a0d54..d63549d56c 100644 --- a/Tiles/DraedonStructures/LaboratoryPanels.cs +++ b/Tiles/DraedonStructures/LaboratoryPanels.cs @@ -8,12 +8,11 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.DraedonStructures { - public class LaboratoryPanels : ModTile, IMergeableTile + public class LaboratoryPanels : ModTile { public static readonly SoundStyle MinePlatingSound = new("CalamityMod/Sounds/Custom/PlatingMine", 3); - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/DraedonStructures/LaboratoryPipePlating.cs b/Tiles/DraedonStructures/LaboratoryPipePlating.cs index 963d4ed162..d7ec964a52 100644 --- a/Tiles/DraedonStructures/LaboratoryPipePlating.cs +++ b/Tiles/DraedonStructures/LaboratoryPipePlating.cs @@ -8,12 +8,11 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.DraedonStructures { - public class LaboratoryPipePlating : ModTile, IMergeableTile + public class LaboratoryPipePlating : ModTile { public static readonly SoundStyle MinePlatingSound = new("CalamityMod/Sounds/Custom/PlatingMine", 3); - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/DraedonStructures/LaboratoryPlating.cs b/Tiles/DraedonStructures/LaboratoryPlating.cs index 9f6e1c8f72..c778e72cba 100644 --- a/Tiles/DraedonStructures/LaboratoryPlating.cs +++ b/Tiles/DraedonStructures/LaboratoryPlating.cs @@ -8,12 +8,10 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.DraedonStructures { - public class LaboratoryPlating : ModTile, IMergeableTile + public class LaboratoryPlating : ModTile { public static readonly SoundStyle MinePlatingSound = new("CalamityMod/Sounds/Custom/PlatingMine", 3); - List IMergeableTile.TileAdjacencies { get; } = []; - public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/DraedonStructures/ReinforcedCrate.cs b/Tiles/DraedonStructures/ReinforcedCrate.cs index 114871a032..06b9c32ffe 100644 --- a/Tiles/DraedonStructures/ReinforcedCrate.cs +++ b/Tiles/DraedonStructures/ReinforcedCrate.cs @@ -19,6 +19,7 @@ namespace CalamityMod.Tiles.DraedonStructures Main.tileNoAttach[Type] = true; Main.tileLavaDeath[Type] = false; Main.tileWaterDeath[Type] = false; + Main.tileTable[Type] = true; Main.tileSolidTop[Type] = true; TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); TileObjectData.newTile.LavaDeath = false; diff --git a/Tiles/DraedonStructures/RustedPlating.cs b/Tiles/DraedonStructures/RustedPlating.cs index 44eff8e23b..3dac585830 100644 --- a/Tiles/DraedonStructures/RustedPlating.cs +++ b/Tiles/DraedonStructures/RustedPlating.cs @@ -8,12 +8,10 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.DraedonStructures { - public class RustedPlating : ModTile, IMergeableTile + public class RustedPlating : ModTile { public static readonly SoundStyle MinePlatingSound = new("CalamityMod/Sounds/Custom/PlatingMine", 3); - - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/Furniture/BossRelics/AstrumDeusRelic.png b/Tiles/Furniture/BossRelics/AstrumDeusRelic.png index 841e350f40..1fdf1e0d99 100644 Binary files a/Tiles/Furniture/BossRelics/AstrumDeusRelic.png and b/Tiles/Furniture/BossRelics/AstrumDeusRelic.png differ diff --git a/Tiles/FurnitureAuric/AuricReinforcedCrateTile.cs b/Tiles/FurnitureAuric/AuricReinforcedCrateTile.cs index 5c8fa7fa53..6fcdd98125 100644 --- a/Tiles/FurnitureAuric/AuricReinforcedCrateTile.cs +++ b/Tiles/FurnitureAuric/AuricReinforcedCrateTile.cs @@ -17,6 +17,7 @@ namespace CalamityMod.Tiles.FurnitureAuric Main.tileLavaDeath[Type] = false; Main.tileWaterDeath[Type] = false; Main.tileSolidTop[Type] = true; + Main.tileTable[Type] = true; TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); TileObjectData.newTile.LavaDeath = false; TileObjectData.addTile(Type); diff --git a/Tiles/IMergeableTile.cs b/Tiles/IMergeableTile.cs deleted file mode 100644 index 9455c50bcc..0000000000 --- a/Tiles/IMergeableTile.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using Microsoft.Xna.Framework.Graphics; -using Terraria.ModLoader; - -namespace CalamityMod.Tiles -{ - /// - /// Interface for tiles that specify custom universal merge data. - /// - internal interface IMergeableTile - { - List TileAdjacencies { get; } - } - - internal static class MergeableTile - { - private sealed class MergeableTileGlobalTile : GlobalTile - { - public override void PostDraw(int i, int j, int type, SpriteBatch spriteBatch) - { - if (!TryGetMergeableTile(type, out var mergeableTile)) - return; - - TileFraming.DrawUniversalMergeFrames(i, j, mergeableTile.TileAdjacencies); - } - - public override bool TileFrame(int i, int j, int type, ref bool resetFrame, ref bool noBreak) - { - if (!TryGetMergeableTile(type, out var mergeableTile)) - return base.TileFrame(i, j, type, ref resetFrame, ref noBreak); - - foreach (var adjacency in mergeableTile.TileAdjacencies) - TileFraming.GetAdjacencyData(i, j, adjacency); - - return base.TileFrame(i, j, type, ref resetFrame, ref noBreak); - } - - private static bool TryGetMergeableTile(int type, [NotNullWhen(returnValue: true)] out IMergeableTile mergeableTile) - { - if (TileLoader.GetTile(type) is IMergeableTile theMergeableTile) - { - mergeableTile = theMergeableTile; - return true; - } - - mergeableTile = null; - return false; - } - } - - public static void RegisterUniversalMerge(this IMergeableTile mergeableTile, int tileId, string blendSheetPath) - { - if (mergeableTile is not ModTile tile) - throw new InvalidCastException($"{nameof(IMergeableTile)} is implemented on type {mergeableTile.GetType().FullName}; said type should inherit from {nameof(ModTile)}"); - - TileFraming.SetUpUniversalMerge(tile.Type, tileId, blendSheetPath, out var data); - mergeableTile.TileAdjacencies.Add(data); - } - } -} diff --git a/Tiles/MergeableTile.cs b/Tiles/MergeableTile.cs new file mode 100644 index 0000000000..86d6438fc6 --- /dev/null +++ b/Tiles/MergeableTile.cs @@ -0,0 +1,60 @@ +using System.Collections.Generic; +using Microsoft.Xna.Framework.Graphics; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Tiles +{ + internal static class MergeableTile + { + // CIT 25MAY2024: This custom tile merging system was repeatedly crashing the mod with an out of memory exception. + // Because the person who made this system is no longer on the dev team, I am just going to disable it again. + + private sealed class MergeableTileGlobalTile : GlobalTile + { + /*public override void PostDraw(int i, int j, int type, SpriteBatch spriteBatch) + { + TileFraming.DrawUniversalMergeFrames(i, j, GetOrCreateTileAdjacencies(type)); + } + + public override bool TileFrame(int i, int j, int type, ref bool resetFrame, ref bool noBreak) + { + foreach (var adjacency in GetOrCreateTileAdjacencies(type)) + TileFraming.GetAdjacencyData(i, j, adjacency); + + return base.TileFrame(i, j, type, ref resetFrame, ref noBreak); + }*/ + } + + private sealed class MergeableTileSystem : ModSystem + { + /*public override void PostSetupContent() + { + // Tomat: @heartplusup, you can add vanilla merges like so: + // RegisterUniversalMerge(TileID.Dirt, TileID.Stone, "CalamityMod/Tiles/Merges/StoneMerge"); - Already-merged tiles look weird; needs changes by someone else. + // RegisterUniversalMerge(TileID.WoodBlock, TileID.Stone, "CalamityMod/Tiles/Merges/StoneMerge"); + }*/ + } + + private static readonly Dictionary> tileAdjacencyMap = []; + + public static void RegisterUniversalMerge(this ModTile tile, int mergeType, string blendSheetPath) + { + // RegisterUniversalMerge(tile.Type, mergeType, blendSheetPath); + } + + public static void RegisterUniversalMerge(int tileId, int mergeType, string blendSheetPath) + { + // TileFraming.SetUpUniversalMerge(tileId, mergeType, blendSheetPath, out var data); + // GetOrCreateTileAdjacencies(tileId).Add(data); + } + + /*private static List GetOrCreateTileAdjacencies(int tileId) + { + /*if (!tileAdjacencyMap.TryGetValue(tileId, out var adjacencies)) + tileAdjacencyMap[tileId] = adjacencies = []; + + return adjacencies; + }*/ + } +} diff --git a/Tiles/Ores/AerialiteOre.cs b/Tiles/Ores/AerialiteOre.cs index 427c90d2b2..4c0aeb9049 100644 --- a/Tiles/Ores/AerialiteOre.cs +++ b/Tiles/Ores/AerialiteOre.cs @@ -11,13 +11,12 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Ores { - public class AerialiteOre : ModTile, IMergeableTile + public class AerialiteOre : ModTile { public static readonly SoundStyle MineSound = new("CalamityMod/Sounds/Custom/MagicalRockMine", 3); internal static Texture2D GlowTexture; - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { if (!Main.dedServ) diff --git a/Tiles/Ores/AerialiteOreDisenchanted.cs b/Tiles/Ores/AerialiteOreDisenchanted.cs index 4780b063e0..bd6f41dac4 100644 --- a/Tiles/Ores/AerialiteOreDisenchanted.cs +++ b/Tiles/Ores/AerialiteOreDisenchanted.cs @@ -7,12 +7,10 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Ores { - public class AerialiteOreDisenchanted : ModTile, IMergeableTile + public class AerialiteOreDisenchanted : ModTile { private const int AnimationFrameWidth = 234; - - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileBlockLight[Type] = true; diff --git a/Tiles/Ores/AstralOre.cs b/Tiles/Ores/AstralOre.cs index c2e220d120..2b9da5ece9 100644 --- a/Tiles/Ores/AstralOre.cs +++ b/Tiles/Ores/AstralOre.cs @@ -10,10 +10,9 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Ores { - public class AstralOre : ModTile, IMergeableTile + public class AstralOre : ModTile { - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileLighted[Type] = true; diff --git a/Tiles/Ores/AuricOre.cs b/Tiles/Ores/AuricOre.cs index 8d5facedb2..bc4ad02243 100644 --- a/Tiles/Ores/AuricOre.cs +++ b/Tiles/Ores/AuricOre.cs @@ -14,14 +14,13 @@ using Terraria.ObjectData; namespace CalamityMod.Tiles.Ores { - public class AuricOre : ModTile, IMergeableTile + public class AuricOre : ModTile { public static readonly SoundStyle MineSound = new("CalamityMod/Sounds/Custom/AuricMine", 3); public static bool Animate; internal static Texture2D GlowTexture; - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { if (!Main.dedServ) diff --git a/Tiles/Ores/ExodiumOre.cs b/Tiles/Ores/ExodiumOre.cs index 41fc92d67f..298a81c0e1 100644 --- a/Tiles/Ores/ExodiumOre.cs +++ b/Tiles/Ores/ExodiumOre.cs @@ -10,10 +10,9 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Ores { - public class ExodiumOre : ModTile, IMergeableTile + public class ExodiumOre : ModTile { - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/Ores/HallowedOre.cs b/Tiles/Ores/HallowedOre.cs index 049ca594f2..dfe58dd453 100644 --- a/Tiles/Ores/HallowedOre.cs +++ b/Tiles/Ores/HallowedOre.cs @@ -9,10 +9,9 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Ores { - public class HallowedOre : ModTile, IMergeableTile + public class HallowedOre : ModTile { - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileLighted[Type] = true; diff --git a/Tiles/Ores/InfernalSuevite.cs b/Tiles/Ores/InfernalSuevite.cs index 4d00e3d10c..9c5aa5ff20 100644 --- a/Tiles/Ores/InfernalSuevite.cs +++ b/Tiles/Ores/InfernalSuevite.cs @@ -10,13 +10,11 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Ores { [LegacyName("CharredOre")] - public class InfernalSuevite : ModTile, IMergeableTile + public class InfernalSuevite : ModTile { private int sheetWidth = 234; private int sheetHeight = 90; - - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/Ores/PerennialOre.cs b/Tiles/Ores/PerennialOre.cs index 08d732e51e..3cc6d1c162 100644 --- a/Tiles/Ores/PerennialOre.cs +++ b/Tiles/Ores/PerennialOre.cs @@ -11,12 +11,10 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Ores { - public class PerennialOre : ModTile, IMergeableTile + public class PerennialOre : ModTile { internal static Texture2D GlowTexture; - List IMergeableTile.TileAdjacencies { get; } = []; - public override void SetStaticDefaults() { if (!Main.dedServ) diff --git a/Tiles/Ores/ScoriaOre.cs b/Tiles/Ores/ScoriaOre.cs index 238f5f1cd4..fe8efcf707 100644 --- a/Tiles/Ores/ScoriaOre.cs +++ b/Tiles/Ores/ScoriaOre.cs @@ -12,10 +12,8 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Ores { [LegacyName("ChaoticOre")] - public class ScoriaOre : ModTile, IMergeableTile + public class ScoriaOre : ModTile { - List IMergeableTile.TileAdjacencies { get; } = []; - public override void SetStaticDefaults() { Main.tileLighted[Type] = true; diff --git a/Tiles/Ores/UelibloomOre.cs b/Tiles/Ores/UelibloomOre.cs index 14ab406efd..b213b57d7b 100644 --- a/Tiles/Ores/UelibloomOre.cs +++ b/Tiles/Ores/UelibloomOre.cs @@ -9,10 +9,9 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.Ores { - public class UelibloomOre : ModTile, IMergeableTile + public class UelibloomOre : ModTile { - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/PerennialBrick.cs b/Tiles/PerennialBrick.cs index 9133c5f6cb..0b647557dc 100644 --- a/Tiles/PerennialBrick.cs +++ b/Tiles/PerennialBrick.cs @@ -8,10 +8,9 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles { - public class PerennialBrick : ModTile, IMergeableTile + public class PerennialBrick : ModTile { - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/Rubblemaker/SunkenSea/SmallCoralsEcho.cs b/Tiles/Rubblemaker/SunkenSea/SmallCoralsEcho.cs index 65c88d8234..099fc82862 100644 --- a/Tiles/Rubblemaker/SunkenSea/SmallCoralsEcho.cs +++ b/Tiles/Rubblemaker/SunkenSea/SmallCoralsEcho.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Tiles.Rubblemaker.SunkenSea Main.tileNoAttach[Type] = true; Main.tileNoFail[Type] = true; Main.tileLavaDeath[Type] = true; - Main.tileWaterDeath[Type] = true; + Main.tileWaterDeath[Type] = false; Main.tileFrameImportant[Type] = true; TileID.Sets.ReplaceTileBreakUp[Type] = true; TileID.Sets.SwaysInWindBasic[Type] = false; diff --git a/Tiles/ScoriaBrick.cs b/Tiles/ScoriaBrick.cs index 800e5d6d57..1509aa27f4 100644 --- a/Tiles/ScoriaBrick.cs +++ b/Tiles/ScoriaBrick.cs @@ -10,13 +10,12 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles { [LegacyName("ChaoticBrick")] - public class ScoriaBrick : ModTile, IMergeableTile + public class ScoriaBrick : ModTile { int subsheetHeight = 72; internal static Texture2D GlowTexture; - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { if (!Main.dedServ) diff --git a/Tiles/SunkenSea/EutrophicSand.cs b/Tiles/SunkenSea/EutrophicSand.cs index c9ef48f1f5..58baf6e83c 100644 --- a/Tiles/SunkenSea/EutrophicSand.cs +++ b/Tiles/SunkenSea/EutrophicSand.cs @@ -10,10 +10,8 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.SunkenSea { - public class EutrophicSand : ModTile, IMergeableTile + public class EutrophicSand : ModTile { - List IMergeableTile.TileAdjacencies { get; } = []; - public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/SunkenSea/HardenedEutrophicSand.cs b/Tiles/SunkenSea/HardenedEutrophicSand.cs index 209e0a22cd..b198501573 100644 --- a/Tiles/SunkenSea/HardenedEutrophicSand.cs +++ b/Tiles/SunkenSea/HardenedEutrophicSand.cs @@ -8,10 +8,8 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.SunkenSea { - public class HardenedEutrophicSand : ModTile, IMergeableTile + public class HardenedEutrophicSand : ModTile { - List IMergeableTile.TileAdjacencies { get; } = []; - public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/SunkenSea/Navystone.cs b/Tiles/SunkenSea/Navystone.cs index 8799172e30..783d94f011 100644 --- a/Tiles/SunkenSea/Navystone.cs +++ b/Tiles/SunkenSea/Navystone.cs @@ -8,10 +8,8 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.SunkenSea { - public class Navystone : ModTile, IMergeableTile + public class Navystone : ModTile { - List IMergeableTile.TileAdjacencies { get; } = []; - public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/SunkenSea/SeaPrism.cs b/Tiles/SunkenSea/SeaPrism.cs index 83d6da7082..c0227a3a46 100644 --- a/Tiles/SunkenSea/SeaPrism.cs +++ b/Tiles/SunkenSea/SeaPrism.cs @@ -8,13 +8,11 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles.SunkenSea { - public class SeaPrism : ModTile, IMergeableTile + public class SeaPrism : ModTile { private const short subsheetWidth = 450; private const short subsheetHeight = 198; - List IMergeableTile.TileAdjacencies { get; } = []; - public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/SunkenSea/SmallCorals.cs b/Tiles/SunkenSea/SmallCorals.cs index 6848dccbca..84237a5d3e 100644 --- a/Tiles/SunkenSea/SmallCorals.cs +++ b/Tiles/SunkenSea/SmallCorals.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Tiles.SunkenSea Main.tileNoAttach[Type] = true; Main.tileNoFail[Type] = true; Main.tileLavaDeath[Type] = true; - Main.tileWaterDeath[Type] = true; + Main.tileWaterDeath[Type] = false; Main.tileFrameImportant[Type] = true; TileID.Sets.ReplaceTileBreakUp[Type] = true; TileID.Sets.SwaysInWindBasic[Type] = false; diff --git a/Tiles/UelibloomBrick.cs b/Tiles/UelibloomBrick.cs index ee453b6ab0..49b1e8e449 100644 --- a/Tiles/UelibloomBrick.cs +++ b/Tiles/UelibloomBrick.cs @@ -10,13 +10,11 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles { - public class UelibloomBrick : ModTile, IMergeableTile + public class UelibloomBrick : ModTile { private int extraFrameHeight = 36; private int extraFrameWidth = 90; - List IMergeableTile.TileAdjacencies { get; } = []; - public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/Tiles/VernalSoil.cs b/Tiles/VernalSoil.cs index eb4e766460..ebfd615be2 100644 --- a/Tiles/VernalSoil.cs +++ b/Tiles/VernalSoil.cs @@ -11,10 +11,9 @@ using Terraria.ModLoader; namespace CalamityMod.Tiles { - public class VernalSoil : ModTile, IMergeableTile + public class VernalSoil : ModTile { - List IMergeableTile.TileAdjacencies { get; } = []; - + public override void SetStaticDefaults() { Main.tileSolid[Type] = true; diff --git a/UI/DebuffSystem/ColdDebuffType.png b/UI/DebuffSystem/ColdDebuffType.png index eb0a88f11a..f64ac9f30b 100644 Binary files a/UI/DebuffSystem/ColdDebuffType.png and b/UI/DebuffSystem/ColdDebuffType.png differ diff --git a/UI/DebuffSystem/ElectricityDebuffType.png b/UI/DebuffSystem/ElectricityDebuffType.png index 30539636b2..e77f2d6947 100644 Binary files a/UI/DebuffSystem/ElectricityDebuffType.png and b/UI/DebuffSystem/ElectricityDebuffType.png differ diff --git a/UI/DebuffSystem/HeatDebuffType.png b/UI/DebuffSystem/HeatDebuffType.png index 8b25d715bb..d1c54b3e8d 100644 Binary files a/UI/DebuffSystem/HeatDebuffType.png and b/UI/DebuffSystem/HeatDebuffType.png differ diff --git a/UI/DebuffSystem/SicknessDebuffType.png b/UI/DebuffSystem/SicknessDebuffType.png index db56ba8449..8c498f6d77 100644 Binary files a/UI/DebuffSystem/SicknessDebuffType.png and b/UI/DebuffSystem/SicknessDebuffType.png differ diff --git a/UI/DebuffSystem/WaterDebuffType.png b/UI/DebuffSystem/WaterDebuffType.png index 1e41f4d471..66ee4d3800 100644 Binary files a/UI/DebuffSystem/WaterDebuffType.png and b/UI/DebuffSystem/WaterDebuffType.png differ diff --git a/UI/VanillaBossBars/ProfanedGuardianBossBar.cs b/UI/VanillaBossBars/ProfanedGuardianBossBar.cs new file mode 100644 index 0000000000..35afbb34b6 --- /dev/null +++ b/UI/VanillaBossBars/ProfanedGuardianBossBar.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using CalamityMod.NPCs.ProfanedGuardians; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.GameContent; +using Terraria.GameContent.UI.BigProgressBar; +using Terraria.ID; +using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.UI.VanillaBossBars +{ + public class ProfanedGuardianBossBar : ModBossBar + { + // Used to determine the max health of a multi-segmented boss + public NPC FalseNPCSegment; + + public override Asset GetIconTexture(ref Rectangle? iconFrame) + { + // Icons are based on whoever should die first + if (NPC.AnyNPCs(NPCType())) + return TextureAssets.NpcHeadBoss[NPCID.Sets.BossHeadTextures[NPCType()]]; + + if (NPC.AnyNPCs(NPCType())) + return TextureAssets.NpcHeadBoss[NPCID.Sets.BossHeadTextures[NPCType()]]; + + return TextureAssets.NpcHeadBoss[NPCID.Sets.BossHeadTextures[NPCType()]]; + } + + public override bool? ModifyInfo(ref BigProgressBarInfo info, ref float life, ref float lifeMax, ref float shield, ref float shieldMax) + { + NPC target = Main.npc[info.npcIndexToAimAt]; + + if (!target.active) + return false; + + // Get the commander's health + life = target.life; + lifeMax = target.lifeMax; + + // Add max health by feeding the data of false NPCs + FalseNPCSegment = new NPC(); + FalseNPCSegment.SetDefaults(NPCType(), target.GetMatchingSpawnParams()); + lifeMax += FalseNPCSegment.lifeMax; + FalseNPCSegment.SetDefaults(NPCType(), target.GetMatchingSpawnParams()); + lifeMax += FalseNPCSegment.lifeMax; + + // Determine the current health of all guardians + foreach (NPC guardian in Main.ActiveNPCs) + { + if (guardian.type == NPCType() || guardian.type == NPCType()) + life += guardian.life; + } + return true; + } + } +} diff --git a/Utilities/CalamityRecipes.cs b/Utilities/CalamityRecipes.cs index 81a27225f2..bc4aefe0a0 100644 --- a/Utilities/CalamityRecipes.cs +++ b/Utilities/CalamityRecipes.cs @@ -356,7 +356,8 @@ namespace CalamityMod ItemID.PalmWoodSword, ItemID.EbonwoodSword, ItemID.ShadewoodSword, - ItemID.PearlwoodSword + ItemID.PearlwoodSword, + ItemID.AshWoodSword }); AnyWoodenSword = RecipeGroup.RegisterGroup("AnyWoodenSword", group); diff --git a/Utilities/ItemUtils.cs b/Utilities/ItemUtils.cs index 88bb34ef06..2a1911dd9e 100644 --- a/Utilities/ItemUtils.cs +++ b/Utilities/ItemUtils.cs @@ -136,7 +136,7 @@ namespace CalamityMod { // Terrarian (has its own special "Legendary" for marketing reasons) // Other items that want to use Legendary2 are also compatible - if (item.type == ItemID.Terrarian || PrefixLegacy.ItemSets.ItemsThatCanHaveLegendary2[item.type]) + if (PrefixLegacy.ItemSets.ItemsThatCanHaveLegendary2[item.type]) { int[][] terrarianReforgeTiers = new int[][] { @@ -148,26 +148,8 @@ namespace CalamityMod prefix = IteratePrefix(rand, terrarianReforgeTiers, currentPrefix); } - // Yoyos, Flails, Spears, etc. - // Spears actually work fine with Legendary, but vanilla doesn't give it to them, so we won't either. - // Rapiers, whips, and other specific vanilla weapons (ie. Zenith or Excalibur) are specifically excluded from this, so they get broadsword reforges despite not scaling with melee speed. - // - // 18FEB2024: Ozzatron: removed the (item.channel || item.noMelee) because vanilla lets Burning Sky get Legendary - // 12MAY2024: Shade: added item.useStyle != ItemUseStyleID.Shoot because vanilla lets Sahara Slicers and Death's Ascension get Legendary - else if (item.channel && item.useStyle != ItemUseStyleID.Rapier && !item.CountsAsClass() && !PrefixLegacy.ItemSets.SwordsHammersAxesPicks[item.type] && item.useStyle != ItemUseStyleID.Shoot) - { - int[][] meleeNoSpeedReforgeTiers = new int[][] - { - /* 0 */ new int[] { PrefixID.Keen, PrefixID.Forceful, PrefixID.Strong }, - /* 1 */ new int[] { PrefixID.Hurtful, PrefixID.Ruthless, PrefixID.Zealous }, - /* 2 */ new int[] { PrefixID.Superior, PrefixID.Demonic }, - /* 3 */ new int[] { PrefixID.Godly } - }; - prefix = IteratePrefix(rand, meleeNoSpeedReforgeTiers, currentPrefix); - } - - // All other melee weapons - else + // Swords, Whips, Tools, other items that support the Legendary modifier + else if (PrefixLegacy.ItemSets.SwordsHammersAxesPicks[item.type] || (item.ModItem != null && item.ModItem.MeleePrefix())) { int[][] meleeReforgeTiers = new int[][] { @@ -180,7 +162,7 @@ namespace CalamityMod }; int[][] toolReforgeTiers = new int[][] { - /* 0 */ new int[] { PrefixID.Keen, PrefixID.Nimble, PrefixID.Nasty, PrefixID.Heavy, PrefixID.Light, PrefixID.Forceful, PrefixID.Strong }, + /* 0 */ new int[] { PrefixID.Keen, PrefixID.Nimble, PrefixID.Nasty, PrefixID.Heavy, PrefixID.Forceful, PrefixID.Strong }, /* 1 */ new int[] { PrefixID.Hurtful, PrefixID.Ruthless, PrefixID.Zealous, PrefixID.Quick, PrefixID.Pointy, PrefixID.Bulky }, /* 2 */ new int[] { PrefixID.Murderous, PrefixID.Agile, PrefixID.Large, PrefixID.Dangerous, PrefixID.Sharp }, /* 3 */ new int[] { PrefixID.Massive, PrefixID.Unpleasant, PrefixID.Savage, PrefixID.Superior }, @@ -191,6 +173,20 @@ namespace CalamityMod var tierListToUse = (item.pick > 0 || item.axe > 0 || item.hammer > 0) ? toolReforgeTiers : meleeReforgeTiers; prefix = IteratePrefix(rand, tierListToUse, currentPrefix); } + + // Yoyos, Flails, Spears, etc. + // Spears actually work fine with Legendary, but vanilla doesn't give it to them, so we won't either. + else + { + int[][] meleeNoSpeedReforgeTiers = new int[][] + { + /* 0 */ new int[] { PrefixID.Keen, PrefixID.Forceful, PrefixID.Strong }, + /* 1 */ new int[] { PrefixID.Hurtful, PrefixID.Ruthless, PrefixID.Zealous }, + /* 2 */ new int[] { PrefixID.Superior, PrefixID.Demonic }, + /* 3 */ new int[] { PrefixID.Godly } + }; + prefix = IteratePrefix(rand, meleeNoSpeedReforgeTiers, currentPrefix); + } } // RANGED diff --git a/Utilities/NPCDebuffs.cs b/Utilities/NPCDebuffs.cs index c66dbc74d2..ff965a1105 100644 --- a/Utilities/NPCDebuffs.cs +++ b/Utilities/NPCDebuffs.cs @@ -168,9 +168,9 @@ namespace CalamityMod // Is this sorted... like... at all?? EnemyStats.DebuffImmunities = new SortedDictionary> { - { ModContent.NPCType(), immuneToEverything }, - { ModContent.NPCType(), immuneToEverything }, - { ModContent.NPCType(), immuneToEverything }, + { ModContent.NPCType(), immuneToEverything }, + { ModContent.NPCType(), immuneToEverything }, + { ModContent.NPCType(), immuneToEverything }, { NPCID.Deerclops, ice }, diff --git a/Utilities/NPCUtils.cs b/Utilities/NPCUtils.cs index c28f3fdab4..719631c115 100644 --- a/Utilities/NPCUtils.cs +++ b/Utilities/NPCUtils.cs @@ -1,15 +1,15 @@ -using System.Linq; -using System.Reflection; +using System; +using System.Linq; using CalamityMod.Balancing; -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; using CalamityMod.DataStructures; +using CalamityMod.Enums; using CalamityMod.Events; using CalamityMod.NPCs; using CalamityMod.NPCs.NormalNPCs; using CalamityMod.NPCs.OldDuke; using CalamityMod.NPCs.Providence; using CalamityMod.NPCs.SlimeGod; +using CalamityMod.NPCs.Yharon; using CalamityMod.Projectiles.Boss; using CalamityMod.World; using Microsoft.Xna.Framework; @@ -24,8 +24,85 @@ using static Terraria.ModLoader.ModContent; namespace CalamityMod { + #region Calamity Targeting Parameters Struct + public struct CalamityTargetingParameters + { + // Vanilla argument to TargetClosest. Defaults to true as it does in vanilla. + // If true, the NPC will turn to face the target. + public bool faceTarget = true; + + // Vanilla argument to TargetClosestUpgraded. That function is never used, but the flexibility is implemented here. + // Allows targeting distance calculations to be measured from a different position than the NPC's center, if desired. + public Vector2? targetingCenter = null; + + // Hard maximum range to search for targets. Players outside this physical Manhattan distance will always be ignored. + // + // Vanilla always uses infinity for this, leading to behavior like Queen Bee crossing the world to spawncamp you. + // Calamity defaults to a very high but not infinite value. + public float maxSearchRange = 9600f; // 600 tiles + + // Targeting preference enum. + // Anyone = Target the "closest" player, no other considerations. Vanilla behavior. + // PreferSame = Always pick the same player if they're within the search range, even if another player is closer or has more aggro. + // ForceSwitch = Try to pick any other player but the current player, if possible. Similar to an "aggro drop" in MMOs. + // + // ForceSwitch intentionally does nothing in single player, because there is nobody to switch to. + public NPCTargetType targetType = NPCTargetType.Anyone; + + // The ratio at which to consider aggro bonuses from player gear. + // 1f is vanilla. Set to 0f to ignore aggro bonuses entirely. + // Set to a negative value to make the NPC intentionally avoid tanks and preferentially go after other players. + public float aggroRatio = 1f; + + // Whether or not players must have line of sight to the NPC to be considered valid targets. + // This is always line of sight to the NPC itself, even if a different targeting center for range finding is specified. + public bool requireLineOfSight = false; + + // If true, the targeting algorithm counts missing health as a gigantic boost to aggro. + // This makes for a "merciless" or "bloodthirsty" NPC which is focused on killing the lowest health players. + public bool finishThemOff = false; + internal const float FinishThemOff_MaxAggroBoost = 4000f; + + // If true, this NPC ignores the Stardust armor set bonus "JoJo Tank Minion" (or "Algalon the Observer" according to the wiki). + // + // This is set to false by default, because that's vanilla behavior. + // As Stardust armor is postgame in vanilla, no vanilla bosses ignore the Stardust Guardian. + // It is highly recommended to set this to true for all bosses, or their aggro can be abusively manipulated. + public bool ignoreTankMinions = false; + + // If true, this NPC ignores players who have less than zero net aggro and are not actively using items. + // + // This is set to true by default, because it's (undocumented) vanilla behavior. + // Bosses will automatically attack stealthed players anyway -- you don't need to set this to false for that to occur. + public bool ignoreStealthedPlayers = true; + + // If true, this targeting change forces a net update. + // In vanilla, targeting updates cause net updates if direction changed or the target player changed, + // but NEVER if the NPC has collideX or collideY set to true. + // + // Generally this doesn't need to be set to true, as bosses will never have collideX or collideY set to true. + public bool forceNetUpdate = false; + + public CalamityTargetingParameters() + { + } + + // Quick defaults for recommended boss settings. + public CalamityTargetingParameters(bool isBoss) + { + ignoreTankMinions = isBoss; + } + + public static CalamityTargetingParameters BossDefaults => new(true); + } + #endregion + + public static partial class CalamityUtils { + public static T ModNPC(this NPC npc) where T : ModNPC => npc.ModNPC as T; + + #region NPC Counting /// /// Efficiently counts the amount of existing enemies. May be used for multiple enemies. /// @@ -49,6 +126,22 @@ namespace CalamityMod return count; } + public static bool AnyBossNPCS(bool checkForMechs = false) + { + foreach (NPC npc in Main.ActiveNPCs) + { + if (npc.IsABoss()) + { + // Added due to the new mech boss ore progression, return true if any mech is alive and checkForMechs is true, reduces mech boss projectile damage if true. + if (checkForMechs) + return npc.type == NPCID.TheDestroyer || npc.type == NPCID.SkeletronPrime || npc.type == NPCID.Spazmatism || npc.type == NPCID.Retinazer; + return true; + } + } + return FindFirstProjectile(ProjectileType()) != -1; + } + #endregion + /// /// Hides an NPC from the bestiary. This should be called in SetStaticDefaults. /// @@ -62,23 +155,7 @@ namespace CalamityMod NPCID.Sets.NPCBestiaryDrawOffset.Add(n.Type, value); } - /// - /// Syncs position and velocity from a client to the server. This is to be used in contexts where these things are reliant on client-side information, such as . - /// - /// - public static void SyncMotionToServer(this NPC npc) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - return; - - var netMessage = CalamityMod.Instance.GetPacket(); - netMessage.Write((byte)CalamityModMessageType.SyncNPCMotionDataToServer); - netMessage.Write(npc.whoAmI); - netMessage.WriteVector2(npc.Center); - netMessage.WriteVector2(npc.velocity); - netMessage.Send(); - } - + #region Stat Setting /// /// Allows you to set the lifeMax value of a NPC to different values based on the mode. Called instead of npc.lifeMax = X. /// @@ -123,7 +200,9 @@ namespace CalamityMod if (customDR.HasValue) npc.Calamity().customDR = true; } + #endregion + #region NPC Threat Classification // This function controls the behavior of Proximity Rage. // // TODO -- In multiplayer, with more than one player, all enemies are listed as statue spawned. @@ -147,7 +226,7 @@ namespace CalamityMod // "Non-enemies" (e.g. butterflies or projectile enemies) with near zero max health, // or anything but the strongest enemies with no contact damage (e.g. Celestial Pillars, Providence) // do not generate rage. - if (npc.lifeMax <= BalancingConstants.TinyHealthThreshold || (npc.damage <= BalancingConstants.TinyDamageThreshold && npc.lifeMax <= BalancingConstants.NoContactDamageHealthThreshold)) + if (npc.lifeMax <= BalancingConstants.TinyHealthThreshold || (npc.defDamage <= BalancingConstants.TinyDamageThreshold && npc.lifeMax <= BalancingConstants.NoContactDamageHealthThreshold)) return false; // Also explicitly exclude dummies and anything with a ridiculous health pool (dummies from Fargo's for example). if (npc.type == NPCID.TargetDummy || npc.type == NPCType() || npc.lifeMax > BalancingConstants.UnreasonableHealthThreshold) @@ -171,39 +250,9 @@ namespace CalamityMod return npc.type == NPCType() || npc.type == NPCType() || npc.type == NPCType() || npc.type == NPCType(); } + #endregion - public static bool AnyBossNPCS(bool checkForMechs = false) - { - foreach (NPC npc in Main.ActiveNPCs) - { - if (npc.IsABoss()) - { - // Added due to the new mech boss ore progression, return true if any mech is alive and checkForMechs is true, reduces mech boss projectile damage if true. - if (checkForMechs) - return npc.type == NPCID.TheDestroyer || npc.type == NPCID.SkeletronPrime || npc.type == NPCID.Spazmatism || npc.type == NPCID.Retinazer; - return true; - } - } - return FindFirstProjectile(ProjectileType()) != -1; - } - - /// - /// Syncs . This exists to sync the Destroyer's lasers so that the telegraphs and segment colors display properly. - /// - /// - public static void SyncDestroyerLaserColor(this NPC npc) - { - // Don't bother attempting to send packets in singleplayer. - if (Main.netMode == NetmodeID.SinglePlayer) - return; - - ModPacket packet = CalamityMod.Instance.GetPacket(); - packet.Write((byte)CalamityModMessageType.SyncDestroyerLaserColor); - packet.Write((byte)npc.whoAmI); - packet.Write(npc.Calamity().destroyerLaserColor); - packet.Send(); - } - + #region Net Synchronization /// /// Syncs . This exists specifically for AIs manipulated in a global context, as has no netUpdate related hooks. /// @@ -244,6 +293,257 @@ namespace CalamityMod packet.Send(); } + /// + /// Syncs position and velocity from a client to the server. This is to be used in contexts where these things are reliant on client-side information, such as . + /// + /// + public static void SyncMotionToServer(this NPC npc) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + return; + + var netMessage = CalamityMod.Instance.GetPacket(); + netMessage.Write((byte)CalamityModMessageType.SyncNPCMotionDataToServer); + netMessage.Write(npc.whoAmI); + netMessage.WriteVector2(npc.Center); + netMessage.WriteVector2(npc.velocity); + netMessage.Send(); + } + + /// + /// Syncs . This exists to sync the Destroyer's lasers so that the telegraphs and segment colors display properly. + /// + /// + public static void SyncDestroyerLaserColor(this NPC npc) + { + // Don't bother attempting to send packets in singleplayer. + if (Main.netMode == NetmodeID.SinglePlayer) + return; + + ModPacket packet = CalamityMod.Instance.GetPacket(); + packet.Write((byte)CalamityModMessageType.SyncDestroyerLaserColor); + packet.Write((byte)npc.whoAmI); + packet.Write(npc.Calamity().destroyerLaserColor); + packet.Send(); + } + #endregion + + #region Smooth Movement + /// + /// Smoother movement for NPCs + /// + /// The NPC getting the movement change. + /// The distance where the NPC should stop moving once it's close enough to its destination. + /// How far the NPC is from its destination. + /// How quickly the NPC moves towards its destination. + /// Whether the NPC should use SimpleFlyMovement to make the movement more affected by acceleration. + public static void SmoothMovement(NPC npc, float movementDistanceGateValue, Vector2 distanceFromDestination, float baseVelocity, float acceleration, bool useSimpleFlyMovement) + { + // Inverse lerp returns the percentage of progress between A and B + float lerpValue = Utils.GetLerpValue(movementDistanceGateValue, 2400f, distanceFromDestination.Length(), true); + + // Min velocity + float minVelocity = distanceFromDestination.Length(); + float minVelocityCap = baseVelocity; + if (minVelocity > minVelocityCap) + minVelocity = minVelocityCap; + + // Max velocity + Vector2 maxVelocity = distanceFromDestination / 24f; + float maxVelocityCap = minVelocityCap * 3f; + if (maxVelocity.Length() > maxVelocityCap) + maxVelocity = distanceFromDestination.SafeNormalize(Vector2.Zero) * maxVelocityCap; + + // Set the velocity + Vector2 desiredVelocity = Vector2.Lerp(distanceFromDestination.SafeNormalize(Vector2.Zero) * minVelocity, maxVelocity, lerpValue); + if (useSimpleFlyMovement) + npc.SimpleFlyMovement(desiredVelocity, acceleration); + else + npc.velocity = desiredVelocity; + } + #endregion + + #region Calamity Style Targeting + /// + /// Replacement and extension for vanilla's NPC.TargetClosest. Has very flexible behavior.
+ /// Like vanilla's function, this function does not return any value, but makes its changes in-place. + ///
+ /// Struct to specify all options. Refer to struct definition in NPCUtils for details. + /// The targeted player ID. + public static int CalamityTargeting(this NPC npc, CalamityTargetingParameters options) + { + float distance = 0f; + // float realDist = 0f; // Defined but not used by vanilla. Commented out here. + bool anyTargetAvailable = false; + int tankMinionProjectileID = -1; + + // The setup and initial loop is equivalent to vanilla NPC.TargetClosest, but optimized. + foreach (Player p in Main.ActivePlayers) + { + bool playerDead = p.dead || p.ghost; + if (playerDead) + continue; + + // ForceSwitch targeting. If the same player from last time is iterated over, just ignore them. + bool sameTargetAsLastTime = p.whoAmI == npc.oldTarget; + bool notSinglePlayer = Main.netMode != NetmodeID.SinglePlayer; + if (options.targetType == NPCTargetType.ForceSwitch && notSinglePlayer && sameTargetAsLastTime) + continue; + + // + // The below code is implemented in vanilla as a separate method. Here, it's inlined for efficiency. + // + + Vector2 pCenter = p.Center; + Vector2 targetCenter = options.targetingCenter ?? npc.Center; + float manhattanDist = Math.Abs(targetCenter.X - pCenter.X) + Math.Abs(targetCenter.Y - pCenter.Y); + + // Hard cutoff range specified in options. If the player is further, completely ignore them. + if (manhattanDist > options.maxSearchRange) + continue; + + // Line of sight requirement specified in options. Please don't use this without reducing the max search range. + if (options.requireLineOfSight && !Collision.CanHit(npc.Center, 1, 1, pCenter, 1, 1)) + continue; + + float aggroAdjustedDist = manhattanDist - options.aggroRatio * p.aggro; + + // Implementation of "Finish Them Off": Add enormous amounts of virtual aggro to low health players + if (options.finishThemOff) + { + float missingHPRatio = MathHelper.Clamp(1f - p.statLife / (float)p.statLifeMax2, 0f, 1f); + float bloodthirstAggro = MathHelper.Lerp(0f, CalamityTargetingParameters.FinishThemOff_MaxAggroBoost, missingHPRatio); + aggroAdjustedDist -= bloodthirstAggro; + } + + bool aggroDisabled = p.npcTypeNoAggro[npc.type]; + if (aggroDisabled && npc.direction != 0) + aggroAdjustedDist += 1000f; + + bool cancelTargeting = false; + + // PreferSame targeting. If the same player from last time is a valid target, even if not the "best" target, pick it anyway. + bool preferSameFound = options.targetType == NPCTargetType.PreferSame && sameTargetAsLastTime; + + // Standard targeting. If the adjusted distance is lower, or this is the first valid target, actually choose the new target. + bool standardTargetingRequirementsMet = !anyTargetAvailable || aggroAdjustedDist < distance; + + // If either targeting method succeeded, then this target is being engaged. + bool engageThisTarget = preferSameFound || standardTargetingRequirementsMet; + if (engageThisTarget) + { + anyTargetAvailable = true; + tankMinionProjectileID = -1; // Reset any Stardust Guardian aggro because a real player was found. + distance = aggroAdjustedDist; + npc.target = p.whoAmI; + + // If PreferSame targeting is active, and the same player was found, cancel further iteration. They are being chosen above all others. + if (preferSameFound) + cancelTargeting = true; + } + + // "Tank pet" accomodation, AKA the 1.4+ Stardust Guardian + // Basically, if the player would be targeted, give a chance to instead target their tank minion + // + // This behavior is not documented on the vanilla wiki. + if (p.tankPet >= 0 && !aggroDisabled && !options.ignoreTankMinions) + { + Projectile tankMinion = Main.projectile[p.tankPet]; + Vector2 tmCenter = tankMinion.Center; + float manhattanDistToTankMinion = Math.Abs(targetCenter.X - tmCenter.X) + Math.Abs(targetCenter.Y - tmCenter.Y); + + // The Stardust Guardian is considered to have a 200 aggro bonus by default. + // In Calamity this is scaled by the aggro ratio specified in options. + manhattanDistToTankMinion -= options.aggroRatio * 200f; + + // The Stardust Guardian only attracts the attention of NPCs within a very short distance + if (manhattanDistToTankMinion < distance && manhattanDistToTankMinion < 200f && Collision.CanHit(npc.Center, 1, 1, tmCenter, 1, 1)) + tankMinionProjectileID = p.tankPet; + } + + // If targeting has been short-circuited for any reason, cancel iteration over players. + if (cancelTargeting) + break; + } + + // If the NPC has been aggroed by a Stardust Guardian instead of an actual player, account for that + if (tankMinionProjectileID >= 0) + { + Projectile tankMinion = Main.projectile[tankMinionProjectileID]; + npc.targetRect = tankMinion.Hitbox; + + // Always set direction to a nonzero value. This NPC has been engaged in combat. + npc.direction = 1; + if (tankMinion.Center.X < npc.Center.X) + npc.direction = -1; + + npc.directionY = 1; + if (tankMinion.Center.Y < npc.Center.Y) + npc.directionY = -1; + } + + // Standard player aggro occurs here + else + { + bool shouldFaceTarget = options.faceTarget; + + // Sanitize targeted player index + if (npc.target < 0 || npc.target >= Main.maxPlayers) + npc.target = 0; + + Player targetPlayer = Main.player[npc.target]; + npc.targetRect = targetPlayer.Hitbox; + + // Do not switch facing to look at dead players. + if (targetPlayer.dead) + shouldFaceTarget = false; + + // If already engaged in combat, do not switch facing to look at players that ignore your aggro. + if (targetPlayer.npcTypeNoAggro[npc.type] && npc.direction != 0) + shouldFaceTarget = false; + + if (shouldFaceTarget) + { + bool oldTargetWasValid = npc.oldTarget >= 0 && npc.oldTarget < Main.maxPlayers; + + bool targetIsLowAggroNotUsingItem = targetPlayer.itemAnimation == 0 && targetPlayer.aggro < 0; + bool willIgnoreStealthedPlayers = !npc.boss && options.ignoreStealthedPlayers; + + // Regular NPCs (not bosses) will voluntarily ignore otherwise-valid player targets with less than zero aggro if they are not actively using an item. + // This ONLY WORKS if they already have another valid target, aka multiplayer. + // As such, having net less than zero aggro enables you to remain "stealthed" to regular enemies if you are not doing anything. + // This is undocumented vanilla behavior. + bool ignoreStealthedPlayer = willIgnoreStealthedPlayers && oldTargetWasValid && targetIsLowAggroNotUsingItem; + if (!ignoreStealthedPlayer) + { + // Always set direction to a nonzero value. This NPC has been engaged in combat. + npc.direction = 1; + if (targetPlayer.Center.X < npc.Center.X) + npc.direction = -1; + + npc.directionY = 1; + if (targetPlayer.Center.Y < npc.Center.Y) + npc.directionY = -1; + } + } + } + + // Confused enemies always run in the exact wrong direction, horizontally at least. + if (npc.confused) + npc.direction *= -1; + + // Apply net updates. + bool directionChange = npc.direction != npc.oldDirection || npc.directionY != npc.oldDirectionY; + bool targetChange = npc.target != npc.oldTarget; + bool shouldNetUpdate = (directionChange || targetChange) && !npc.collideX && !npc.collideY; + if (shouldNetUpdate || options.forceNetUpdate) + npc.netUpdate = true; + + return npc.target; + } + #endregion + + #region Minion Homing /// /// Detects nearby hostile NPCs from a given point /// @@ -306,6 +606,53 @@ namespace CalamityMod return closestTarget; } + /// + /// Detects the hostile NPC that is closest angle-wise to the rotation vector + /// + /// The position that will be used to find the rotation vector to NPCs + /// The rotation vector that the other rotation vectors to NPCs will be compared to + /// Maximum amount of pixels to check around the origin + /// When the angle between the rotation vector and the vector to the NPC is less than or equal to this, NPCs start getting ranked by distance. Set to 0 or less to ignore + /// Whether or not to ignore tiles when finding a target + /// The NPC that best fits the parameters. Null if no NPC is found + public static NPC ClosestNPCToAngle(this Vector2 origin, Vector2 checkRotationVector, float maxDistanceToCheck, float wantedHalfCone = 0.125f, bool ignoreTiles = true) + { + NPC closestTarget = null; + float distance = maxDistanceToCheck; + float angle = MathHelper.Pi; + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC npc = Main.npc[i]; + if (!npc.CanBeChasedBy(null, false)) + continue; + + float checkDist = origin.Distance(npc.Center); + if (checkDist >= distance) // Immediately disqualify anything beyond the distance that must be beaten + continue; + + float angleBetween = checkRotationVector.AngleBetween(npc.Center - origin); + if (angleBetween > angle) // Narrow down to the closest npc to the angle + continue; + + if (!ignoreTiles && !Collision.CanHit(origin, 1, 1, npc.Center, 1, 1)) // Tile LoS check if wanted + continue; + + if (angle <= wantedHalfCone) + { + angle = wantedHalfCone; + distance = checkDist; // We are within the cone. Now npcs are further narrowed down by distance + closestTarget = npc; + } + else + { + angle = angleBetween; + closestTarget = npc; + } + } + + return closestTarget; + } + /// /// Detects nearby hostile NPCs from a given point with minion support /// @@ -329,39 +676,7 @@ namespace CalamityMod } return ClosestNPCAt(origin, maxDistanceToCheck, ignoreTiles); } - - /// - /// Smoother movement for NPCs - /// - /// The NPC getting the movement change. - /// The distance where the NPC should stop moving once it's close enough to its destination. - /// How far the NPC is from its destination. - /// How quickly the NPC moves towards its destination. - /// Whether the NPC should use SimpleFlyMovement to make the movement more affected by acceleration. - public static void SmoothMovement(NPC npc, float movementDistanceGateValue, Vector2 distanceFromDestination, float baseVelocity, float acceleration, bool useSimpleFlyMovement) - { - // Inverse lerp returns the percentage of progress between A and B - float lerpValue = Utils.GetLerpValue(movementDistanceGateValue, 2400f, distanceFromDestination.Length(), true); - - // Min velocity - float minVelocity = distanceFromDestination.Length(); - float minVelocityCap = baseVelocity; - if (minVelocity > minVelocityCap) - minVelocity = minVelocityCap; - - // Max velocity - Vector2 maxVelocity = distanceFromDestination / 24f; - float maxVelocityCap = minVelocityCap * 3f; - if (maxVelocity.Length() > maxVelocityCap) - maxVelocity = distanceFromDestination.SafeNormalize(Vector2.Zero) * maxVelocityCap; - - // Set the velocity - Vector2 desiredVelocity = Vector2.Lerp(distanceFromDestination.SafeNormalize(Vector2.Zero) * minVelocity, maxVelocity, lerpValue); - if (useSimpleFlyMovement) - npc.SimpleFlyMovement(desiredVelocity, acceleration); - else - npc.velocity = desiredVelocity; - } + #endregion /// /// Check if an NPC is organic @@ -375,31 +690,13 @@ namespace CalamityMod target.HitSound != SoundID.NPCHit34 && target.HitSound != SoundID.NPCHit36 && target.HitSound != SoundID.NPCHit42 && target.HitSound != SoundID.NPCHit49 && target.HitSound != SoundID.NPCHit52 && target.HitSound != SoundID.NPCHit53 && target.HitSound != SoundID.NPCHit54 && target.HitSound != null) || target.type == NPCType() || - target.type == NPCType()) + target.type == NPCType() || target.type == NPCType()) { return true; } return false; } - /// - /// Shortcut for the generic boss summon message. - /// - /// The whoAmI index of the summoned npc. - public static void BossAwakenMessage(int npcIndex) - { - // TODO -- this should use MiscUtils DisplayLocalizedText. - string typeName = Main.npc[npcIndex].TypeName; - if (Main.netMode == NetmodeID.SinglePlayer) - { - Main.NewText(Language.GetTextValue("Announcement.HasAwoken", typeName), new Color(175, 75, 255)); - } - else if (Main.netMode == NetmodeID.Server) - { - ChatHelper.BroadcastChatMessage(NetworkText.FromKey("Announcement.HasAwoken", new object[] { Main.npc[npcIndex].GetTypeNetName() }), new Color(175, 75, 255)); - } - } - public static void Inflict246DebuffsNPC(NPC target, int buff, float timeBase = 2f) { if (Main.rand.NextBool(4)) @@ -416,8 +713,6 @@ namespace CalamityMod } } - public static T ModNPC(this NPC npc) where T : ModNPC => npc.ModNPC as T; - public static NPCShop AddWithCustomValue(this NPCShop shop, int itemType, int customValue, params Condition[] conditions) { var item = new Item(itemType) @@ -432,6 +727,38 @@ namespace CalamityMod return shop.AddWithCustomValue(ItemType(), customValue, conditions); } + public static void DrawBackglow(this NPC npc, Color backglowColor, float backglowArea, SpriteEffects spriteEffects, Rectangle frame, Vector2 screenPos, Texture2D overrideTexture = null) + { + Texture2D texture = overrideTexture is null ? TextureAssets.Npc[npc.type].Value : overrideTexture; + Vector2 drawPosition = npc.Center - screenPos; + Vector2 origin = frame.Size() * 0.5f; + Color backAfterimageColor = backglowColor * npc.Opacity; + for (int i = 0; i < 10; i++) + { + Vector2 drawOffset = (MathHelper.TwoPi * i / 10f).ToRotationVector2() * backglowArea; + Main.spriteBatch.Draw(texture, drawPosition + drawOffset, frame, backAfterimageColor, npc.rotation, origin, npc.scale, spriteEffects, 0f); + } + } + + #region Boss Spawning + /// + /// Shortcut for the generic boss summon message. + /// + /// The whoAmI index of the summoned npc. + public static void BossAwakenMessage(int npcIndex) + { + // TODO -- this should use MiscUtils DisplayLocalizedText. + string typeName = Main.npc[npcIndex].TypeName; + if (Main.netMode == NetmodeID.SinglePlayer) + { + Main.NewText(Language.GetTextValue("Announcement.HasAwoken", typeName), new Color(175, 75, 255)); + } + else if (Main.netMode == NetmodeID.Server) + { + ChatHelper.BroadcastChatMessage(NetworkText.FromKey("Announcement.HasAwoken", new object[] { Main.npc[npcIndex].GetTypeNetName() }), new Color(175, 75, 255)); + } + } + /// /// Summons a boss near a particular area depending on a specific spawn context. /// @@ -465,19 +792,6 @@ namespace CalamityMod return null; } - public static void DrawBackglow(this NPC npc, Color backglowColor, float backglowArea, SpriteEffects spriteEffects, Rectangle frame, Vector2 screenPos, Texture2D overrideTexture = null) - { - Texture2D texture = overrideTexture is null ? TextureAssets.Npc[npc.type].Value : overrideTexture; - Vector2 drawPosition = npc.Center - screenPos; - Vector2 origin = frame.Size() * 0.5f; - Color backAfterimageColor = backglowColor * npc.Opacity; - for (int i = 0; i < 10; i++) - { - Vector2 drawOffset = (MathHelper.TwoPi * i / 10f).ToRotationVector2() * backglowArea; - Main.spriteBatch.Draw(texture, drawPosition + drawOffset, frame, backAfterimageColor, npc.rotation, origin, npc.scale, spriteEffects, 0f); - } - } - /// /// Spawns Old Duke on a player. Only works server side, and only works if the player owns a fishing bobber.
/// Old Duke will spawn above the fishing bobber if one is found. @@ -508,5 +822,6 @@ namespace CalamityMod int oldDuke = NPC.NewNPC(NPC.GetBossSpawnSource(playerIndex), (int)projectile.Center.X, (int)projectile.Center.Y + 100, NPCType()); BossAwakenMessage(oldDuke); } + #endregion } } diff --git a/Utilities/PlayerUtils.cs b/Utilities/PlayerUtils.cs index eab0501756..faf8ed2d66 100644 --- a/Utilities/PlayerUtils.cs +++ b/Utilities/PlayerUtils.cs @@ -887,7 +887,7 @@ namespace CalamityMod ///
/// The player using the holdout. /// Returns if the player CAN'T use the item. - public static bool CantUseHoldout(this Player player) => player == null || !player.active || player.dead || !player.channel || player.CCed || player.noItems; + public static bool CantUseHoldout(this Player player, bool needsToHold = true) => player == null || !player.active || player.dead || (!player.channel && needsToHold) || player.CCed || player.noItems; /// /// Makes the given player send the given packet to all appropriate receivers.
diff --git a/build.txt b/build.txt index f6d015e792..b80ad208f0 100644 --- a/build.txt +++ b/build.txt @@ -1,5 +1,5 @@ author = Fabsol and the Dev Team -version = 2.0.4.001 +version = 2.0.4.002 displayName = Calamity Mod modReferences = CalamityModMusic homepage = https://discord.gg/calamity